diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-10-07 12:59:49 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:13 -0400 |
commit | deac702d85c5bbe68a8acf762a01939028e65320 (patch) | |
tree | cafade712e0198441517054ee3898d65eedb8fac /src | |
parent | introduce a couple of unittests some re-organizing of obt (diff) |
0.7.1 re-arranging for unittests; tuple tests; read in files; obt
Diffstat (limited to 'src')
-rwxr-xr-x | src/sdp.d | 37 | ||||
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 38 | ||||
-rw-r--r-- | src/sdp/ao_conf_make_meta.d | 1 | ||||
-rw-r--r-- | src/sdp/ao_conf_make_meta_native.d | 2 | ||||
-rw-r--r-- | src/sdp/ao_conf_make_meta_sdlang.d | 2 | ||||
-rw-r--r-- | src/sdp/ao_read_source_files.d | 40 |
6 files changed, 48 insertions, 72 deletions
@@ -1,7 +1,6 @@ #!/usr/bin/env rdmd /+ sdp - sdp.d +/ /+ sdp: sisu document parser, see http://sisudoc.org +/ import @@ -181,35 +180,37 @@ void main(string[] args) { "not a sisu markup filename" ); /+ ↓ read file +/ - auto header_and_content_tuple = raw.sourceContent(fn_src); - static assert(!isTypeTuple!(header_and_content_tuple)); - auto header = header_and_content_tuple[0]; - auto sourcefile_content = header_and_content_tuple[1]; - debug(header_and_content) { + auto read_in_file_string = raw.sourceContent(fn_src); + /+ ↓ file tuple of header and content +/ + auto header_and_body_tuple = raw.sourceContentSplitIntoHeaderAndBody(read_in_file_string, fn_src); + auto header = header_and_body_tuple[0]; + auto content_body = header_and_body_tuple[1]; + debug(header_and_body) { writeln(header); - writeln(header_and_content_tuple.length); - writeln(sourcefile_content[0]); + writeln(header_and_body_tuple.length); + writeln(content_body[0]); } + /+ ↓ split header into make and meta +/ auto header_make_and_meta_tuple = head.headerContentAA(header, conf_doc_make_aa); static assert(!isTypeTuple!(header_make_and_meta_tuple)); - string[string][string] dochead_make_aa = header_make_and_meta_tuple[0]; - string[string][string] dochead_meta_aa = header_make_and_meta_tuple[1]; - /+ ↓ process document, return abstraction as tuple +/ - auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_aa, dochead_meta_aa); + string[string][string] dochead_make = header_make_and_meta_tuple[0]; + string[string][string] dochead_meta = header_make_and_meta_tuple[1]; + /+ ↓ document abstraction: process document, return abstraction as tuple +/ + auto t = abs.abstract_doc_source(content_body, dochead_make, dochead_meta); static assert(!isTypeTuple!(t)); auto doc_ao_contents = t[0]; // contents ~ endnotes ~ bookindex; // static assert(!isIterable!(doc_ao_contents)); auto doc_ao_bookindex_unordered_hashes = t[1]; auto doc_ao_biblio = t[2]; // destroy(t); - /+ ↓ document parts +/ + /+ ↓ debugs +/ debug(checkdoc) { // checkbook & dumpdoc dbg.abstract_doc_source_debugs( doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - dochead_make_aa, - dochead_meta_aa, + dochead_make, + dochead_meta, fn_src, opt_action_bool ); @@ -219,8 +220,8 @@ void main(string[] args) { doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - dochead_make_aa, - dochead_meta_aa, + dochead_make, + dochead_meta, fn_src, opt_action_bool ); @@ -231,7 +232,7 @@ void main(string[] args) { fn_src ); } - destroy(sourcefile_content); + destroy(content_body); destroy(t); destroy(doc_ao_contents); // destroy(doc_ao_make_aa); diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 5423513..d97b1b0 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -2064,7 +2064,6 @@ template SiSUdocAbstraction() { } } struct ObjInlineMarkup { - // struct ObjInlineMarkup : AssertObjInlineMarkup { auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; auto obj_inline_markup_and_anchor_tags(string[string] obj_, string[string][string] dochead_make_aa) @@ -2078,7 +2077,7 @@ template SiSUdocAbstraction() { switch (obj_["is"]) { case "heading": static __gshared string anchor_tag = ""; - // WORK ON, you still need to ensure that level 1 anchor_tags are unique + // TODO WORK ON, you still need to ensure that level 1 anchor_tags are unique obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, dochead_make_aa); obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"]); if (auto m = match(obj_txt["munge"], rgx.heading_anchor_tag)) { @@ -2737,41 +2736,6 @@ template SiSUdocAbstraction() { auto t = tuple(bookindex_section, obj_cite_number); return t; } - auto bookindex_build_section_( - string[][string][string] bookindex_unordered_hashes - ) { - auto mainkeys = - bookindex_unordered_hashes.byKey.array.sort().release; - string bi_tmp; - string[] bookindex_section; - // int bi_num; - // writeln(mainkeys.length); - foreach (mainkey; mainkeys) { - bi_tmp = "_0_1 !{" ~ mainkey ~ "}! "; - foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp ~= " {" ~ ref_ ~ "}#" ~ go ~ ", "; - } - bi_tmp ~= " \\\\\n "; - bookindex_unordered_hashes[mainkey].remove("_a"); - auto subkeys = - bookindex_unordered_hashes[mainkey].byKey.array.sort().release; - foreach (subkey; subkeys) { - bi_tmp ~= subkey ~ ", "; - // bi_tmp ~= " " ~ subkey ~ ", "; - foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp ~= " {" ~ ref_ ~ "}#" ~ go ~ ", "; - } - bi_tmp ~= " \\\\\n "; - ++skn; - } - bi_tmp = replaceFirst(bi_tmp, rgx.trailing_linebreak, ""); - bookindex_section ~= bi_tmp; - ++mkn; - } - return bookindex_section; - } } struct NotesSection { string object_notes; diff --git a/src/sdp/ao_conf_make_meta.d b/src/sdp/ao_conf_make_meta.d index 5bc9694..4056914 100644 --- a/src/sdp/ao_conf_make_meta.d +++ b/src/sdp/ao_conf_make_meta.d @@ -24,6 +24,7 @@ template SiSUheaderExtractHub() { ? (head_native.headerNativeToAA(header_src)) : (head_sdlang.headerSDLangToAA(header_src, conf_doc_make_aa)); static assert(!isTypeTuple!(header_make_and_meta_tuple)); + static assert(header_make_and_meta_tuple.length==2); return header_make_and_meta_tuple; } } diff --git a/src/sdp/ao_conf_make_meta_native.d b/src/sdp/ao_conf_make_meta_native.d index f70a7bf..1242565 100644 --- a/src/sdp/ao_conf_make_meta_native.d +++ b/src/sdp/ao_conf_make_meta_native.d @@ -209,7 +209,7 @@ template SiSUheaderExtractNative() { } } auto t = tuple(dochead_meta, dochead_make); - static assert(!isTypeTuple!(t)); + static assert(t.length==2); return t; } private auto native_header_extract( diff --git a/src/sdp/ao_conf_make_meta_sdlang.d b/src/sdp/ao_conf_make_meta_sdlang.d index 61b4960..3855e7c 100644 --- a/src/sdp/ao_conf_make_meta_sdlang.d +++ b/src/sdp/ao_conf_make_meta_sdlang.d @@ -237,7 +237,7 @@ template SiSUheaderExtractSDLang() { dochead_make = sdlangToAAmake(dochead_make, header_sdlang); auto dochead_meta = sdlangToAAmake(meta_aa, header_sdlang); auto t = tuple(dochead_make, dochead_meta); - static assert(!isTypeTuple!(t)); + static assert(t.length==2); return t; } private auto headerSDLangToAA(char[] header_sdlang_src, string[string][string] conf_doc_make_aa) { diff --git a/src/sdp/ao_read_source_files.d b/src/sdp/ao_read_source_files.d index 5aef05d..3fd070d 100644 --- a/src/sdp/ao_read_source_files.d +++ b/src/sdp/ao_read_source_files.d @@ -15,22 +15,28 @@ template SiSUmarkupRaw() { mixin RgxInit; auto rgx = Rgx(); struct MarkupRaw { - auto sourceContent(in string fn_src) { + final sourceContent(in string fn_src) { + auto raw = MarkupRawUnit(); + auto source_txt_str = + raw.markupSourceReadIn(fn_src); + return source_txt_str; + } + final auto sourceContentSplitIntoHeaderAndBody(in string source_txt_str, in string fn_src="") { auto raw = MarkupRawUnit(); auto t = - raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth); + raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str); auto header_raw = t[0]; - auto sourcefile_content = t[1]; - if (match(fn_src, rgx.src_fn_master)) { + auto sourcefile_body_content = t[1]; + if (match(fn_src, rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise auto ins = Inserts(); - sourcefile_content = - ins.scan_master_src_for_insert_files_and_import_content(sourcefile_content, fn_src); - // auto ins = SiSUdocInserts.Inserts(); + sourcefile_body_content = + ins.scan_master_src_for_insert_files_and_import_content(sourcefile_body_content, fn_src); } t = tuple( header_raw, - sourcefile_content + sourcefile_body_content ); + static assert(t.length==2); return t; } } @@ -90,12 +96,16 @@ template SiSUmarkupRaw() { split(cast(char[]) src_text, rgx.line_delimiter); return source_line_arr; } - auto markupSourceHeaderContentRawLineTupleArray(in string fn_src, Regex!(char) rgx_file ) { + auto markupSourceReadIn(in string fn_src) { + auto rgx = Rgx(); enforce( - match(fn_src, rgx_file), + match(fn_src, rgx.src_pth), "not a sisu markup filename" ); auto source_txt_str = readInMarkupSource(fn_src); + return source_txt_str; + } + auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { auto hc = header0Content1(source_txt_str); auto header = hc[0]; char[] la; @@ -108,7 +118,7 @@ template SiSUmarkupRaw() { ); return t; } - final char[][] markupSourceContentRawLineArray(in string fn_src, Regex!(char) rgx_file ) { + final char[][] getInsertMarkupSourceContentRawLineArray(in string fn_src, Regex!(char) rgx_file) { enforce( match(fn_src, rgx_file), "not a sisu markup filename" @@ -178,7 +188,7 @@ template SiSUmarkupRaw() { to!string(markup_src_file_path ~ insert_sub_pth ~ insert_fn); auto raw = MarkupRawUnit(); auto markup_sourcesubfile_insert_content = - raw.markupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); + raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); debug(insert) { // insert file tell_l("red", line); tell_l("red", fn_src_insert); @@ -207,7 +217,7 @@ template SiSUmarkupRaw() { return contents_insert; } auto scan_master_src_for_insert_files_and_import_content( - char[][] sourcefile_content, + char[][] sourcefile_body_content, string fn_src ) { mixin SiSUrgxInitFlags; @@ -215,7 +225,7 @@ template SiSUmarkupRaw() { auto type = flags_type_init; auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; - foreach (line; sourcefile_content) { + foreach (line; sourcefile_body_content) { if (type["curly_code"] == 1) { if (matchFirst(line, rgx.block_curly_code_close)) { type["curly_code"] = 0; @@ -246,7 +256,7 @@ template SiSUmarkupRaw() { // raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth); } auto markup_sourcefile_insert_content = - raw.markupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); + raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); debug(insert) { // insert file tell_l("red", line); tell_l("red", fn_src_insert); |