diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-01-27 15:57:55 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | bdeee0ea38b48d4fc5c4bb7411a584a9af29382f (patch) | |
tree | 5b5b159e01ddd9ae781d9493a3421dd8426b7c7f /org | |
parent | debugs template (diff) |
document abstraction template
Diffstat (limited to 'org')
-rw-r--r-- | org/ao_abstract_doc_source.org | 269 | ||||
-rw-r--r-- | org/ao_defaults.org | 63 | ||||
-rw-r--r-- | org/sdp.org | 4 |
3 files changed, 191 insertions, 145 deletions
diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index a2673fa..6fd6718 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -23,114 +23,113 @@ ao_abstract_doc_source.d +/ template SiSUdocAbstraction() { - private: - struct SiSUdocAbstraction { - /+ ↓ abstraction imports +/ - <<abs_imports>> - /+ ↓ abstraction mixins +/ - <<abs_mixins>> - /+ ↓ abstraction struct init +/ - <<abs_init_struct>> - /+ ↓ abstract marked up document +/ - auto SiSUdocAbstraction(Src,Make,Meta,Opt)( - Src markup_sourcefile_content, - Make dochead_make_aa, - Meta dochead_meta_aa, - Opt opt_action_bool, - ) { - debug(asserts){ - static assert(is(typeof(markup_sourcefile_content) == char[][])); - static assert(is(typeof(dochead_make_aa) == string[string][string])); - static assert(is(typeof(dochead_meta_aa) == string[string][string])); - static assert(is(typeof(opt_action_bool) == bool[string])); - } - /+ ↓ abstraction init +/ - <<abs_init_rest>> - /+ abstraction init ↑ +/ - /+ ↓ loop markup document/text line by line +/ - srcDocLoop: - foreach (line; markup_sourcefile_content) { - /+ ↓ markup document/text line by line +/ - <<abs_in_loop_body_00>> - if (type["code"] == TriState.on) { - <<abs_in_loop_body_00_code_block>> - } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { - /+ object other than "code block" object - (includes regular text paragraph, headings & blocks other than code) +/ - <<abs_in_loop_body_non_code_obj>> + /+ ↓ abstraction imports +/ + <<abs_imports>> + /+ ↓ abstraction mixins +/ + <<abs_mixins>> + /+ ↓ abstraction struct init +/ + <<abs_init_struct>> + /+ ↓ abstract marked up document +/ + auto SiSUdocAbstraction(Src,Make,Meta,Opt)( + Src markup_sourcefile_content, + Make dochead_make_aa, + Meta dochead_meta_aa, + Opt opt_action_bool, + ) { + auto rgx = Rgx(); + debug(asserts){ + static assert(is(typeof(markup_sourcefile_content) == char[][])); + static assert(is(typeof(dochead_make_aa) == string[string][string])); + static assert(is(typeof(dochead_meta_aa) == string[string][string])); + static assert(is(typeof(opt_action_bool) == bool[string])); + } + /+ ↓ abstraction init +/ + <<abs_init_rest>> + /+ abstraction init ↑ +/ + /+ ↓ loop markup document/text line by line +/ + srcDocLoop: + foreach (line; markup_sourcefile_content) { + /+ ↓ markup document/text line by line +/ + <<abs_in_loop_body_00>> + if (type["code"] == TriState.on) { + <<abs_in_loop_body_00_code_block>> + } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { + /+ object other than "code block" object + (includes regular text paragraph, headings & blocks other than code) +/ + <<abs_in_loop_body_non_code_obj>> + } else { + /+ not within a block group +/ + <<abs_in_loop_body_open_block_obj_assert>> + if (matchFirst(line, rgx.block_open)) { + <<abs_in_loop_body_open_block_obj>> + } else if (!line.empty) { + /+ line not empty +/ + /+ non blocks (headings, paragraphs) & closed blocks +/ + <<abs_in_loop_body_not_block_obj>> + } else if (type["blocks"] == TriState.closing) { + /+ line empty, with blocks flag +/ + <<abs_in_loop_body_not_block_obj_line_empty_blocks_flags>> } else { - /+ not within a block group +/ - <<abs_in_loop_body_open_block_obj_assert>> - if (matchFirst(line, rgx.block_open)) { - <<abs_in_loop_body_open_block_obj>> - } else if (!line.empty) { - /+ line not empty +/ - /+ non blocks (headings, paragraphs) & closed blocks +/ - <<abs_in_loop_body_not_block_obj>> - } else if (type["blocks"] == TriState.closing) { - /+ line empty, with blocks flag +/ - <<abs_in_loop_body_not_block_obj_line_empty_blocks_flags>> - } else { - /+ line.empty, post contents, empty variables: +/ - <<abs_in_loop_body_not_block_obj_line_empty>> - } // close else for line empty - } // close else for not the above - } // close after non code, other blocks or regular text - <<abs_in_loop_body_01>> - } /+ ← closed: loop markup document/text line by line +/ - /+ ↓ post loop markup document/text +/ - <<abs_post>> - /+ post loop markup document/text ↑ +/ - } /+ ← closed: abstract doc source +/ - /+ ↓ abstraction functions +/ - <<abs_functions_object_reset>> - <<abs_functions_header_set_common>> - <<abs_functions_ocn_status>> - <<abs_functions_block>> - <<abs_functions_block_code>> - <<abs_functions_block_biblio>> - <<abs_functions_block_poem>> - <<abs_functions_block_group>> - <<abs_functions_block_block>> - <<abs_functions_block_quote>> - <<abs_functions_block_table>> - <<abs_functions_block_line_status_empty>> - <<abs_functions_book_index>> - <<abs_functions_heading>> - <<abs_functions_para>> - /+ abstraction functions ↑ +/ - /+ ↓ abstraction function emitters +/ - <<ao_emitters_ocn>> - /+ +/ - <<ao_emitters_obj_inline_markup_munge>> - <<ao_emitters_obj_inline_markup>> - <<ao_emitters_obj_inline_markup_and_anchor_tags>> - <<ao_emitters_obj_inline_markup_table_of_contents>> - <<ao_emitters_obj_inline_markup_private>> - <<ao_emitters_obj_inline_markup_heading_numbering_segment_anchor_tags>> - <<ao_emitters_obj_inline_markup_close>> - /+ +/ - <<ao_emitters_obj_attributes>> - <<ao_emitters_obj_attributes_public>> - <<ao_emitters_obj_attributes_private>> - <<ao_emitters_obj_attributes_private_an_attribute>> - <<ao_emitters_obj_attributes_private_json>> - <<ao_emitters_obj_attributes_private_close>> - /+ +/ - <<ao_emitters_book_index_nugget>> - <<ao_emitters_book_index_report_indented>> - <<ao_emitters_book_index_report_section>> - /+ +/ - <<ao_emitters_endnotes>> - /+ +/ - <<ao_emitters_bibliography>> - /+ +/ - <<ao_emitters_metadata>> - /+ abstraction functions emitters ↑ +/ - /+ ↓ abstraction functions assertions +/ - <<abs_functions_assertions>> - /+ abstraction functions assertions ↑ +/ - } /+ ← closed: struct Abstraction +/ + /+ line.empty, post contents, empty variables: +/ + <<abs_in_loop_body_not_block_obj_line_empty>> + } // close else for line empty + } // close else for not the above + } // close after non code, other blocks or regular text + <<abs_in_loop_body_01>> + } /+ ← closed: loop markup document/text line by line +/ + /+ ↓ post loop markup document/text +/ + <<abs_post>> + /+ post loop markup document/text ↑ +/ + } /+ ← closed: abstract doc source +/ + /+ ↓ abstraction functions +/ + <<abs_functions_object_reset>> + <<abs_functions_header_set_common>> + <<abs_functions_ocn_status>> + <<abs_functions_block>> + <<abs_functions_block_code>> + <<abs_functions_block_biblio>> + // <<abs_functions_block_glossary>> + <<abs_functions_block_poem>> + <<abs_functions_block_group>> + <<abs_functions_block_block>> + <<abs_functions_block_quote>> + <<abs_functions_block_table>> + <<abs_functions_block_line_status_empty>> + <<abs_functions_book_index>> + <<abs_functions_heading>> + <<abs_functions_para>> + /+ abstraction functions ↑ +/ + /+ ↓ abstraction function emitters +/ + <<ao_emitters_ocn>> + /+ +/ + <<ao_emitters_obj_inline_markup_munge>> + <<ao_emitters_obj_inline_markup>> + <<ao_emitters_obj_inline_markup_and_anchor_tags>> + <<ao_emitters_obj_inline_markup_table_of_contents>> + <<ao_emitters_obj_inline_markup_private>> + <<ao_emitters_obj_inline_markup_heading_numbering_segment_anchor_tags>> + <<ao_emitters_obj_inline_markup_close>> + /+ +/ + <<ao_emitters_obj_attributes>> + <<ao_emitters_obj_attributes_public>> + <<ao_emitters_obj_attributes_private>> + <<ao_emitters_obj_attributes_private_an_attribute>> + <<ao_emitters_obj_attributes_private_json>> + <<ao_emitters_obj_attributes_private_close>> + /+ +/ + <<ao_emitters_book_index_nugget>> + <<ao_emitters_book_index_report_indented>> + <<ao_emitters_book_index_report_section>> + /+ +/ + <<ao_emitters_endnotes>> + /+ +/ + <<ao_emitters_bibliography>> + /+ +/ + <<ao_emitters_metadata>> + /+ abstraction functions emitters ↑ +/ + /+ ↓ abstraction functions assertions +/ + <<abs_functions_assertions>> + /+ abstraction functions assertions ↑ +/ } /+ ← closed: template SiSUdocAbstraction +/ #+END_SRC @@ -158,7 +157,30 @@ Process markup document, create document abstraction. #+name: abs_imports #+BEGIN_SRC d -import ao_object_setter; +import + ao_object_setter, + ao_defaults, + ao_rgx, + output_hub; +private import + std.algorithm, + std.array, + std.container, + std.exception, + std.file, + std.getopt, + std.json, + std.path, + std.process, + std.range, + std.regex, + std.stdio, + std.string, + std.traits, + std.typecons, + std.uni, + std.utf, + std.conv : to; #+END_SRC *** mixins :mixins: @@ -399,6 +421,8 @@ scope(exit) { #+name: abs_init_rest #+BEGIN_SRC d +mixin SiSUrgxInitFlags; +mixin SiSUnode; auto node_para_int_ = node_metadata_para_int; auto node_para_str_ = node_metadata_para_str; ObjGenericComposite comp_obj_heading_, comp_obj_para, comp_obj_toc; @@ -2059,6 +2083,7 @@ void _check_ocn_status_(L,T)( static assert(is(typeof(line) == char[])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if ((!line.empty) && (type["ocn_status_multi_obj"] == TriState.off)) { /+ not multi-line object, check whether obj_cite_number is on or turned off +/ if (matchFirst(line, rgx.obj_cite_number_block_marks)) { @@ -2123,6 +2148,7 @@ void _start_block_(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d + auto rgx = Rgx(); if (matchFirst(line, rgx.block_curly_code_open)) { /+ curly code open +/ debug(code) { // code (curly) open @@ -2291,6 +2317,7 @@ void _code_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if (type["curly_code"] == TriState.on) { if (matchFirst(line, rgx.block_curly_code_close)) { debug(code) { // code (curly) close @@ -2423,6 +2450,9 @@ void _biblio_block_( ref string biblio_entry_str_json, ref string[] biblio_arr_json ) { + mixin SiSUbiblio; + auto jsn = BibJsnStr(); + auto rgx = Rgx(); if (matchFirst(line, rgx.heading_biblio)) { type["biblio_section"] = TriState.on; type["blurb_section"] = State.off; @@ -2440,10 +2470,10 @@ void _biblio_block_( if ((bib_entry == State.off) && (biblio_entry_str_json.empty)) { bib_entry = State.on; - biblio_entry_str_json = biblio_entry_tags_jsonstr; + biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; } else if (!(biblio_entry_str_json.empty)) { bib_entry = State.off; - if (!(biblio_entry_str_json == biblio_entry_tags_jsonstr)) { + if (!(biblio_entry_str_json == jsn.biblio_entry_tags_jsonstr)) { auto biblio_entry = parseJSON(biblio_entry_str_json); if (biblio_entry["fulltitle"].str.empty) { writeln("check problem entry (Title missing): ", biblio_entry_str_json); @@ -2452,7 +2482,7 @@ void _biblio_block_( } else { biblio_arr_json ~= biblio_entry_str_json; } - biblio_entry_str_json = biblio_entry_tags_jsonstr; + biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; } } else { // CHECK ERROR writeln("?? 2. ERROR ", biblio_entry_str_json, "??"); @@ -2559,6 +2589,7 @@ void _poem_block_(L,O,T,C,N,Ma)( static assert(is(typeof(obj_cite_number_poem) == string[string])); static assert(is(typeof(dochead_make_aa) == string[string][string])); } + auto rgx = Rgx(); if (type["curly_poem"] == TriState.on) { if (matchFirst(line, rgx.block_curly_poem_close)) { an_object[an_object_key]="verse"; // check that this is as you please @@ -2760,6 +2791,7 @@ void _group_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if (type["curly_group"] == State.on) { if (matchFirst(line, rgx.block_curly_group_close)) { debug(group) { // group (curly) close @@ -2806,6 +2838,7 @@ void _block_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if (type["curly_block"] == TriState.on) { if (matchFirst(line, rgx.block_curly_block_close)) { debug(block) { // block (curly) close @@ -2852,6 +2885,7 @@ void _quote_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if (type["curly_quote"] == TriState.on) { if (matchFirst(line, rgx.block_curly_quote_close)) { debug(quote) { // quote (curly) close @@ -2898,6 +2932,7 @@ void _table_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if (type["curly_table"] == TriState.on) { if (matchFirst(line, rgx.block_curly_table_close)) { debug(table) { // table (curly) close @@ -3174,6 +3209,7 @@ auto _book_index_(L,I,O,T,B)( static assert(is(typeof(type) == int[string])); static assert(is(typeof(opt_action_bool) == bool[string])); } + auto rgx = Rgx(); if (auto m = match(line, rgx.book_index)) { /+ match book_index +/ debug(bookindexmatch) { // book index @@ -3237,6 +3273,7 @@ auto _heading_found_(L,X,H,R,T)( static assert(is(typeof(heading_match_rgx) == Regex!(char)[string])); static assert(is(typeof(type) == int[string])); } + auto rgx = Rgx(); if ((dochead_make_identify_unmarked_headings.length > 2) && (type["make_headings"] == State.off)) { /+ headings found +/ @@ -3408,6 +3445,7 @@ auto _heading_matched_(L,C,O,K,Lv,Lc,T,Me)( static assert(is(typeof(type) == int[string])); static assert(is(typeof(dochead_meta_aa) == string[string][string])); } + auto rgx = Rgx(); if (auto m = match(line, rgx.heading)) { /+ heading match +/ type["heading"] = State.on; @@ -3565,6 +3603,7 @@ auto _para_match_(L,O,K,I,B,T,C)( static assert(is(typeof(type) == int[string])); static assert(is(typeof(line_occur) == int[string])); } + auto rgx = Rgx(); if (line_occur["para"] == State.off) { /+ para matches +/ type["para"] = State.on; @@ -3819,8 +3858,12 @@ struct ObjInlineMarkupMunge { invariant() { } /+ revisit +/ - string code(string obj_txt_in) - in { } + string code(Ot)(Ot obj_txt_in) + in { + debug(asserts){ + assert(is(typeof(obj_txt_in) == string)); + } + } body { obj_txt["munge"]=obj_txt_in; return obj_txt["munge"]; diff --git a/org/ao_defaults.org b/org/ao_defaults.org index b46b2ad..db9709a 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -560,35 +560,40 @@ template SiSUnode() { #+BEGIN_SRC d template SiSUbiblio() { // required: deemed_author (author || editor); year; fulltitle; - auto biblio_entry_tags_jsonstr = `{ - "is" : "", - "sortby_deemed_author_year_title" : "", - "deemed_author" : "", - "author_raw" : "", - "author" : "", - "author_arr" : [ "" ], - "editor_raw" : "", - "editor" : "", - "editor_arr" : [ "" ], - "title" : "", - "subtitle" : "", - "fulltitle" : "", - "language" : "", - "trans" : "", - "src" : "", - "journal" : "", - "in" : "", - "volume" : "", - "edition" : "", - "year" : "", - "place" : "", - "publisher" : "", - "url" : "", - "pages" : "", - "note" : "", - "short_name" : "", - "id" : "" - }`; // is: book, article, magazine, newspaper, blog, other + struct BibJsnStr { + auto biblio_entry_tags_jsonstr() { + string x = `{ + "is" : "", + "sortby_deemed_author_year_title" : "", + "deemed_author" : "", + "author_raw" : "", + "author" : "", + "author_arr" : [ "" ], + "editor_raw" : "", + "editor" : "", + "editor_arr" : [ "" ], + "title" : "", + "subtitle" : "", + "fulltitle" : "", + "language" : "", + "trans" : "", + "src" : "", + "journal" : "", + "in" : "", + "volume" : "", + "edition" : "", + "year" : "", + "place" : "", + "publisher" : "", + "url" : "", + "pages" : "", + "note" : "", + "short_name" : "", + "id" : "" + }`; // is: book, article, magazine, newspaper, blog, other + return x; + } + } } #+END_SRC diff --git a/org/sdp.org b/org/sdp.org index facd2a3..bd1005c 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -192,7 +192,6 @@ mixin SiSUbiblio; mixin SiSUrgxInitFlags; mixin SiSUconfigSDLangHub; mixin SiSUmarkupRaw; -mixin SiSUdocAbstraction; mixin outputHub; #+END_SRC @@ -202,7 +201,6 @@ mixin outputHub; #+BEGIN_SRC d auto raw = MarkupRaw(); auto head = SiSUheaderExtractHub(); -auto abs = SiSUdocAbstraction(); /+ struct DocumentParts { string[string][] contents; @@ -413,7 +411,7 @@ static assert(_0_make_1_dochead_meta_tuple.length==2); #+NAME: sdp_each_file_do_document_abstraction #+BEGIN_SRC d /+ ↓ document abstraction: process document, return abstraction as tuple +/ -auto t = abs.SiSUdocAbstraction( +auto t = SiSUdocAbstraction!()( (_0_header_1_body_content_2_insert_filelist_tuple[1]), (_0_make_1_dochead_meta_tuple[0]), (_0_make_1_dochead_meta_tuple[1]), |