diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2025-02-19 15:03:38 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2025-02-19 15:03:41 -0500 | 
| commit | 48fc249d6c82062b87db0dead5204d09e79edda8 (patch) | |
| tree | 5944fedd91aacaa9f0503e1a55702fcc80074b80 /org | |
| parent | org, touch, minor (diff) | |
document (metadata & abstraction) struct
- struct replaces tuple
- some direct naming of structs returned
  (instead of use of auto) - minor
Diffstat (limited to 'org')
| -rw-r--r-- | org/ocda.org | 46 | ||||
| -rw-r--r-- | org/ocda_functions.org | 4 | ||||
| -rw-r--r-- | org/output_show.org | 46 | ||||
| -rw-r--r-- | org/spine.org | 76 | 
4 files changed, 85 insertions, 87 deletions
| diff --git a/org/ocda.org b/org/ocda.org index 2e4bbb0..148edf8 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -75,7 +75,7 @@ mixin docAbstractionFunctions;  #+HEADER: :noweb yes  #+BEGIN_SRC d  <<docAbstractionInit>> -<<docAbstractionInitSubstitutions>> +<<docAbstractionInitSubstitutionsDebug>>  <<docAbstractionMainLoopSrcByLine>>  <<docAbstractionPostMainLoop>>  <<docAbstractionReturnsStruct>> @@ -109,8 +109,8 @@ scope(exit) {    anchor_tag = "";  }  mixin spineNode; -auto node_para_int_    = node_metadata_para_int; -auto node_para_str_    = node_metadata_para_str; +int[string] node_para_int_     = node_metadata_para_int; +string[string] node_para_str_  = node_metadata_para_str;  ObjGenericComposite comp_obj_;  line_occur = [    "heading"  : 0, @@ -221,7 +221,7 @@ int cnt1 = 1; int cnt2 = 1; int cnt3 = 1;  *** abstraction init substitutions -#+NAME: docAbstractionInitSubstitutions +#+NAME: docAbstractionInitSubstitutionsDebug  #+HEADER: :noweb yes  #+BEGIN_SRC d  debug (substitutions) { @@ -255,7 +255,7 @@ debug (substitutions) {  #+NAME: docAbstractionMainLoopSrcByLine  #+HEADER: :noweb yes  #+BEGIN_SRC d -auto loopMarkupSrcByLine( +_loopMarkupSrcByLineStruct loopMarkupSrcByLine(    char[][]         markup_sourcefile_content,    string[string]   an_object,    uint[string]     pith, @@ -364,7 +364,7 @@ auto loopMarkupSrcByLine(              ._doc_header_and_make_substitutions_(conf_make_meta)              ._doc_header_and_make_substitutions_fontface_(conf_make_meta);            { -            auto _get = line.txt_by_line_block_quote(an_object, pith); +            ST_txt_by_line_block_generic _get = line.txt_by_line_block_quote(an_object, pith);              {                an_object = _get.this_object;                pith      = _get.pith; @@ -377,7 +377,7 @@ auto loopMarkupSrcByLine(              ._doc_header_and_make_substitutions_fontface_(conf_make_meta)              .replaceAll(rgx.para_delimiter, mkup.br_line_spaced ~ "$1");            { -            auto _get = line.txt_by_line_block_group(an_object, pith); +            ST_txt_by_line_block_generic _get = line.txt_by_line_block_group(an_object, pith);              {                an_object = _get.this_object;                pith      = _get.pith; @@ -393,7 +393,7 @@ auto loopMarkupSrcByLine(                .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ]));            }            { -            auto _get = line.txt_by_line_block_block(an_object, pith); +            ST_txt_by_line_block_generic _get = line.txt_by_line_block_block(an_object, pith);              {                an_object = _get.this_object;                pith      = _get.pith; @@ -402,7 +402,7 @@ auto loopMarkupSrcByLine(            continue;          } else if (pith["block_is"]    == eN.blk_is.poem) {            { -            auto _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg); +            ST_txt_by_line_block_poem _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg);              {                an_object = _get.this_object;                pith      = _get.pith; @@ -436,7 +436,7 @@ auto loopMarkupSrcByLine(              object_number_poem["start"] = obj_cite_digits.object_number.to!string;            }            { -            auto _get = line.txt_by_line_block_start(pith, dochas, object_number_poem); +            ST_txt_by_line_block_start _get = line.txt_by_line_block_start(pith, dochas, object_number_poem);              {                pith               = _get.pith;                dochas             = _get.dochas; @@ -466,7 +466,7 @@ auto loopMarkupSrcByLine(            || line.matchFirst(rgx.book_index_item_open)            || pith["section"] == eN.sect.book_index)  {              { // book_index -              auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action); +              ST_flow_book_index _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action);                {                  an_object = _get.this_object;                  pith      = _get.pith; @@ -488,7 +488,7 @@ auto loopMarkupSrcByLine(                comp_obj_comment.text                   = an_object[an_object_key].strip;                the_document_body_section               ~= comp_obj_comment;                { -                auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); +                ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);                  {                    line_occur = _get.line_occur;                    an_object  = _get.this_object; @@ -505,7 +505,7 @@ auto loopMarkupSrcByLine(                && (pith["make_headings"] == eN.bi.off)) {                  // heading found                  { -                  auto _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith); +                  ST_flow_heading_found _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith);                    {                      heading_match_str = _get.heading_match_str;                      heading_match_rgx = _get.heading_match_rgx; @@ -520,7 +520,7 @@ auto loopMarkupSrcByLine(                ) {                  // heading make set                  { -                  auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); +                  ST_flow_heading_make_set _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith);                    {                      line      = _get.line;                      an_object = _get.this_object; @@ -558,7 +558,7 @@ auto loopMarkupSrcByLine(                    ._doc_header_and_make_substitutions_(conf_make_meta)                    ._doc_header_and_make_substitutions_fontface_(conf_make_meta);                  { -                  auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); +                  ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);                    {                      an_object     = _get.this_object;                      an_object_key = _get.this_object_key; @@ -587,7 +587,7 @@ auto loopMarkupSrcByLine(          } else if (pith["block_state"] == eN.blk_state.closing) {            // line empty, with blocks flag            { -            auto _get = line.flow_block_flag_line_empty_( +            ST_flow_block_flag_line_empty _get = line.flow_block_flag_line_empty_(                an_object,                bookindex_extract_hash,                the_document_body_section, @@ -703,7 +703,7 @@ auto loopMarkupSrcByLine(              _anchor_tag                   = obj_cite_digits.identifier;              // (incrementally build toc) table of contents here!              { -              auto _get = obj_im.flow_table_of_contents_gather_headings( +              ST_flow_table_of_contents_gather_headings _get = obj_im.flow_table_of_contents_gather_headings(                  an_object,                  conf_make_meta,                  tag_in_seg, @@ -724,7 +724,7 @@ auto loopMarkupSrcByLine(              if (an_object["lev_markup_number"].to!int <= 4) {                segnames["epub"] ~= tag_in_seg["seg_lv1to4"];              } -            auto comp_obj_ = node_construct.node_emitter_heading( +            ObjGenericComposite comp_obj_ = node_construct.node_emitter_heading(                  an_object,                  tag_in_seg,                  lev_anchor_tag, @@ -745,7 +745,7 @@ auto loopMarkupSrcByLine(              the_document_body_section ~= comp_obj_;              debug(objectrelated1) { writeln(line); } // check              { -              auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); +              ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);                {                  line_occur = _get.line_occur;                  an_object  = _get.this_object; @@ -766,7 +766,7 @@ auto loopMarkupSrcByLine(              an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";              bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg);              an_object["is"] = "para"; -            auto comp_obj_ = node_construct.node_location_emitter( +            ObjGenericComposite comp_obj_ = node_construct.node_location_emitter(                  content_non_header,                  tag_in_seg,                  lev_anchor_tag, @@ -798,7 +798,7 @@ auto loopMarkupSrcByLine(              the_document_body_section                       ~= comp_obj_;              tag_assoc                                           = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);              { -              auto _get = txt_by_line_common_reset_(line_occur, an_object, pith); +              ST_txt_by_line_common_reset _get = txt_by_line_common_reset_(line_occur, an_object, pith);                {                  line_occur = _get.line_occur;                  an_object  = _get.this_object; @@ -872,7 +872,7 @@ auto loopMarkupSrcByLine(    return ret;  }  { // loopMarkupSrcByLine -  auto _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith); +  _loopMarkupSrcByLineStruct _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith);    the_document_toc_section      = _doc_by_line.toc;    the_document_body_section     = _doc_by_line.body;    the_document_glossary_section = _doc_by_line.glossary; @@ -1534,7 +1534,7 @@ struct DocHas_ {      return tag_assoc;    }  } -auto doc_has() { +DocHas_ doc_has() {    return DocHas_();  }  // the doc to be returned diff --git a/org/ocda_functions.org b/org/ocda_functions.org index 120c3e3..ffbecb6 100644 --- a/org/ocda_functions.org +++ b/org/ocda_functions.org @@ -3899,7 +3899,7 @@ ST_the_section build_the_glossary_section(      }    } else { // para      { -      auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); +      ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);        {          an_object     = _get.this_object;          an_object_key = _get.this_object_key; @@ -4206,7 +4206,7 @@ ST_the_section build_the_blurb_section(Opt) (      tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;    } else if (!(line.empty)) {      { -      auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur); +      ST_flow_para_match _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);        {          an_object     = _get.this_object;          an_object_key = _get.this_object_key; diff --git a/org/output_show.org b/org/output_show.org index 607f668..6f54451 100644 --- a/org/output_show.org +++ b/org/output_show.org @@ -28,10 +28,8 @@  module sisudoc.meta.metadoc_show_summary;  @safe:  template spineMetaDocSummary() { -  void spineMetaDocSummary(S,T)( -    const S  doc_abstraction, -          T  doc_matters, -  ) { +  void spineMetaDocSummary(D)(D doc) { +    auto doc_matters = doc.matters;      <<metadoc_show_summary_imports>>      <<metadoc_show_imports_shared>>      mixin InternalMarkup; @@ -55,7 +53,7 @@ string[string] check = [    "last_object_number_book_index" : "0",  ];  foreach (k; doc_matters.has.keys_seq.seg) { -  foreach (obj; doc_abstraction[k]) { +  foreach (obj; doc.abstraction[k]) {      if (obj.metainfo.is_of_part != "empty") {        if (!empty(obj.metainfo.object_number)) {          if (k == "body") { @@ -92,9 +90,9 @@ writefln(    doc_matters.src.language,    markup.repeat_character_by_number_provided("-", char_repeat_number),    "- toc arr length:", -  to!int(doc_abstraction["toc"].length), -  "- doc_abstraction arr length:", -  to!int(doc_abstraction["body"].length), +  to!int(doc.abstraction["toc"].length), +  "- doc.abstraction arr length:", +  to!int(doc.abstraction["body"].length),    "  doc body last obj on.#:",    to!int(check["last_object_number_body"]),    "  - number of tables:", @@ -110,26 +108,26 @@ writefln(    "  - number of images:",    doc_matters.has.images,    "- endnotes length:",                                // subtract headings -  (doc_abstraction["endnotes"].length > 2) -  ? (to!int(doc_abstraction["endnotes"].length - 2)) +  (doc.abstraction["endnotes"].length > 2) +  ? (to!int(doc.abstraction["endnotes"].length - 2))    : 0,    "- glossary length:", -  (doc_abstraction["glossary"].length > 1) -  ? (to!int(doc_abstraction["glossary"].length)) +  (doc.abstraction["glossary"].length > 1) +  ? (to!int(doc.abstraction["glossary"].length))    : 0,    "- biblio length:", -  (doc_abstraction["bibliography"].length > 1) -  ? (to!int(doc_abstraction["bibliography"].length)) +  (doc.abstraction["bibliography"].length > 1) +  ? (to!int(doc.abstraction["bibliography"].length))    : 0,    "- bookindex length:", -  (doc_abstraction["bookindex"].length > 1) -  ? (to!int(doc_abstraction["bookindex"].length)) +  (doc.abstraction["bookindex"].length > 1) +  ? (to!int(doc.abstraction["bookindex"].length))    : 0,    "  book idx last obj on.#:",    to!int(check["last_object_number_book_index"]),    "- blurb length:", -  (doc_abstraction["blurb"].length > 1) -  ? (to!int(doc_abstraction["blurb"].length)) +  (doc.abstraction["blurb"].length > 1) +  ? (to!int(doc.abstraction["blurb"].length))    : 0,    "* last obj on.#:",    to!int(check["last_object_number"]), @@ -252,9 +250,7 @@ writefln(  #+HEADER: :noweb yes  #+BEGIN_SRC d  template spineShowConfig() { -  void spineShowConfig(T)( -    T  doc_matters, -  ) { +  void spineShowConfig(T)(T doc_matters) {      <<metadoc_show_summary_imports>>      <<metadoc_show_imports_shared>>      mixin InternalMarkup; @@ -348,9 +344,7 @@ writefln(  module sisudoc.meta.metadoc_show_make;  @safe:  template spineShowMake() { -  void spineShowMake(T)( -    T  doc_matters, -  ) { +  void spineShowMake(T)(T doc_matters) {      <<metadoc_show_summary_imports>>      <<metadoc_show_imports_shared>>      mixin InternalMarkup; @@ -422,9 +416,7 @@ writefln(  module sisudoc.meta.metadoc_show_metadata;  @safe:  template spineShowMetaData() { -  void spineShowMetaData(T)( -    T  doc_matters, -  ) { +  void spineShowMetaData(T)(T doc_matters) {      <<metadoc_show_summary_imports>>      <<metadoc_show_imports_shared>>      mixin InternalMarkup; diff --git a/org/spine.org b/org/spine.org index f1fc7b2..f6e7faa 100644 --- a/org/spine.org +++ b/org/spine.org @@ -1282,7 +1282,7 @@ enforce(  *** 1. _document abstraction_ [#A]  - return tuple of: -  - doc_abstraction (the document) +  - doc.abstraction (the document)    - doc_matters  #+NAME: spine_each_file_do_abstraction @@ -1292,11 +1292,10 @@ if ((_opt_action.debug_do)  ) {    writeln("--->\nstepX commence → (document abstraction) [", manifest.src.filename, "]");  } -auto t = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); -static assert(t.length==2); -auto doc_abstraction = t[dAM.abstraction]; -auto doc_matters = t[dAM.matters]; -if ((doc_matters.opt.action.debug_do) +auto doc = spineAbstraction!()(_env, program_info, _opt_action, _cfg, manifest, _make_and_meta_struct); +auto doc_abstraction = doc.abstraction; +auto doc_matters = doc.matters; +if ((doc.matters.opt.action.debug_do)    || (_opt_action.debug_do_stages)  ) {    writeln("- stepX complete for [", manifest.src.filename, "]"); @@ -1323,9 +1322,9 @@ if ((doc_matters.opt.action.debug_do)  #+NAME: spine_each_file_do_debugs_checkdoc_0  #+BEGIN_SRC d  /+ ↓ debugs +/ -if (doc_matters.opt.action.show_summary) { +if (doc.matters.opt.action.show_summary) {    import sisudoc.meta.metadoc_show_summary; -  spineMetaDocSummary!()(doc_abstraction, doc_matters); +  spineMetaDocSummary!()(doc);  }  #+END_SRC @@ -1335,9 +1334,9 @@ if (doc_matters.opt.action.show_summary) {  #+NAME: spine_each_file_do_debugs_checkdoc_1  #+BEGIN_SRC d  /+ ↓ debugs +/ -if (doc_matters.opt.action.show_metadata) { +if (doc.matters.opt.action.show_metadata) {    import sisudoc.meta.metadoc_show_metadata; -  spineShowMetaData!()(doc_matters); +  spineShowMetaData!()(doc.matters);  }  #+END_SRC @@ -1347,9 +1346,9 @@ if (doc_matters.opt.action.show_metadata) {  #+NAME: spine_each_file_do_debugs_checkdoc_2  #+BEGIN_SRC d  /+ ↓ debugs +/ -if (doc_matters.opt.action.show_make) { +if (doc.matters.opt.action.show_make) {    import sisudoc.meta.metadoc_show_make; -  spineShowMake!()(doc_matters); +  spineShowMake!()(doc.matters);  }  #+END_SRC @@ -1359,9 +1358,9 @@ if (doc_matters.opt.action.show_make) {  #+NAME: spine_each_file_do_debugs_checkdoc_3  #+BEGIN_SRC d  /+ ↓ debugs +/ -if (doc_matters.opt.action.show_config) { +if (doc.matters.opt.action.show_config) {    import sisudoc.meta.metadoc_show_config; -  spineShowConfig!()(doc_matters); +  spineShowConfig!()(doc.matters);  }  #+END_SRC @@ -1370,17 +1369,17 @@ if (doc_matters.opt.action.show_config) {  #+NAME: spine_each_file_do_debugs_checkdoc_4  #+BEGIN_SRC d -if (doc_matters.opt.action.curate) { -  auto _hvst = spineMetaDocCurate!()(doc_matters, hvst); +if (doc.matters.opt.action.curate) { +  auto _hvst = spineMetaDocCurate!()(doc.matters, hvst);    if (      _hvst.title.length > 0      && _hvst.author_surname_fn.length > 0    ) {      hvst.curates ~= _hvst;    } else { -    if ((doc_matters.opt.action.debug_do) +    if ((doc.matters.opt.action.debug_do)        || (_opt_action.debug_do_curate) -      || (doc_matters.opt.action.vox_gt2) +      || (doc.matters.opt.action.vox_gt2)      ) {        writeln("WARNING curate: document header yaml does not contain information related to: title or author: ", _hvst.path_html_segtoc);      } @@ -1394,8 +1393,8 @@ if (doc_matters.opt.action.curate) {  #+NAME: spine_each_file_do_debugs_checkdoc_5  #+BEGIN_SRC d  /+ ↓ debugs +/ -if (doc_matters.opt.action.debug_do) { -  spineDebugs!()(doc_abstraction, doc_matters); +if (doc.matters.opt.action.debug_do) { +  spineDebugs!()(doc.abstraction, doc.matters);  }  #+END_SRC @@ -1413,16 +1412,12 @@ if (!(_opt_action.skip_output)) {  #+NAME: spine_each_file_do_selected_output  #+BEGIN_SRC d  /+ ↓ output hub +/ -if (!(doc_matters.opt.action.skip_output)) { -  if ((_opt_action.debug_do) -    || (_opt_action.debug_do_stages) -  ) { +if (!(doc.matters.opt.action.skip_output)) { +  if ((_opt_action.debug_do) || (_opt_action.debug_do_stages)) {      writeln("step5 commence → (process outputs) [", manifest.src.filename, "]");    } -  doc_abstraction.outputHub!()(doc_matters); -  if ((_opt_action.debug_do) -    || (_opt_action.debug_do_stages) -  ) { +  doc.abstraction.outputHub!()(doc.matters); +  if ((_opt_action.debug_do) || (_opt_action.debug_do_stages)) {      writeln("- step5 complete for [", manifest.src.filename, "]");    }  } @@ -1489,8 +1484,19 @@ template spineAbstraction() {      }      auto doc_matters = ST_DocumentMatters();      <<spine_each_file_do_document_matters_msg_step4_end>> -    auto t = tuple(doc_abstraction, doc_matters); -    return t; +    auto theDOC() { +      struct ST_DOC { +        const auto abstraction() { +          return doc_abstraction; +        } +        auto matters() { +          return doc_matters; +        } +      } +      return ST_DOC(); +    } +    auto the_doc = theDOC(); +    return the_doc;    }  }  #+END_SRC @@ -1589,12 +1595,12 @@ if ((_opt_action.debug_do)  - prepare the document abstraction used in downstream processing  - _return tuple of_: -  - document abstraction (_the_document_ or doc_abstraction) +  - document abstraction (_the_document_ or doc.abstraction)    - document abstraction keys      - (head, toc, body, endnotes, glossary, bibliography, bookindex, blurb, tail) -    - (transfer to _doc_matters_) -  - segnames for html epub (transfer to _doc_matters_) -  - image list (transfer to _doc_matters_) +    - (transfer to _doc.matters_) +  - segnames for html epub (transfer to _doc.matters_) +  - image list (transfer to _doc.matters_)  #+NAME: spine_each_file_do_document_abstraction  #+BEGIN_SRC d @@ -1632,7 +1638,7 @@ if ((_opt_action.debug_do)  if ((_opt_action.debug_do)    || (_opt_action.debug_do_stages)  ) { -  writeln("step4 commence → (doc_matters) [", _manifest.src.filename, "]"); +  writeln("step4 commence → (doc.matters) [", _manifest.src.filename, "]");  }  #+END_SRC | 
