diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sdp/ao_abstract_doc_source.d | 75 | ||||
-rw-r--r-- | lib/sdp/ao_object_setter.d | 138 | ||||
-rw-r--r-- | lib/sdp/ao_output_debugs.d | 60 |
3 files changed, 145 insertions, 128 deletions
diff --git a/lib/sdp/ao_abstract_doc_source.d b/lib/sdp/ao_abstract_doc_source.d index 74d1baa..00cff5c 100644 --- a/lib/sdp/ao_abstract_doc_source.d +++ b/lib/sdp/ao_abstract_doc_source.d @@ -25,7 +25,8 @@ template SiSUdocAbstraction() { /+ initialize +/ auto rgx = Rgx(); - string[string][] contents_the_objects; + ObjComposite[] contents_the_objects; + string[string] an_object, processing; auto set_abstract_object = ObjectAbstractSet(); auto set_header = HeaderDocMetadataMakeJson(); @@ -212,7 +213,8 @@ template SiSUdocAbstraction() { } scope(failure) { stderr.writefln( - "%s:%s failed here:\n line: %s", + "%s\n%s\n%s:%s failed here:\n line: %s", + __MODULE__, __FUNCTION__, __FILE__, __LINE__, line, ); @@ -458,12 +460,11 @@ template SiSUdocAbstraction() { ++heading_pointer; contents_the_objects ~= set_abstract_object.contents_heading( - type["obj_cite_number_status"], an_object["substantive"], an_object["attrib"], - obj_cite_number, an_object["lev"], - an_object["lev_markup_number"], - an_object["lev_collapsed_number"] + obj_cite_number, + to!int(an_object["lev_markup_number"]), + to!int(an_object["lev_collapsed_number"]) ); // track previous heading and make assertions debug(objectrelated1) { // check @@ -534,10 +535,10 @@ template SiSUdocAbstraction() { } // close else for line empty } // close else for not the above } // close after non code, other blocks or regular text - if (((contents_the_objects[$-1]["is"] == "para") - || (contents_the_objects[$-1]["is"] == "heading")) + if (((contents_the_objects[$-1].is_a == "para") + || (contents_the_objects[$-1].is_a == "heading")) && (counter-1 > previous_count)) { - if (match(contents_the_objects[$-1]["obj"], + if (match(contents_the_objects[$-1].object, rgx.inline_notes_delimiter_al_regular_number_note)) { // endnotes/ footnotes for // doc objects other than paragraphs & headings @@ -1408,7 +1409,7 @@ template SiSUdocAbstraction() { auto block_flag_line_empty( char[] line, ref string[string] an_object, - ref string[string][] contents_the_objects, + ref ObjComposite[] contents_the_objects, ref string[][string][string] bookindex_unordered_hashes, ref int obj_cite_number, ref string node, @@ -2948,7 +2949,6 @@ template SiSUdocAbstraction() { } } struct BookIndexReportSection { - mixin ObjectSetter; int mkn, skn; auto rgx = Rgx(); auto bookindex_write_section( @@ -2982,7 +2982,6 @@ template SiSUdocAbstraction() { int obj_cite_number ) { string type; - int type_heading; string lev, lev_markup_number, lev_collapsed_number; string attrib; string[string] indent; @@ -2990,43 +2989,35 @@ template SiSUdocAbstraction() { auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; string bi_tmp; - string[string][] bookindex_section; + ObjComposite[] bookindex_section; // writeln(mainkeys.length); // B~ Book Index - type_heading=1; - bi_tmp = "Book Index"; attrib=""; lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; bookindex_section ~= set_abstract_object.contents_heading( - type_heading, - bi_tmp, + "Book Index", attrib, obj_cite_number, - lev, - lev_markup_number, - lev_collapsed_number + to!int(lev_markup_number), + to!int(lev_collapsed_number) ); ++obj_cite_number; ++mkn; // 1~ Index - type_heading=1; - bi_tmp = "Index"; attrib=""; lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; bookindex_section ~= set_abstract_object.contents_heading( - type_heading, - bi_tmp, + "Index", attrib, obj_cite_number, - lev, - lev_markup_number, - lev_collapsed_number + to!int(lev_markup_number), + to!int(lev_collapsed_number) ); ++obj_cite_number; ++mkn; @@ -3115,31 +3106,30 @@ template SiSUdocAbstraction() { } } struct NotesSection { - mixin ObjectSetter; string object_notes; long previous_count; int mkn; auto rgx = Rgx(); private auto gather_notes_for_endnote_section( - string[string][] contents_am, - long counter + ObjComposite[] contents_am, + ulong counter ) in { // endnotes/ footnotes for // doc objects other than paragraphs & headings // various forms of grouped text - assert((contents_am[counter]["is"] == "para") - || (contents_am[counter]["is"] == "heading")); + assert((contents_am[counter].is_a == "para") + || (contents_am[counter].is_a == "heading")); assert(counter > previous_count); previous_count=counter; assert( - match(contents_am[counter]["obj"], + match(contents_am[counter].object, rgx.inline_notes_delimiter_al_regular_number_note) ); } body { foreach(m; - matchAll(contents_am[counter]["obj"], + matchAll(contents_am[counter].object, rgx.inline_notes_delimiter_al_regular_number_note)) { debug(endnotes_build) { writeln( @@ -3168,47 +3158,40 @@ template SiSUdocAbstraction() { } body { auto set_abstract_object = ObjectAbstractSet(); - string[string][] endnotes_section; + ObjComposite[] endnotes_section; auto endnotes_ = gathered_notes(); // auto endnotes_ = (split(object_notes, rgx.break_string))[0..$-1]; string type; - int type_heading; string lev, lev_markup_number, lev_collapsed_number; string attrib; string[string] indent; // B~ Endnotes - type_heading=1; attrib=""; lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; endnotes_section ~= set_abstract_object.contents_heading( - type_heading, "Endnotes", attrib, obj_cite_number, - lev, - lev_markup_number, - lev_collapsed_number + to!int(lev_markup_number), + to!int(lev_collapsed_number) ); ++obj_cite_number; ++mkn; // 1~ Endnotes - type_heading=1; attrib=""; lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; endnotes_section ~= set_abstract_object.contents_heading( - type_heading, "Endnotes", attrib, obj_cite_number, - lev, - lev_markup_number, - lev_collapsed_number + to!int(lev_markup_number), + to!int(lev_collapsed_number) ); ++obj_cite_number; ++mkn; diff --git a/lib/sdp/ao_object_setter.d b/lib/sdp/ao_object_setter.d index a44aeb0..4492e8a 100644 --- a/lib/sdp/ao_object_setter.d +++ b/lib/sdp/ao_object_setter.d @@ -3,42 +3,74 @@ ao_object_setter.d +/ template ObjectSetter() { + /+ structs +/ + struct HeadingAttrib { + int lev = 9; // use of enum should make this redundant, remove + int lev_markup_number = 9; + int lev_collapsed_number = 9; + } + struct ParaAttrib { + int indent_first = 0; + int indent_second = 0; + bool bullet = false; + } + struct BlockAttrib { + } + struct Comment { + // no .attrib and no .obj_cite_number + } + struct Node { + int ocn = 0; + int parent_lev = 0; + int parent_ocn = 0; + string node = ""; + } + struct ObjComposite { + // size_t id; + string use = ""; + string of = ""; + string is_a = ""; + string object = ""; + string obj_cite_number = ""; // not used for calculations? output only? else int + HeadingAttrib heading_attrib; + ParaAttrib para_attrib; + BlockAttrib block_attrib; + Node node_structure; + } + struct ObjCompositeArr { + ObjComposite[] oca; + } + + /+ structs setter +/ struct ObjectAbstractSet { import std.conv : to; - string[string] contents_comment(in string object) { - string[string] object_set; - object_set["use"] = "comment"; - object_set["of"] = "comment"; - object_set["is"] = "comment"; - object_set["obj"] = object; - // object_set["attrib"] = attrib; + auto contents_comment(in string object) { + ObjComposite object_set; + object_set.use = "comment"; + object_set.of = "comment"; + object_set.is_a = "comment"; + object_set.object = object; return object_set; } - string[string] contents_heading( - in int type, + auto contents_heading( in string object, in string attrib, in int obj_cite_number, - in string lev, - in string lev_markup_number, - in string lev_collapsed_number, + in int lev_markup_number, + in int lev_collapsed_number, ) { - string[string] object_set; - object_set["use"] = "content"; - object_set["of"] = "para"; - object_set["is"] = "heading"; - object_set["type"] = to!string(type); - // object_set["is"] = type; // "heading" "heading_dummy" - object_set["obj"] = object; - object_set["obj_cite_number"] = (obj_cite_number==0) ? "" : to!string(obj_cite_number); - object_set["lev"] = to!string(lev); - object_set["lev_markup_number"] = to!string(lev_markup_number); - object_set["lev_collapsed_number"] = to!string(lev_collapsed_number); - object_set["attrib"] = attrib; - // object_set["children"] = children; + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "para"; + object_set.is_a = "heading"; + object_set.object = object; + object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + object_set.heading_attrib.lev_markup_number = lev_markup_number; + object_set.heading_attrib.lev_collapsed_number = lev_collapsed_number; + // object_set.node_structure.node = node; return object_set; } - string[string] contents_para( + auto contents_para( in string is_a, in string object, in string attrib, @@ -46,48 +78,46 @@ template ObjectSetter() { in string[string] indent, in bool bullet ) { - string[string] object_set; - object_set["use"] = "content"; - object_set["of"] = "para"; - object_set["is"] = is_a; - // object_set["status"] = status; - object_set["obj"] = object; - object_set["obj_cite_number"] = (obj_cite_number==0) ? "" : to!string(obj_cite_number); - object_set["indent_first"] = indent["first"]; - object_set["indent_second"] = indent["second"]; - object_set["bullet"] = to!string(bullet); - object_set["attrib"] = attrib; + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "para"; + object_set.is_a = "para"; + object_set.object = object; + object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + object_set.para_attrib.indent_first = 0; // indent["first"]; + object_set.para_attrib.indent_second = 0; // indent["second"]; + object_set.para_attrib.bullet = false; + // object_set.node_structure.node = node; return object_set; } - string[string] contents_block( + auto contents_block( in string type, in string object, in string attrib, in int obj_cite_number ) { - string[string] object_set; - object_set["use"] = "content"; - object_set["of"] = "block"; - object_set["is"] = type; - object_set["obj"] = object; - object_set["obj_cite_number"] = (obj_cite_number==0) ? "" : to!string(obj_cite_number); - object_set["attrib"] = attrib; + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "block"; + object_set.is_a = type; + object_set.object = object; + object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + // object_set.node_structure.node = node; return object_set; } - string[string] contents_block_obj_cite_number_string( + auto contents_block_obj_cite_number_string( in string type, in string object, in string obj_cite_number, in string node ) { - string[string] object_set; - object_set["use"] = "content"; - object_set["of"] = "block"; - object_set["is"] = type; - object_set["obj"] = object; - object_set["obj_cite_number"] = obj_cite_number; - object_set["node"] = node; - // object_set["attrib"] = ""; + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "block"; + object_set.is_a = type; + object_set.object = object; + object_set.obj_cite_number = obj_cite_number; + object_set.node_structure.node = node; return object_set; } } diff --git a/lib/sdp/ao_output_debugs.d b/lib/sdp/ao_output_debugs.d index 020474e..9c66312 100644 --- a/lib/sdp/ao_output_debugs.d +++ b/lib/sdp/ao_output_debugs.d @@ -4,14 +4,18 @@ +/ template SiSUoutputDebugs() { struct SDPoutputDebugs { - auto abstract_doc_source_debugs( - string[string][] contents, - JSONValue[string] docmake, - JSONValue[string] dochead, + auto tst_debugs(S)(auto ref const S s) { + mixin RgxInit; + mixin ScreenTxtColors; + auto rgx = Rgx(); + } + auto abstract_doc_source_debugs(S)(auto ref const S contents, + JSONValue[string] docmake, + JSONValue[string] dochead, string[][string][string] bookindex_unordered_hashes, - JSONValue[] biblio, - string fn_src, - bool[string] opt_action_bool + JSONValue[] biblio, + string fn_src, + bool[string] opt_action_bool ) { mixin RgxInit; mixin ScreenTxtColors; @@ -23,15 +27,15 @@ template SiSUoutputDebugs() { __LINE__, ); foreach (obj; contents) { - if (obj["use"] == "content") { - if (obj["is"] == "heading") { + if (obj.use == "content") { + if (obj.is_a == "heading") { writefln( "%s%s node: %s heading: %s %s", scr_txt_marker["cyan"], - obj["obj_cite_number"], - obj["node"], - obj["lev_markup_number"], - obj["obj"], + obj.obj_cite_number, + obj.node, + obj.lev_markup_number, + obj.object, ); } else { } @@ -46,12 +50,12 @@ template SiSUoutputDebugs() { __LINE__, ); foreach (obj; contents) { - if (obj["use"] == "content") { + if (obj.use == "content") { writefln( "[%s][%s]\n%s", - obj["obj_cite_number"], - obj["is"], - obj["obj"] + obj.obj_cite_number, + obj.is_a, + obj.object ); } } @@ -64,14 +68,14 @@ template SiSUoutputDebugs() { __LINE__, ); foreach (obj; contents) { - if (obj["use"] == "content") { + if (obj.use == "content") { writefln( "%s* [%s][%s] %s%s", scr_txt_color["green"], - obj["obj_cite_number"], - obj["is"], + obj.obj_cite_number, + obj.is_a, scr_txt_color["off"], - obj["obj"] + obj.object ); } } @@ -240,9 +244,9 @@ template SiSUoutputDebugs() { ]; debug(checkdoc) { foreach (obj; contents) { - if (obj["use"] == "content") { - if (!empty(obj["obj_cite_number"])) { - check["last_obj_cite_number"] = obj["obj_cite_number"]; + if (obj.use == "content") { + if (!empty(obj.obj_cite_number)) { + check["last_obj_cite_number"] = obj.obj_cite_number; } } } @@ -255,14 +259,14 @@ template SiSUoutputDebugs() { __LINE__, ); foreach (obj; contents) { - if (obj["is"] == "heading") { + if (obj.is_a == "heading") { writefln( "%s%s~ [%s] %s", scr_txt_marker["yellow"], - obj["lev"], - obj["obj_cite_number"], + obj.heading_attrib.lev, + obj.obj_cite_number, // "[", obj["is"], "] ", - obj["obj"] + obj.object ); } } |