From af80415a3a3e4b1717d0dbeefb1f9b97fb84b5e4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 9 Jul 2023 17:57:26 -0400 Subject: ocda, improve doc markup structure error messages - ocda, metadoc_from_src workon doc markup structure error message, check --- org/ocda.org | 608 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 499 insertions(+), 109 deletions(-) (limited to 'org/ocda.org') 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 <> } /+ ← srcDocLoop closed: loop markup document/text line by line +/ - /+ ↓ post loop markup document/text +/ - /+ ↓ post loop markup document/text +/ + /+ ↓ post loop markup document/text +/ <> <> <> @@ -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: -- cgit v1.2.3