From bdeee0ea38b48d4fc5c4bb7411a584a9af29382f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 27 Jan 2017 15:57:55 -0500 Subject: document abstraction template --- org/ao_abstract_doc_source.org | 269 ++++++++++++++++++++++++----------------- org/ao_defaults.org | 63 +++++----- org/sdp.org | 4 +- 3 files changed, 191 insertions(+), 145 deletions(-) (limited to 'org') 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 +/ - <> - /+ ↓ abstraction mixins +/ - <> - /+ ↓ abstraction struct init +/ - <> - /+ ↓ 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 +/ - <> - /+ abstraction init ↑ +/ - /+ ↓ loop markup document/text line by line +/ - srcDocLoop: - foreach (line; markup_sourcefile_content) { - /+ ↓ markup document/text line by line +/ - <> - if (type["code"] == TriState.on) { - <> - } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { - /+ object other than "code block" object - (includes regular text paragraph, headings & blocks other than code) +/ - <> + /+ ↓ abstraction imports +/ + <> + /+ ↓ abstraction mixins +/ + <> + /+ ↓ abstraction struct init +/ + <> + /+ ↓ 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 +/ + <> + /+ abstraction init ↑ +/ + /+ ↓ loop markup document/text line by line +/ + srcDocLoop: + foreach (line; markup_sourcefile_content) { + /+ ↓ markup document/text line by line +/ + <> + if (type["code"] == TriState.on) { + <> + } else if (!matchFirst(line, rgx.skip_from_regular_parse)) { + /+ object other than "code block" object + (includes regular text paragraph, headings & blocks other than code) +/ + <> + } else { + /+ not within a block group +/ + <> + if (matchFirst(line, rgx.block_open)) { + <> + } else if (!line.empty) { + /+ line not empty +/ + /+ non blocks (headings, paragraphs) & closed blocks +/ + <> + } else if (type["blocks"] == TriState.closing) { + /+ line empty, with blocks flag +/ + <> } else { - /+ not within a block group +/ - <> - if (matchFirst(line, rgx.block_open)) { - <> - } else if (!line.empty) { - /+ line not empty +/ - /+ non blocks (headings, paragraphs) & closed blocks +/ - <> - } else if (type["blocks"] == TriState.closing) { - /+ line empty, with blocks flag +/ - <> - } else { - /+ line.empty, post contents, empty variables: +/ - <> - } // close else for line empty - } // close else for not the above - } // close after non code, other blocks or regular text - <> - } /+ ← closed: loop markup document/text line by line +/ - /+ ↓ post loop markup document/text +/ - <> - /+ post loop markup document/text ↑ +/ - } /+ ← closed: abstract doc source +/ - /+ ↓ abstraction functions +/ - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - /+ abstraction functions ↑ +/ - /+ ↓ abstraction function emitters +/ - <> - /+ +/ - <> - <> - <> - <> - <> - <> - <> - /+ +/ - <> - <> - <> - <> - <> - <> - /+ +/ - <> - <> - <> - /+ +/ - <> - /+ +/ - <> - /+ +/ - <> - /+ abstraction functions emitters ↑ +/ - /+ ↓ abstraction functions assertions +/ - <> - /+ abstraction functions assertions ↑ +/ - } /+ ← closed: struct Abstraction +/ + /+ line.empty, post contents, empty variables: +/ + <> + } // close else for line empty + } // close else for not the above + } // close after non code, other blocks or regular text + <> + } /+ ← closed: loop markup document/text line by line +/ + /+ ↓ post loop markup document/text +/ + <> + /+ post loop markup document/text ↑ +/ + } /+ ← closed: abstract doc source +/ + /+ ↓ abstraction functions +/ + <> + <> + <> + <> + <> + <> + // <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + /+ abstraction functions ↑ +/ + /+ ↓ abstraction function emitters +/ + <> + /+ +/ + <> + <> + <> + <> + <> + <> + <> + /+ +/ + <> + <> + <> + <> + <> + <> + /+ +/ + <> + <> + <> + /+ +/ + <> + /+ +/ + <> + /+ +/ + <> + /+ abstraction functions emitters ↑ +/ + /+ ↓ abstraction 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]), -- cgit v1.2.3