From 10ec5e96d65b58dbe915c2d622b0bfb8abbd122b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 21 Dec 2019 11:38:05 -0500 Subject: reduce use of auto, much with tuples --- src/doc_reform/meta/conf_make_meta_structs.d | 2 +- src/doc_reform/meta/defaults.d | 2 +- src/doc_reform/meta/metadoc_from_src.d | 80 ++++++++++++++++---------- src/doc_reform/meta/metadoc_harvest.d | 2 +- src/doc_reform/meta/metadoc_harvests_authors.d | 2 +- src/doc_reform/meta/metadoc_harvests_topics.d | 2 +- 6 files changed, 56 insertions(+), 34 deletions(-) (limited to 'src/doc_reform/meta') diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d index c1d6f2c..121605a 100644 --- a/src/doc_reform/meta/conf_make_meta_structs.d +++ b/src/doc_reform/meta/conf_make_meta_structs.d @@ -15,7 +15,7 @@ import mixin spineRgxInit; static auto rgx = Rgx(); mixin InternalMarkup; -auto mkup = InlineMarkup(); +static auto mkup = InlineMarkup(); string url_markup(string line) @safe { string line_ = line .replaceAll( diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d index b3f6bba..0b6388b 100644 --- a/src/doc_reform/meta/defaults.d +++ b/src/doc_reform/meta/defaults.d @@ -188,7 +188,7 @@ template InternalMarkup() { string tc_p = "┆"; string img = "☼"; string sep = "␣"; - string on_o = "「"; auto on_c = "」"; + string on_o = "「"; string on_c = "」"; string mk_bullet = "● "; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index d37e029..6dbbb22 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -89,6 +89,28 @@ template docAbstraction() { int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + alias TxtPlusHasFootnotes = Tuple!( + string, "obj_txt", + bool, "has_notes_reg", + bool, "has_notes_star", + bool, "has_notes_plus", + ); + alias TxtPlusHasFootnotesUrlsImages = Tuple!( + string, "obj_txt", + bool, "has_notes_reg", + bool, "has_notes_star", + bool, "has_notes_plus", + bool, "has_urls", + bool, "has_images_without_dimensions", + ); + alias TxtAndAnchorTagPlusHasFootnotesUrlsImages = Tuple!( + string, "obj_txt", + string, "anchor_tag", + bool, "has_notes_reg", + bool, "has_notes_star", + bool, "has_links", + bool, "has_images_without_dimensions", + ); enum DomTags { none, open, close, close_and_open, open_still, } pure ObjGenericComposite obj_heading_ancestors()( ObjGenericComposite obj, @@ -957,7 +979,7 @@ template docAbstraction() { : ocn_emit(obj_type_status["ocn_status"]); an_object["is"] = "heading"; an_object_key="body_nugget"; - auto substantive_object_and_anchor_tags_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_object_and_anchor_tags_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, ((_new_doc) ? Yes._new_doc : No._new_doc)); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[sObj.content]; anchor_tag = substantive_object_and_anchor_tags_tuple[sObj.anchor_tag]; @@ -1096,7 +1118,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"], ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -2855,7 +2877,7 @@ template docAbstraction() { ); } an_object["is"] = "verse"; - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -2918,7 +2940,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -2964,7 +2986,7 @@ template docAbstraction() { } processing.remove("verse"); an_object["is"] = "verse"; - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -3027,7 +3049,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -3329,7 +3351,7 @@ template docAbstraction() { "table" ); an_object["is"] = "table"; - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; @@ -3393,7 +3415,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -3444,7 +3466,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -3495,7 +3517,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; // anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -3582,7 +3604,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; @@ -3634,7 +3656,7 @@ template docAbstraction() { heading_ptr-1, an_object["is"] ); - auto substantive_obj_misc_tuple + TxtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; comp_obj_block = comp_obj_block.init; @@ -4347,7 +4369,7 @@ template docAbstraction() { } return obj_txt_in; } - Tuple!(string, bool, bool, bool) footnotes_endnotes_markup_and_number_or_stars()(string obj_txt_in, bool reset_note_numbers) @safe { + TxtPlusHasFootnotes footnotes_endnotes_markup_and_number_or_stars()(string obj_txt_in, bool reset_note_numbers) @safe { /+ endnotes (regular) +/ bool flg_notes_reg = false; bool flg_notes_star = false; @@ -4403,7 +4425,7 @@ template docAbstraction() { } else { obj_txt_out = obj_txt_in; } - Tuple!(string, bool, bool, bool) t = tuple( + TxtPlusHasFootnotes t = tuple( obj_txt_out, flg_notes_reg, flg_notes_star, @@ -4411,7 +4433,7 @@ template docAbstraction() { ); return t; } - private Tuple!(string, bool, bool, bool, bool, bool) object_notes_and_links_()( + private TxtPlusHasFootnotesUrlsImages object_notes_and_links_()( string obj_txt_in, bool reset_note_numbers=false ) @safe { @@ -4445,8 +4467,8 @@ template docAbstraction() { obj_txt_in = obj_txt_in .replaceAll(rgx.para_inline_link_anchor, "┃$1┃"); } - Tuple!(string, bool, bool, bool) ftn = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in, reset_note_numbers); - obj_txt_out = ftn[0]; + TxtPlusHasFootnotes ftn = footnotes_endnotes_markup_and_number_or_stars(obj_txt_in, reset_note_numbers); + obj_txt_out = ftn.obj_txt; debug(footnotes) { writeln(obj_txt_out, tail); } @@ -4458,18 +4480,18 @@ template docAbstraction() { writeln(m.hit); } } - Tuple!(string, bool, bool, bool, bool, bool) t = tuple( + TxtPlusHasFootnotesUrlsImages t = tuple( obj_txt_out, - ftn[1], - ftn[2], - ftn[3], + ftn.has_notes_reg, + ftn.has_notes_star, + ftn.has_notes_plus, urls, images_without_dimensions, ); return t; } auto init() { - Tuple!(string, bool, bool, bool, bool, bool) t = object_notes_and_links_(""); + TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(""); return t; } invariant() { @@ -4482,7 +4504,7 @@ template docAbstraction() { .replaceFirst(rgx.heading, "") .replaceFirst(rgx.object_number_off_all, "") .strip; - Tuple!(string, bool, bool, bool, bool, bool) t = object_notes_and_links_(obj_txt["munge"], reset_note_numbers); + TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"], reset_note_numbers); debug(munge) { writeln(__LINE__); writeln(obj_txt_in); @@ -4497,7 +4519,7 @@ template docAbstraction() { obj_txt["munge"]=(obj_txt_in) .replaceFirst(rgx.para_attribs, "") .replaceFirst(rgx.object_number_off_all, ""); - Tuple!(string, bool, bool, bool, bool, bool) t = object_notes_and_links_(obj_txt["munge"]); + TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); debug(munge) { writeln(__LINE__); writeln(obj_txt_in); @@ -4514,21 +4536,21 @@ template docAbstraction() { } auto munge_group(string obj_txt_in) @safe { obj_txt["munge"]=obj_txt_in; - Tuple!(string, bool, bool, bool, bool, bool) t = object_notes_and_links_(obj_txt["munge"]); + TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); return t; } invariant() { } auto munge_block()(string obj_txt_in) @safe { obj_txt["munge"]=obj_txt_in; - Tuple!(string, bool, bool, bool, bool, bool) t = object_notes_and_links_(obj_txt["munge"]); + TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); return t; } invariant() { } auto munge_verse()(string obj_txt_in) @safe { obj_txt["munge"]=obj_txt_in; - Tuple!(string, bool, bool, bool, bool, bool) t = object_notes_and_links_(obj_txt["munge"]); + TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); return t; } invariant() { @@ -4558,7 +4580,7 @@ template docAbstraction() { static auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; static string anchor_tag = ""; - auto obj_inline_markup_and_anchor_tags_and_misc(CMM)( + TxtAndAnchorTagPlusHasFootnotesUrlsImages obj_inline_markup_and_anchor_tags_and_misc(CMM)( string[string] obj_, string obj_key_, CMM conf_make_meta, @@ -4638,7 +4660,7 @@ template docAbstraction() { obj_notes_and_links["image_no_dimensions"] = x[5]; break; } - Tuple!(string, string, bool, bool, bool, bool) t = tuple( + TxtAndAnchorTagPlusHasFootnotesUrlsImages t = tuple( obj_txt["munge"], anchor_tag, obj_notes_and_links["notes_reg"], diff --git a/src/doc_reform/meta/metadoc_harvest.d b/src/doc_reform/meta/metadoc_harvest.d index 4bb62ae..eb050e4 100644 --- a/src/doc_reform/meta/metadoc_harvest.d +++ b/src/doc_reform/meta/metadoc_harvest.d @@ -18,7 +18,7 @@ template spineMetaDocHarvest() { std.utf, std.conv : to; mixin InternalMarkup; - auto markup = InlineMarkup(); + static auto mkup = InlineMarkup(); import doc_reform.io_out.paths_output; auto pth_html_abs = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); auto pth_html_rel = spineDocRootTreeHTML!()(doc_matters.src.language); diff --git a/src/doc_reform/meta/metadoc_harvests_authors.d b/src/doc_reform/meta/metadoc_harvests_authors.d index 19ed583..3a7aebc 100644 --- a/src/doc_reform/meta/metadoc_harvests_authors.d +++ b/src/doc_reform/meta/metadoc_harvests_authors.d @@ -14,7 +14,7 @@ module doc_reform.meta.metadoc_harvests_authors; mixin InternalMarkup; mixin spineRgxInit; template spineMetaDocHarvestsAuthors() { - auto mkup = InlineMarkup(); + static auto mkup = InlineMarkup(); void spineMetaDocHarvestsAuthors(H,M,O)( H harvests, M _make_and_meta_struct, diff --git a/src/doc_reform/meta/metadoc_harvests_topics.d b/src/doc_reform/meta/metadoc_harvests_topics.d index 5e11b7e..8c41f3b 100644 --- a/src/doc_reform/meta/metadoc_harvests_topics.d +++ b/src/doc_reform/meta/metadoc_harvests_topics.d @@ -14,7 +14,7 @@ module doc_reform.meta.metadoc_harvests_topics; mixin InternalMarkup; mixin spineRgxInit; template spineMetaDocHarvestsTopics() { - auto mkup = InlineMarkup(); + static auto mkup = InlineMarkup(); void spineMetaDocHarvestsTopics(H,M,O)( H hvst, M _make_and_meta_struct, -- cgit v1.2.3