From deac702d85c5bbe68a8acf762a01939028e65320 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 7 Oct 2016 12:59:49 -0400 Subject: 0.7.1 re-arranging for unittests; tuple tests; read in files; obt --- org/ao_read_source_files.org | 69 +++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 20 deletions(-) (limited to 'org/ao_read_source_files.org') diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org index 11647fb..be7a3a5 100644 --- a/org/ao_read_source_files.org +++ b/org/ao_read_source_files.org @@ -121,7 +121,7 @@ final private auto configSDLang(string conf_sdl) { * get markup source, read file :source:markup: ** [#A] read file, source string :string: -#+name: ao_markup_source_raw +#+name: ao_markup_source_raw_read_file_source_string #+BEGIN_SRC d final private string readInMarkupSource(in string fn_src) { enforce( @@ -189,7 +189,7 @@ catch (ErrnoException ex) { here you split document header and body, an array.length == 2 split is on first match of level A~ (which is required) -#+name: ao_markup_source_raw +#+name: ao_markup_source_raw_doc_header_and_content_split #+BEGIN_SRC d final private char[][] header0Content1(in string src_text) { /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/ @@ -207,7 +207,7 @@ final private char[][] header0Content1(in string src_text) { ** source line array :array: -#+name: ao_markup_source_raw +#+name: ao_markup_source_raw_source_line_array #+BEGIN_SRC d final private char[][] markupSourceLineArray(in char[] src_text) { char[][] source_line_arr = @@ -220,14 +220,26 @@ final private char[][] markupSourceLineArray(in char[] src_text) { - used for regular .sst files; master .ssm files and; .ssi inserts - regex is passed for relevant enforce match -#+name: ao_markup_source_raw +*** read in file + +#+name: ao_markup_source_raw_read_in_file #+BEGIN_SRC d -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; +} +#+END_SRC + +*** tuple header and body content + +#+name: ao_markup_source_raw_tuple_of_header_and_body +#+BEGIN_SRC d +auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { auto hc = header0Content1(source_txt_str); auto header = hc[0]; char[] la; @@ -240,7 +252,13 @@ auto markupSourceHeaderContentRawLineTupleArray(in string fn_src, Regex!(char) r ); return t; } -final char[][] markupSourceContentRawLineArray(in string fn_src, Regex!(char) rgx_file ) { +#+END_SRC + +*** get insert source line array + +#+name: ao_markup_source_raw_get_insert_source_line_array +#+BEGIN_SRC d +final char[][] getInsertMarkupSourceContentRawLineArray(in string fn_src, Regex!(char) rgx_file) { enforce( match(fn_src, rgx_file), "not a sisu markup filename" @@ -316,7 +334,7 @@ if (type1["curly_code"] == 1) { 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); @@ -395,7 +413,7 @@ if (type["curly_code"] == 1) { // 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); @@ -456,22 +474,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; } } @@ -479,7 +503,12 @@ template SiSUmarkupRaw() { struct MarkupRawUnit { private import std.file; // enum State { off, on } - <> + <> + <> + <> + <> + <> + <> } struct Inserts { private import ao_defaults; // ao_defaults.d @@ -496,12 +525,12 @@ template SiSUmarkupRaw() { <> } auto scan_master_src_for_insert_files_and_import_content( - char[][] sourcefile_content, + char[][] sourcefile_body_content, string fn_src ) { mixin SiSUrgxInitFlags; <> - foreach (line; sourcefile_content) { + foreach (line; sourcefile_body_content) { <> } // end src doc loop <> -- cgit v1.2.3