diff options
-rw-r--r-- | flake.lock | 6 | ||||
-rw-r--r-- | org/ocda.org | 608 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 608 |
3 files changed, 1001 insertions, 221 deletions
@@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1688894907, - "narHash": "sha256-U7hEDDhzAhLp6T+DEUbfwAsL+BtqFFGn+S1pa/0XrZY=", + "lastModified": 1688956120, + "narHash": "sha256-7geHGr2aLpQvwGgaZlTLPHMVFxvFzAuB35mZYsKgLpQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4ddf98349c793377c76806ebfbdfb2b96dd4ef5d", + "rev": "2169d3b0bce0daa64d05abbdf9da552a7b8c22a7", "type": "github" }, "original": { diff --git a/org/ocda.org b/org/ocda.org index 1750549..46dc72c 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -110,8 +110,7 @@ template docAbstraction() { } // close after non code, other blocks or regular text <<abs_in_loop_body_reloop_get_prior_state>> } /+ ← srcDocLoop closed: loop markup document/text line by line +/ - /+ ↓ post loop markup document/text +/ - /+ ↓ post loop markup document/text +/ + /+ ↓ post loop markup document/text +/ <<abs_loop_body_exit_eof_xml_dom_tail>> <<abs_post_endnote_tuple>> <<abs_post_glossary_nugget>> @@ -910,14 +909,13 @@ debug (substitutions) { #+NAME: abs_in_loop_body_00_0 #+BEGIN_SRC d /+ scope +/ -scope(exit) { -} +scope(exit) { } scope(failure) { stderr.writefln( - "%s\n%s\n%s:%s failed here:\n line: %s", + "\n%s\n%s\n\n%s:%s\nFAILED while processing the file: ❮❮ %s ❯❯ on line with text:\n%s\n", __MODULE__, __FUNCTION__, __FILE__, __LINE__, - line, + manifested.src.filename, line, ); } debug(source) { @@ -925,10 +923,7 @@ debug(source) { } debug(srclines) { if (!line.empty) { - writefln( - "* %s", - line - ); + writefln("* %s", line); } } #+END_SRC @@ -5180,7 +5175,7 @@ if (pith["block_is"] == eN.blk_is.quote) { } an_object[an_object_key] ~= line ~= "\n"; an_object["lev"] ~= m.captures[1]; - assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels + assertions_doc_structure(an_object, an_object_key, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": // Title set if ((an_object[an_object_key].match(rgx.variable_doc_title_author_date)) @@ -7768,173 +7763,568 @@ invariant() { #+BEGIN_SRC d @safe pure void assertions_doc_structure()( string[string] an_object, + string an_object_key, int[string] lv ) { + string msg_error_doc_struct = "\nERROR in document structure, check markup (heading level relationships):\n"; if (lv["h3"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h2"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h1"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h0"] > eN.bi.off) { - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else { - assert(lv["h0"] == eN.bi.off); - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h7"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h6"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h5"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h4"] > eN.bi.off) { - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else { - assert(lv["h4"] == eN.bi.off); - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h0"] == eN.bi.off) { - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); - assert(lv["h4"] == eN.bi.off); - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h1"] == eN.bi.off) { - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h2"] == eN.bi.off) { - assert(lv["h3"] == eN.bi.off); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h3"] == eN.bi.off) { } if (lv["h4"] == eN.bi.off) { - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h5"] == eN.bi.off) { - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h6"] == eN.bi.off) { - assert(lv["h7"] == eN.bi.off); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h7"] == eN.bi.off) { } switch ((an_object["lev"]).to!string) { case "A": if (lv["h0"] == eN.bi.off) { - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); - assert(lv["h4"] == eN.bi.off); - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h0"] > eN.bi.off) - assert(lv["h0"] == eN.bi.off,"error should not enter level A a second time"); + assert(lv["h0"] == eN.bi.off, + msg_error_doc_struct + ~ "should not enter level A a second time\n" + ~ "at level A~\n" + ~ an_object[an_object_key] + ); } break; case "B": if (lv["h1"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h1"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); } break; case "C": if (lv["h2"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "level C should not follow level A\n" + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h2"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); } break; case "D": if (lv["h3"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "level D should not follow level A\n" + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h3"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); - assert(lv["h3"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); } break; case "1": if (lv["h4"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h4"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); } break; case "2": if (lv["h5"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h5"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); } break; case "3": if (lv["h6"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 2~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h6"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); } break; case "4": if (lv["h7"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 2~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 3~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h7"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); - assert(lv["h7"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); } break; default: diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 3962beb..59cbc0b 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -610,14 +610,13 @@ template docAbstraction() { foreach (line; markup_sourcefile_content) { /+ ↓ markup document/text line by line +/ // "line" variable can be empty but should never be null /+ scope +/ - scope(exit) { - } + scope(exit) { } scope(failure) { stderr.writefln( - "%s\n%s\n%s:%s failed here:\n line: %s", + "\n%s\n%s\n\n%s:%s\nFAILED while processing the file: ❮❮ %s ❯❯ on line with text:\n%s\n", __MODULE__, __FUNCTION__, __FILE__, __LINE__, - line, + manifested.src.filename, line, ); } debug(source) { @@ -625,10 +624,7 @@ template docAbstraction() { } debug(srclines) { if (!line.empty) { - writefln( - "* %s", - line - ); + writefln("* %s", line); } } if (!line.empty) { @@ -1310,8 +1306,7 @@ template docAbstraction() { } } } /+ ← srcDocLoop closed: loop markup document/text line by line +/ - /+ ↓ post loop markup document/text +/ - /+ ↓ post loop markup document/text +/ + /+ ↓ post loop markup document/text +/ { // EOF comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -4049,7 +4044,7 @@ template docAbstraction() { } an_object[an_object_key] ~= line ~= "\n"; an_object["lev"] ~= m.captures[1]; - assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels + assertions_doc_structure(an_object, an_object_key, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": // Title set if ((an_object[an_object_key].match(rgx.variable_doc_title_author_date)) @@ -6165,173 +6160,568 @@ template docAbstraction() { /+ ↓ abstraction functions assertions +/ @safe pure void assertions_doc_structure()( string[string] an_object, + string an_object_key, int[string] lv ) { + string msg_error_doc_struct = "\nERROR in document structure, check markup (heading level relationships):\n"; if (lv["h3"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h2"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h1"] > eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h0"] > eN.bi.off) { - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else { - assert(lv["h0"] == eN.bi.off); - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h7"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h6"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h5"] > eN.bi.off) { - assert(lv["h4"] > eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else if (lv["h4"] > eN.bi.off) { - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } else { - assert(lv["h4"] == eN.bi.off); - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h0"] == eN.bi.off) { - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); - assert(lv["h4"] == eN.bi.off); - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h1"] == eN.bi.off) { - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h2"] == eN.bi.off) { - assert(lv["h3"] == eN.bi.off); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h3"] == eN.bi.off) { } if (lv["h4"] == eN.bi.off) { - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h5"] == eN.bi.off) { - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h6"] == eN.bi.off) { - assert(lv["h7"] == eN.bi.off); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ an_object[an_object_key] + ); } if (lv["h7"] == eN.bi.off) { } switch ((an_object["lev"]).to!string) { case "A": if (lv["h0"] == eN.bi.off) { - assert(lv["h1"] == eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); - assert(lv["h4"] == eN.bi.off); - assert(lv["h5"] == eN.bi.off); - assert(lv["h6"] == eN.bi.off); - assert(lv["h7"] == eN.bi.off); + assert(lv["h1"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] == eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~\n" + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level A~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h0"] > eN.bi.off) - assert(lv["h0"] == eN.bi.off,"error should not enter level A a second time"); + assert(lv["h0"] == eN.bi.off, + msg_error_doc_struct + ~ "should not enter level A a second time\n" + ~ "at level A~\n" + ~ an_object[an_object_key] + ); } break; case "B": if (lv["h1"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h2"] == eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] == eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h1"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level B~\n" + ~ an_object[an_object_key] + ); } break; case "C": if (lv["h2"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h3"] == eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "level C should not follow level A\n" + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] == eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h2"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level C~\n" + ~ an_object[an_object_key] + ); } break; case "D": if (lv["h3"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "level D should not follow level A\n" + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h3"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h1"] > eN.bi.off); - assert(lv["h2"] > eN.bi.off); - assert(lv["h3"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h1"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h2"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); + assert(lv["h3"] > eN.bi.off, + msg_error_doc_struct + ~ "at level D~\n" + ~ an_object[an_object_key] + ); } break; case "1": if (lv["h4"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h4"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 1~\n" + ~ an_object[an_object_key] + ); } break; case "2": if (lv["h5"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h5"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 2~\n" + ~ an_object[an_object_key] + ); } break; case "3": if (lv["h6"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 2~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] == eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h6"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 3~\n" + ~ an_object[an_object_key] + ); } break; case "4": if (lv["h7"] == eN.bi.off) { - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 2~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 3~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); } else { // (lv["h7"] > eN.bi.off) - assert(lv["h0"] > eN.bi.off); - assert(lv["h4"] > eN.bi.off); - assert(lv["h5"] > eN.bi.off); - assert(lv["h6"] > eN.bi.off); - assert(lv["h7"] > eN.bi.off); + assert(lv["h0"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h4"] > eN.bi.off, + msg_error_doc_struct + ~ "missing segment level 1~ ?\n" + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h5"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h6"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); + assert(lv["h7"] > eN.bi.off, + msg_error_doc_struct + ~ "at level 4~\n" + ~ an_object[an_object_key] + ); } break; default: |