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/sdp/ao_read_source_files.d | |
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/sdp/ao_read_source_files.d')
-rw-r--r-- | src/sdp/ao_read_source_files.d | 40 |
1 files changed, 25 insertions, 15 deletions
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); |