[Debugging::] Debugging Format. A format which renders as a plain-text serialisation of the Inweb weave tree, useful only for testing the weaver. @h Creation. = void Debugging::create(void) { weave_format *wf = Formats::create_weave_format(I"TestingInweb", I".txt"); METHOD_ADD(wf, RENDER_FOR_MTID, Debugging::render); } @h Methods. For documentation, see "Weave Fornats". = typedef struct debugging_render_state { struct text_stream *OUT; struct weave_order *wv; } debugging_render_state; void Debugging::render(weave_format *self, text_stream *OUT, heterogeneous_tree *tree) { weave_document_node *C = RETRIEVE_POINTER_weave_document_node(tree->root->content); debugging_render_state drs; drs.OUT = OUT; drs.wv = C->wv; Trees::traverse_from(tree->root, &Debugging::render_visit, (void *) &drs, 0); } int Debugging::render_visit(tree_node *N, void *state, int L) { debugging_render_state *drs = (debugging_render_state *) state; text_stream *OUT = drs->OUT; for (int i=0; itype->node_type_name); if (N->type == weave_document_node_type) @ else if (N->type == weave_head_node_type) @ else if (N->type == weave_body_node_type) @ else if (N->type == weave_tail_node_type) @ else if (N->type == weave_verbatim_node_type) @ else if (N->type == weave_chapter_header_node_type) @ else if (N->type == weave_chapter_footer_node_type) @ else if (N->type == weave_section_header_node_type) @ else if (N->type == weave_section_footer_node_type) @ else if (N->type == weave_section_purpose_node_type) @ else if (N->type == weave_subheading_node_type) @ else if (N->type == weave_bar_node_type) @ else if (N->type == weave_pagebreak_node_type) @ else if (N->type == weave_linebreak_node_type) @ else if (N->type == weave_paragraph_heading_node_type) @ else if (N->type == weave_endnote_node_type) @ else if (N->type == weave_figure_node_type) @ else if (N->type == weave_audio_node_type) @ else if (N->type == weave_video_node_type) @ else if (N->type == weave_download_node_type) @ else if (N->type == weave_material_node_type) @ else if (N->type == weave_embed_node_type) @ else if (N->type == weave_pmac_node_type) @ else if (N->type == weave_vskip_node_type) @ else if (N->type == weave_chapter_node_type) @ else if (N->type == weave_section_node_type) @ else if (N->type == weave_code_line_node_type) @ else if (N->type == weave_function_usage_node_type) @ else if (N->type == weave_commentary_node_type) @ else if (N->type == weave_carousel_slide_node_type) @ else if (N->type == weave_toc_node_type) @ else if (N->type == weave_toc_line_node_type) @ else if (N->type == weave_chapter_title_page_node_type) @ else if (N->type == weave_defn_node_type) @ else if (N->type == weave_source_code_node_type) @ else if (N->type == weave_url_node_type) @ else if (N->type == weave_footnote_cue_node_type) @ else if (N->type == weave_begin_footnote_text_node_type) @ else if (N->type == weave_display_line_node_type) @ else if (N->type == weave_function_defn_node_type) @ else if (N->type == weave_item_node_type) @ else if (N->type == weave_grammar_index_node_type) @ else if (N->type == weave_inline_node_type) @ else if (N->type == weave_locale_node_type) @ else if (N->type == weave_maths_node_type) @ else WRITE("Unknown node"); WRITE("\n"); return TRUE; } @ = weave_document_node *C = RETRIEVE_POINTER_weave_document_node(N->content); WRITE(" weave order %d", C->wv->allocation_id); @ = weave_head_node *C = RETRIEVE_POINTER_weave_head_node(N->content); WRITE(" banner <%S>", C->banner); @ = ; @ = weave_tail_node *C = RETRIEVE_POINTER_weave_tail_node(N->content); WRITE(" rennab <%S>", C->rennab); @ = weave_verbatim_node *C = RETRIEVE_POINTER_weave_verbatim_node(N->content); Debugging::show_text(OUT, C->content, 80); @ = weave_section_header_node *C = RETRIEVE_POINTER_weave_section_header_node(N->content); WRITE(" <%S>", C->sect->md->sect_title); @ = weave_section_footer_node *C = RETRIEVE_POINTER_weave_section_footer_node(N->content); WRITE(" <%S>", C->sect->md->sect_title); @ = weave_chapter_header_node *C = RETRIEVE_POINTER_weave_chapter_header_node(N->content); WRITE(" <%S>", C->chap->md->ch_title); @ = weave_chapter_footer_node *C = RETRIEVE_POINTER_weave_chapter_footer_node(N->content); WRITE(" <%S>", C->chap->md->ch_title); @ = weave_section_purpose_node *C = RETRIEVE_POINTER_weave_section_purpose_node(N->content); WRITE(" <%S>", C->purpose); @ = weave_subheading_node *C = RETRIEVE_POINTER_weave_subheading_node(N->content); WRITE(" <%S>", C->text); @ = ; @ = ; @ = ; @ = weave_paragraph_heading_node *C = RETRIEVE_POINTER_weave_paragraph_heading_node(N->content); Debugging::show_para(OUT, C->para); if (C->no_skip) WRITE(" (no skip)"); @ = ; @ = weave_figure_node *C = RETRIEVE_POINTER_weave_figure_node(N->content); WRITE(" <%S> %d by %d", C->figname, C->w, C->h); @ = weave_audio_node *C = RETRIEVE_POINTER_weave_audio_node(N->content); WRITE(" <%S> %d", C->audio_name, C->w); @ = weave_video_node *C = RETRIEVE_POINTER_weave_video_node(N->content); WRITE(" <%S> %d", C->video_name, C->w); @ = weave_download_node *C = RETRIEVE_POINTER_weave_download_node(N->content); WRITE(" <%S> %S", C->download_name, C->filetype); @ = weave_material_node *C = RETRIEVE_POINTER_weave_material_node(N->content); WRITE(" "); Debugging::show_mat(OUT, C->material_type); if (C->material_type == CODE_MATERIAL) WRITE(": %S", C->styling->language_name); if (C->plainly) WRITE(" (plainly)"); @ = weave_embed_node *C = RETRIEVE_POINTER_weave_embed_node(N->content); WRITE(" service <%S> ID <%S> %d by %d", C->service, C->ID, C->w, C->h); @ = weave_pmac_node *C = RETRIEVE_POINTER_weave_pmac_node(N->content); WRITE(" <%S>", C->pmac->macro_name); if (C->defn) WRITE(" (definition)"); @ = weave_vskip_node *C = RETRIEVE_POINTER_weave_vskip_node(N->content); if (C->in_comment) WRITE(" (in comment)"); @ = ; @ = weave_chapter_node *C = RETRIEVE_POINTER_weave_chapter_node(N->content); WRITE(" <%S>", C->chap->md->ch_title); @ = weave_section_node *C = RETRIEVE_POINTER_weave_section_node(N->content); WRITE(" <%S>", C->sect->md->sect_title); @ = ; @ = weave_function_usage_node *C = RETRIEVE_POINTER_weave_function_usage_node(N->content); WRITE(" <%S>", C->fn->function_name); @ = weave_commentary_node *C = RETRIEVE_POINTER_weave_commentary_node(N->content); Debugging::show_text(OUT, C->text, 80); if (C->in_code) WRITE(" (code)"); @ = weave_carousel_slide_node *C = RETRIEVE_POINTER_weave_carousel_slide_node(N->content); WRITE(" caption <%S>", C->caption); @ = weave_toc_node *C = RETRIEVE_POINTER_weave_toc_node(N->content); WRITE(" - <%S>", C->text1); @ = weave_toc_line_node *C = RETRIEVE_POINTER_weave_toc_line_node(N->content); WRITE(" - <%S, %S>", C->text1, C->text2); if (C->para) Debugging::show_para(OUT, C->para); @ = weave_chapter_title_page_node *C = RETRIEVE_POINTER_weave_chapter_title_page_node(N->content); WRITE(" - something %d", C->allocation_id); @ = weave_defn_node *C = RETRIEVE_POINTER_weave_defn_node(N->content); WRITE(" <%S>", C->keyword); @ = weave_source_code_node *C = RETRIEVE_POINTER_weave_source_code_node(N->content); WRITE(" <%S>\n", C->matter); for (int i=0; icolouring); @ = weave_url_node *C = RETRIEVE_POINTER_weave_url_node(N->content); WRITE(" content <%S> url <%S>", C->content, C->url); @ = weave_footnote_cue_node *C = RETRIEVE_POINTER_weave_footnote_cue_node(N->content); WRITE(" [%S]", C->cue_text); @ = weave_begin_footnote_text_node *C = RETRIEVE_POINTER_weave_begin_footnote_text_node(N->content); WRITE(" [%S]", C->cue_text); @ = weave_display_line_node *C = RETRIEVE_POINTER_weave_display_line_node(N->content); WRITE(" <%S>", C->text); @ = weave_function_defn_node *C = RETRIEVE_POINTER_weave_function_defn_node(N->content); WRITE(" <%S>", C->fn->function_name); @ = weave_item_node *C = RETRIEVE_POINTER_weave_item_node(N->content); WRITE(" depth %d label <%S>", C->depth, C->label); @ = ; @ = ; @ = weave_locale_node *C = RETRIEVE_POINTER_weave_locale_node(N->content); Debugging::show_para(OUT, C->par1); if (C->par2) { WRITE(" to "); Debugging::show_para(OUT, C->par2); } @ = weave_maths_node *C = RETRIEVE_POINTER_weave_maths_node(N->content); WRITE(" <%S>", C->content); if (C->displayed) WRITE(" (displayed)"); @ = void Debugging::show_text(text_stream *OUT, text_stream *text, int limit) { WRITE(" <"); for (int i=0; (i"); if (Str::len(text) > limit) WRITE(" ... continues to %d chars", Str::len(text)); } void Debugging::show_para(text_stream *OUT, paragraph *P) { WRITE(" P%S", P->paragraph_number); if (Str::len(P->heading_text) > 0) WRITE("'%S'", P->heading_text); } void Debugging::show_mat(text_stream *OUT, int m) { switch (m) { case COMMENTARY_MATERIAL: WRITE("discussion"); break; case MACRO_MATERIAL: WRITE("paragraph macro"); break; case DEFINITION_MATERIAL: WRITE("definition"); break; case CODE_MATERIAL: WRITE("code"); break; case ENDNOTES_MATERIAL: WRITE("endnotes"); break; case FOOTNOTES_MATERIAL: WRITE("footnotes"); break; default: WRITE("unknown"); break; } }