From 45e1b786144b8ef0a70a235f8a1a89e90a752d8f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 12 Jan 2017 20:51:12 -0500 Subject: 0.11.0 improved message passing, using templates --- org/ao_output_debugs.org | 126 +++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 80 deletions(-) (limited to 'org/ao_output_debugs.org') diff --git a/org/ao_output_debugs.org b/org/ao_output_debugs.org index 886adb1..f0a8cab 100644 --- a/org/ao_output_debugs.org +++ b/org/ao_output_debugs.org @@ -23,14 +23,9 @@ +/ template SiSUoutputDebugs() { struct SDPoutputDebugs { - auto abstract_doc_source_debugs(S)( + auto abstract_doc_source_debugs(S,T)( auto ref const S contents, - string[][string] document_section_keys_sequenced, - string[] html_segnames, - string[string][string] dochead_make, - string[string][string] dochead_meta, - string fn_src, - bool[string] opt_action_bool + auto ref T doc_matters, ) { mixin RgxInit; mixin InternalMarkup; @@ -66,7 +61,7 @@ debug(parent) { __FILE__, __LINE__, ); - foreach (key; document_section_keys_sequenced["seg"]) { + foreach (key; doc_matters.keys_seq_seg) { foreach (obj; contents[key]) { if (obj.use != "empty") { if (obj.is_a == "heading") { @@ -112,16 +107,15 @@ debug(dumpdoc) { #+name: ao_output_debugs #+BEGIN_SRC d -void out_segnames(S)( +void out_segnames(S,T)( auto ref const S contents, - string[] keys, - string[] html_segnames, + auto ref T doc_matters, ) { - foreach (key; keys) { + foreach (key; doc_matters.keys_seq_seg) { if (contents[key].length > 1) { foreach (obj; contents[key]) { if (obj.heading_lev_markup == 4) { - writeln(obj.ptr_html_segnames, ". (", html_segnames[obj.ptr_html_segnames], ") -> ", obj.text); + writeln(obj.ptr_html_segnames, ". (", doc_matters.segnames[obj.ptr_html_segnames], ") -> ", obj.text); } } } @@ -247,26 +241,8 @@ debug(section_toc_scroll) { #+name: ao_output_debugs #+BEGIN_SRC d debug(segnames) { - key="toc_scroll"; writeln(__LINE__); - string[] keys; - keys ~= [ "toc_seg", "body" ]; - if (contents["endnotes_seg"].length > 1) { - keys ~= "endnotes_seg"; - } - if (contents["glossary"].length > 1) { - keys ~= "glossary"; - } - if (contents["bibliography"].length > 1) { - keys ~= "bibliography"; - } - if (contents["bookindex_seg"].length > 1) { - keys ~= "bookindex_seg"; - } - if (contents["blurb"].length > 1) { - keys ~= "blurb"; - } - out_segnames(contents, keys, html_segnames); + out_segnames(contents, doc_matters); } #+END_SRC @@ -295,7 +271,7 @@ debug(section_body) { #+BEGIN_SRC d debug(dom) { enum DomTags { none, open, close, close_and_open, open_still, } - foreach (sect; document_section_keys_sequenced["seg"]) { + foreach (sect; doc_matters.keys_seq_seg) { foreach (obj; contents[sect]) { if (obj.is_a == "heading") { foreach_reverse (k; 0 .. 7) { @@ -318,7 +294,7 @@ debug(dom) { } } writeln("--------------------"); - foreach (sect; document_section_keys_sequenced["seg"]) { + foreach (sect; doc_matters.keys_seq_seg) { foreach (obj; contents[sect]) { if (obj.is_a == "heading") { foreach_reverse (k; 0 .. 7) { @@ -350,7 +326,7 @@ debug(dom) { #+name: ao_output_debugs #+BEGIN_SRC d debug(section_endnotes) { - key="endnotes_seg"; + key="endnotes"; out_endnotes(contents, key); } #+END_SRC @@ -360,17 +336,7 @@ debug(section_endnotes) { #+name: ao_output_debugs #+BEGIN_SRC d debug(section_endnotes_seg) { - key="endnotes_seg"; - out_endnotes(contents, key); -} -#+END_SRC - -**** endnotes scroll - -#+name: ao_output_debugs -#+BEGIN_SRC d -debug(section_endnotes_scroll) { - key="endnotes_scroll"; + key="endnotes"; out_endnotes(contents, key); } #+END_SRC @@ -497,19 +463,19 @@ debug(headermakejson) { writefln( "%s\n%s\n%s", "document header, metadata & make instructions:", - dochead_meta, + doc_matters.dochead_meta, ptr_head_main, ); foreach (main_header; ptr_head_main) { switch (main_header) { case "make": foreach (sub_header; ptr_head_sub_make) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } @@ -529,115 +495,115 @@ debug(headermetadatajson) { writefln( "%s\n%s\n%s", "document header, metadata & make instructions:", - dochead_meta, + doc_matters.dochead_meta, ptr_head_main, ); foreach (main_header; ptr_head_main) { switch (main_header) { case "creator": foreach (sub_header; ptr_head_sub_creator) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "title": foreach (sub_header; ptr_head_sub_title) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "rights": foreach (sub_header; ptr_head_sub_rights) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "date": foreach (sub_header; ptr_head_sub_date) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "original": foreach (sub_header; ptr_head_sub_original) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "classify": foreach (sub_header; ptr_head_sub_classify) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "identifier": foreach (sub_header; ptr_head_sub_identifier) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "notes": foreach (sub_header; ptr_head_sub_notes) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } break; case "publisher": foreach (sub_header; ptr_head_sub_publisher) { - if (to!string(dochead_meta[main_header][sub_header]).length > 2) { + if (to!string(doc_matters.dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", main_header, sub_header, - dochead_meta[main_header][sub_header] + doc_matters.dochead_meta[main_header][sub_header] ); } } @@ -660,7 +626,7 @@ debug(anchor) { __FILE__, __LINE__, ); - foreach (k; document_section_keys_sequenced["seg"]) { + foreach (k; doc_matters.keys_seq_seg) { foreach (obj; contents[k]) { if (obj.is_a == "heading") { writefln( @@ -682,7 +648,7 @@ debug(anchor) { #+name: ao_output_debugs #+BEGIN_SRC d debug(heading) { // heading - foreach (k; document_section_keys_sequenced["seg"]) { + foreach (k; doc_matters.keys_seq_seg) { foreach (o; contents[k]) { if (o.is_a == "heading") { writefln( @@ -709,7 +675,7 @@ debug(headings) { __FILE__, __LINE__, ); - foreach (k; document_section_keys_sequenced["seg"]) { + foreach (k; doc_matters.keys_seq_seg) { foreach (obj; contents[k]) { if (obj.is_a == "heading") { writefln( @@ -738,7 +704,7 @@ debug(summary) { #+name: ao_output_debugs_summary #+BEGIN_SRC d debug(checkdoc) { - foreach (k; document_section_keys_sequenced["seg"]) { + foreach (k; doc_matters.keys_seq_seg) { foreach (obj; contents[k]) { if (obj.use != "empty") { if (!empty(obj.obj_cite_number)) { @@ -757,9 +723,9 @@ debug(checkdoc) { writefln( "%s\n\"%s\", %s\n%s\n%s\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n%s%10d\n(%s: %s)", "---------------------------------", - dochead_meta["title"]["full"], - dochead_meta["creator"]["author"], - fn_src, + doc_matters.dochead_meta["title"]["full"], + doc_matters.dochead_meta["creator"]["author"], + doc_matters.source_filename, "---------------------------------", "length toc array: ", to!int(contents["toc_seg"].length), @@ -768,8 +734,8 @@ writefln( "last obj_cite_number: ", to!int(check["last_obj_cite_number"]), "length endnotes: ", - (contents["endnotes_seg"].length > 1) - ? (to!int(contents["endnotes_seg"].length)) + (contents["endnotes"].length > 1) + ? (to!int(contents["endnotes"].length)) : 0, "length glossary: ", (contents["glossary"].length > 1) @@ -797,8 +763,8 @@ writefln( #+name: ao_output_debugs_summary #+BEGIN_SRC d debug(checkdoc) { - if (auto mfn=match(fn_src, rgx.src_fn)) { - if (opt_action_bool["assertions"]) { + if (auto mfn=match(doc_matters.source_filename, rgx.src_fn)) { + if (doc_matters.opt_action_bool["assertions"]) { switch (mfn.captures[2]) { // live manual: case "live-manual.ssm": @@ -917,7 +883,7 @@ debug(checkdoc) { // error in bookindex ... (ch7 ... building the cc machine, an extra semi colon) break; default: - writeln(fn_src); + writeln(doc_matters.source_filename); break; } } -- cgit v1.2.3