diff options
Diffstat (limited to 'org/ao_read_source_files.org')
-rw-r--r-- | org/ao_read_source_files.org | 273 |
1 files changed, 162 insertions, 111 deletions
diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org index 77c3266..3a72106 100644 --- a/org/ao_read_source_files.org +++ b/org/ao_read_source_files.org @@ -13,9 +13,147 @@ #+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) [[./sdp.org][sdp]] [[./][org/]] -* get config file :config: -** [#A] read config file, source string :string: -*** config file (conf.sdl & sisu_document_make) :file:config: +* 0. Code Outline / Structure (tangles) :tangle: +** 1. config files (conf.sdl & sisu_document_make) :ao_config_files: +*** config files, read in + +#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d +/++ + read configuration files<BR> + - read config files<BR> + ao_config_files.d ++/ +template SiSUconfigIn() { + private import + std.exception, + std.stdio, + std.utf, + std.conv : to; + private + struct ConfigIn { + private import std.file; + <<ao_config_file_in>> + } +} +#+END_SRC + +*** config files get sdlang root tag + +#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d +/+ + ++/ +template SiSUconfigSDLang() { + struct ConfigSDLangRootTag { + <<ao_config_file_sdlang>> + } +} +#+END_SRC + +*** config files hub + +#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d +/+ + ++/ +template SiSUconfigSDLangHub() { + mixin SiSUconfigIn; + mixin SiSUconfigSDLang; + struct ConfigHub { + <<ao_config_file_sdlang_hub>> + } +} +#+END_SRC + +** 2. ao_markup_source_raw.d: :ao_markup_source_raw: + +#+BEGIN_SRC d :tangle ../src/sdp/ao_read_source_files.d +/++ + module ao_read_source_files;<BR> + - open markup files<BR> + - if master file scan for addional files to import/insert ++/ +template SiSUmarkupRaw() { + private import + std.exception, + std.regex, + std.stdio, + std.utf, + std.conv : to; + private import + ao_rgx; // ao_defaults.d + mixin RgxInit; + auto rgx = Rgx(); + struct MarkupRaw { + 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(source_txt_str); + auto header_raw = t[0]; + 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_body_content = + ins.scan_master_src_for_insert_files_and_import_content(sourcefile_body_content, fn_src); + } + t = tuple( + header_raw, + sourcefile_body_content + ); + static assert(t.length==2); + return t; + } + } + private + struct MarkupRawUnit { + private import std.file; + <<ao_markup_source_raw_read_file_source_string>> + <<ao_markup_source_raw_doc_header_and_content_split>> + <<ao_markup_source_raw_source_line_array>> + <<ao_markup_source_raw_read_in_file>> + <<ao_markup_source_raw_tuple_of_header_and_body>> + <<ao_markup_source_raw_get_insert_source_line_array>> + } + struct Inserts { + private import ao_defaults; // ao_defaults.d + auto scan_subdoc_source( + char[][] markup_sourcefile_insert_content, + string fn_src + ) { + mixin SiSUrgxInitFlags; + <<ao_inserts_scan>> + foreach (line; markup_sourcefile_insert_content) { + <<ao_inserts_scan_loop>> + } // end src subdoc (inserts) loop + <<ao_inserts_scan_post>> + } + auto scan_master_src_for_insert_files_and_import_content( + char[][] sourcefile_body_content, + string fn_src + ) { + mixin SiSUrgxInitFlags; + <<ao_master_doc_scan_for_insert_filenames>> + foreach (line; sourcefile_body_content) { + <<ao_master_doc_scan_for_insert_filenames_loop>> + } // end src doc loop + <<ao_master_doc_scan_for_insert_filenames_post>> + } + } +} +#+END_SRC + +INSERTS? +[[./ao_scan_inserts.org][ao_scan_inserts]] +WORK AREA + +* 1. get config file :config: +** read config file, source string (conf.sdl & sisu_document_make) :file:config: #+name: ao_config_file_in #+BEGIN_SRC d @@ -51,7 +189,7 @@ final private string readInConfigFile(string conf_sdl) { } #+END_SRC -*** config file get sdl root tag :file:conf:sdlang: +** config file get sdl root tag :file:conf:sdlang: #+name: ao_config_file_sdlang #+BEGIN_SRC d @@ -75,7 +213,7 @@ private auto configSDLangRootTag(string configuration, string conf_sdl_filename) } #+END_SRC -*** config file (conf.sdl & sisu_document_make) :file:config:hub: +** config file (conf.sdl & sisu_document_make) :file:config:hub: #+name: ao_config_file_sdlang_hub #+BEGIN_SRC d @@ -88,8 +226,9 @@ final private auto configSDLang(string conf_sdl) { } #+END_SRC -* get markup source, read file :source:markup: -** [#A] read file, source string :string: +* 2. get markup source, read file +** get markup source, read file :source:markup: +*** [#A] read file, source string :string: #+name: ao_markup_source_raw_read_file_source_string #+BEGIN_SRC d @@ -117,13 +256,13 @@ final private string readInMarkupSource(in string fn_src) { } #+END_SRC -*** notes +**** notes source_txt_str = readText(fn_src); // ok catch (ErrnoException ex) { } -** [#A] document header & content, array.length == 2 :array: +*** [#A] document header & content, array.length == 2 :array: here you split document header and body, an array.length == 2 split is on first match of level A~ (which is required) @@ -144,7 +283,7 @@ final private char[][] header0Content1(in string src_text) { } #+END_SRC -** source line array :array: +*** source line array :array: #+name: ao_markup_source_raw_source_line_array #+BEGIN_SRC d @@ -155,11 +294,11 @@ final private char[][] markupSourceLineArray(in char[] src_text) { } #+END_SRC -** source content raw line array :array: +*** source content raw line array :array: - used for regular .sst files; master .ssm files and; .ssi inserts - regex is passed for relevant enforce match -*** read in file +**** read in file #+name: ao_markup_source_raw_read_in_file #+BEGIN_SRC d @@ -174,7 +313,7 @@ auto markupSourceReadIn(in string fn_src) { } #+END_SRC -*** tuple header and body content +**** tuple header and body content #+name: ao_markup_source_raw_tuple_of_header_and_body #+BEGIN_SRC d @@ -191,7 +330,7 @@ auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { } #+END_SRC -*** get insert source line array +**** get insert source line array #+name: ao_markup_source_raw_get_insert_source_line_array #+BEGIN_SRC d @@ -206,11 +345,11 @@ final char[][] getInsertMarkupSourceContentRawLineArray(in string fn_src, Regex! } #+END_SRC -* get markup source, master file & inserts :masterfile:inserts: +** get markup source, master file & inserts :masterfile:inserts: [[./sdp.org][sdp]] [[./][org/]] -** scan inserts (sub-document) source :scan_insert_src: -*** scan subdoc source +*** scan inserts (sub-document) source :scan_insert_src: +**** scan subdoc source #+name: ao_inserts_scan #+BEGIN_SRC d @@ -220,7 +359,7 @@ auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; #+END_SRC -*** loop insert (sub-document) +**** loop insert (sub-document) #+name: ao_inserts_scan_loop #+BEGIN_SRC d @@ -296,15 +435,15 @@ if (type1["curly_code"] == 1) { } #+END_SRC -*** post loop +**** post loop #+name: ao_inserts_scan_post #+BEGIN_SRC d return contents_insert; #+END_SRC -** scan document source :scan_src: -*** scan doc source +*** scan document source :scan_src: +**** scan doc source #+name: ao_master_doc_scan_for_insert_filenames #+BEGIN_SRC d @@ -314,7 +453,7 @@ auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; #+END_SRC -*** loop master scan for inserts (insert documents) +**** loop master scan for inserts (insert documents) #+name: ao_master_doc_scan_for_insert_filenames_loop #+BEGIN_SRC d @@ -375,7 +514,7 @@ if (type["curly_code"] == 1) { } #+END_SRC -*** post loop +**** post loop #+name: ao_master_doc_scan_for_insert_filenames_post #+BEGIN_SRC d @@ -386,94 +525,6 @@ debug(insert) { // insert file return contents; #+END_SRC -* tangles (code structure) :tangle: -** ao_markup_source_raw.d: :ao_markup_source_raw: - -#+BEGIN_SRC d :tangle ../src/sdp/ao_read_source_files.d -/++ - module ao_read_source_files;<BR> - - open markup files<BR> - - if master file scan for addional files to import/insert -+/ -template SiSUmarkupRaw() { - private import - std.exception, - std.regex, - std.stdio, - std.utf, - std.conv : to; - private import - ao_rgx; // ao_defaults.d - mixin RgxInit; - auto rgx = Rgx(); - struct MarkupRaw { - 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(source_txt_str); - auto header_raw = t[0]; - 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_body_content = - ins.scan_master_src_for_insert_files_and_import_content(sourcefile_body_content, fn_src); - } - t = tuple( - header_raw, - sourcefile_body_content - ); - static assert(t.length==2); - return t; - } - } - private - struct MarkupRawUnit { - private import std.file; - <<ao_markup_source_raw_read_file_source_string>> - <<ao_markup_source_raw_doc_header_and_content_split>> - <<ao_markup_source_raw_source_line_array>> - <<ao_markup_source_raw_read_in_file>> - <<ao_markup_source_raw_tuple_of_header_and_body>> - <<ao_markup_source_raw_get_insert_source_line_array>> - } - struct Inserts { - private import ao_defaults; // ao_defaults.d - auto scan_subdoc_source( - char[][] markup_sourcefile_insert_content, - string fn_src - ) { - mixin SiSUrgxInitFlags; - <<ao_inserts_scan>> - foreach (line; markup_sourcefile_insert_content) { - <<ao_inserts_scan_loop>> - } // end src subdoc (inserts) loop - <<ao_inserts_scan_post>> - } - auto scan_master_src_for_insert_files_and_import_content( - char[][] sourcefile_body_content, - string fn_src - ) { - mixin SiSUrgxInitFlags; - <<ao_master_doc_scan_for_insert_filenames>> - foreach (line; sourcefile_body_content) { - <<ao_master_doc_scan_for_insert_filenames_loop>> - } // end src doc loop - <<ao_master_doc_scan_for_insert_filenames_post>> - } - } -} -#+END_SRC - -INSERTS? -[[./ao_scan_inserts.org][ao_scan_inserts]] -WORK AREA - ** config files (conf.sdl & sisu_document_make) :ao_config_files: *** config files, read in |