diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-04-24 22:08:24 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2016-04-24 22:08:24 -0400 |
commit | ed302d1be74d2b4e69ee4b6e3834637ed531eaea (patch) | |
tree | 0f605c3756788d2fda6fe0782a7a472172a285b9 /org/sdp.org | |
parent | base ... tag (diff) |
step1doc-reform_v0.0.1
Diffstat (limited to 'org/sdp.org')
-rw-r--r-- | org/sdp.org | 211 |
1 files changed, 154 insertions, 57 deletions
diff --git a/org/sdp.org b/org/sdp.org index bd0ad84..e8e100a 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -17,20 +17,34 @@ Deal with imports. Take command line instructions and process files as instructed. +** TODO version, (version.txt) set version (with structure) :version: + +#+NAME: version_txt +#+BEGIN_SRC d +struct Version { + int major; + int minor; + int patch; +} +enum ver = Version(1, 0, 0); +#+END_SRC + ** imports :import: +[[./compile_time_info.org][compile time info]] [[./ao_abstract_doc_source.org][ao_abstract_doc_source]] [[./ao_assertions.org][ao_assertions]] [[./ao_defaults.org][ao_defaults]] -[[./ao_emitters_and_interfaces.org][ao_emitters_and_interfaces: ao_emitter; ao_interface]] +[[./ao_emitter.org][ao_emitter]] [[./ao_read_markup_source.org][ao_read_markup_source]] -// [[./ao_read_markup_source.org][ao_read_markup_source]] [[./ao_object_setter.org][ao_object_setter]] [[./ao_output_debugs.org][ao_output_debugs]] [[./ao_rgx.org][ao_rgx]] [[./ao_scan_inserts.org][ao_scan_inserts]] +[[./ao_structs.org][ao_structs]] [[./ao_utils.org][ao_utils]] -#+name: sdp_imports +*** std :import:std: +#+NAME: sdp_imports #+BEGIN_SRC d /+ sdp sisu document parser +/ import @@ -50,24 +64,60 @@ import std.typecons, std.utf, // std.variant, + std.conv : to; +#+END_SRC + +*** sdp :import:sdp: +**** TODO lib/sdp.d +#+NAME: sdp_imports_use +#+BEGIN_SRC d +/+ sdp sisu document parser +/ +import + lib.sdp.compile_time_info, // sdp/compile_time_info.d lib.sdp.ao_abstract_doc_source, // sdp/ao_abstract_doc_source.d lib.sdp.ao_assertions, // sdp/ao_assertions.d lib.sdp.ao_defaults, // sdp/ao_defaults.d lib.sdp.ao_emitter, // sdp/ao_emitter.d - lib.sdp.ao_interface, // sdp/ao_interface.d - lib.sdp.ao_read_markup_source, // sdp/ao_read_markup_source.d + lib.sdp.ao_read_markup_source, // sdp/ao_read_markup_source.d lib.sdp.ao_object_setter, // sdp/ao_object_setter.d lib.sdp.ao_output_debugs, // sdp/ao_output_debugs.d lib.sdp.ao_rgx, // sdp/ao_rgx.d lib.sdp.ao_scan_inserts, // sdp/ao_scan_inserts.d + lib.sdp.ao_structs, // sdp/ao_structs.d lib.sdp.ao_utils; // sdp/ao_utils.d // std.conv; -import std.conv : to; +#+END_SRC + +**** TODO lib/sdp/std.d (rdmd) :rdmd: +#+NAME: sdp_imports_rdmd +#+BEGIN_SRC d +/+ sdp sisu document parser +/ +import + compile_time_info, // compile_time_info.d + ao_abstract_doc_source, // ao_abstract_doc_source.d + ao_assertions, // ao_assertions.d + ao_defaults, // ao_defaults.d + ao_emitter, // ao_emitter.d + ao_read_markup_source, // sdp/ao_read_markup_source.d + ao_object_setter, // ao_object_setter.d + ao_output_debugs, // ao_output_debugs.d + ao_rgx, // ao_rgx.d + ao_scan_inserts, // ao_scan_inserts.d + ao_structs, // ao_structs.d + ao_utils; // ao_utils.d + // std.conv; +#+END_SRC + +*** version.txt :version: +#+NAME: sdp_version_mixin +#+BEGIN_SRC d +// import std.stdio; +mixin(import("version.txt")); #+END_SRC ** argv [+3] :argv: *** argv mixins & init -#+name: sdp_argv +#+NAME: sdp_argv #+BEGIN_SRC d mixin SiSUheader; mixin SiSUbiblio; @@ -77,10 +127,10 @@ mixin SiSUdocInserts; mixin SiSUdocAbstraction; mixin SiSUoutputDebugs; mixin ScreenTxtColors; -auto cli = new CLI(); -auto raw = new MarkupRaw(); -auto abs = new Abstraction(); -auto dbg = new SDPoutputDebugs(); +auto cli = CLI(); +auto raw = MarkupRaw(); +auto abs = Abstraction(); +auto dbg = SDPoutputDebugs(); // struct DocumentParts { // string[string][] contents; // JSONValue[string] metadata_json; @@ -88,47 +138,60 @@ auto dbg = new SDPoutputDebugs(); // string[][string][string] bookindex_unordered_hashes; // JSONValue[] biblio; // } -char[][] msc; -string[1000] fns_src; +string[] fns_src; string flag_action; string[string] actions; -int file_count; actions = [ "assert" : "yes", ]; -auto rgx = new Rgx(); +auto rgx = Rgx(); scope(success) { debug(checkdoc) { - writeln( + writefln( + "%s~ run complete, ok ~ %s (sdp-%s.%s.%s, %s v%s, %s %s)", scr_txt_color["cyan"], - "~ run complete, ok ~ ", scr_txt_color["off"], + ver.major, + ver.minor, + ver.patch, + __VENDOR__, + __VERSION__, + bits, + os, ); } - // writeln("0"); + // stderr.writeln("0"); } scope(failure) { - debug(checkdoc) { - writeln( + debug(checkdoc) { + writefln( + "%s~ run failure ~%s", scr_txt_color["fuchsia"], - "~ run failure ~", scr_txt_color["off"], + ); + } + // stderr.writeln("1"); +} +scope(exit) { + debug(checkdoc) { + writefln( + "(%s v%s)", + __VENDOR__, + __VERSION__, ); } - // writeln("1"); } #+END_SRC *** argv loop -#+name: sdp_argv +#+NAME: sdp_argv #+BEGIN_SRC d foreach(cmdlnins; argv) { if (match(cmdlnins, rgx.flag_action)) { flag_action ~= " " ~ cmdlnins; actions = cli.extract_actions(cmdlnins, actions); } else if (match(cmdlnins, rgx.src_pth)) { - fns_src[file_count] = cmdlnins; - file_count++; + fns_src ~= cmdlnins; } } #+END_SRC @@ -136,29 +199,38 @@ foreach(cmdlnins; argv) { *** each file [+2] :file: **** filename provided [+1] ***** scope :scope: -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do #+BEGIN_SRC d scope(success) { debug(checkdoc) { - writeln( + writefln( + "%s~ document complete, ok ~%s %s", scr_txt_color["green"], - "~ document complete, ok ~ ", scr_txt_color["off"], fn_src ); } - // writeln("0"); + // stderr.writeln("0"); } scope(failure) { debug(checkdoc) { - writeln( + writefln( + "%s~ document run failure ~%s (%s v%s)\n\t%s", scr_txt_color["red"], - "~ document run failure ~", scr_txt_color["off"], + __VENDOR__, + __VERSION__, + fn_src + ); + } + // stderr.writeln("1"); +} +scope(exit) { + debug(checkdoc) { + writeln( fn_src ); } - // writeln("1"); } enforce( match(fn_src, rgx.src_pth), @@ -167,9 +239,9 @@ enforce( #+END_SRC ***** read file :file:read: -[[./ao_read_markup_source.org][ao_read_markup_source]] +[[./ao_markup_source_raw.org][ao_markup_source_raw]] -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do #+BEGIN_SRC d auto markup_sourcefile_content = raw.markupSourceContentRawLineArray(fn_src); // alternative call @@ -181,7 +253,10 @@ debug(insert) { auto m = match(fn_src, rgx.src_pth); // auto m = match(fn_src, rgx.src_pth); auto markup_src_file_path = m.captures[1]; - writeln("markup source file path: ", markup_src_file_path); // writeln(m.captures[1]); + writefln( + "markup source file path: %s", + markup_src_file_path + ); // writeln(m.captures[1]); writeln(m.captures[2]); } #+END_SRC @@ -189,32 +264,35 @@ debug(insert) { ****** incorporate any inserts [[./ao_scan_inserts.org][ao_scan_inserts]] -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do #+BEGIN_SRC d if (match(fn_src, rgx.src_fn_master)) { -/+ if master file scan document source for document imports (inserted sub-documents) +/ - auto ins = new Inserts(); - auto markup_master_sourcefile_content = +/+ if master file .ssm + scan document source for document imports + (inserted sub-documents) ++/ + auto ins = Inserts(); + markup_sourcefile_content = ins.scan_doc_source(markup_sourcefile_content, fn_src); - msc = markup_master_sourcefile_content; -} else if (match(fn_src, rgx.src_fn)) { - msc = markup_sourcefile_content; -} else { +} else if (!match(fn_src, rgx.src_fn)) { writeln("not a recognized filename"); } debug(raw) { - foreach (line; msc) { + foreach (line; markup_sourcefile_content) { writeln(line); } } #+END_SRC ***** send for processing :processing: -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do #+BEGIN_SRC d -/+ process document ao_abstract_doc_source SiSUdocAbstraction::Abstraction return abstraction as tuple +/ +/+ process document ao_abstract_doc_source + SiSUdocAbstraction::Abstraction + return abstraction as tuple ++/ auto t = - abs.abstract_doc_source(msc); + abs.abstract_doc_source(markup_sourcefile_content); static assert(!isTypeTuple!(t)); auto contents = t[0]; // static assert(!isIterable!(contents)); @@ -226,7 +304,7 @@ auto biblio = t[4]; #+END_SRC ***** debug document parts (checkdoc) -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do #+BEGIN_SRC d // DocumentParts debug(checkdoc) { @@ -245,10 +323,10 @@ debug(checkdoc) { #+END_SRC ***** on exit -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do #+BEGIN_SRC d scope(exit) { - destroy(msc); + destroy(markup_sourcefile_content); destroy(t); destroy(contents); destroy(make_json); @@ -260,25 +338,29 @@ scope(exit) { #+END_SRC **** no filename provided -#+name: sdp_no_filename_provided +#+NAME: sdp_no_filename_provided #+BEGIN_SRC d -/* no recognized filename provided */ +/+ no recognized filename provided +/ writeln("no recognized filename"); break; // terminate, stop #+END_SRC * tangles :tangle: -** code structure :sdp.d: -#+name: tangle_sdp +** sdp code structure :sdp.d: +*** TODO lib/sdp.d #+BEGIN_SRC d :tangle ../lib/sdp.d :shebang #!/usr/bin/env rdmd -/* +/+ sdp sdp.d -*/ ++/ <<sdp_imports>> -mixin RgxInit; mixin Interfaces; mixin Emitters; +<<sdp_imports_use>> +<<sdp_version_mixin>> +mixin CompileTimeInfo; +mixin RgxInit; mixin Emitters; void main(string[] argv) { + <<sdp_compilation>> <<sdp_argv>> foreach(fn_src; fns_src) { if (!empty(fn_src)) { @@ -289,3 +371,18 @@ void main(string[] argv) { } } #+end_src + +** version.txt :version: + +*** TODO lib/version.txt +#+BEGIN_SRC d :tangle ../lib/version.txt +/+ obt - org generated file +/ +<<version_txt>> +#+END_SRC + +*** TODO lib/sdp/version.txt :rdmd: +#+BEGIN_SRC d :tangle ../lib/sdp/version.txt +/+ obt - org generated file +/ +// [used by rdmd] +<<version_txt>> +#+END_SRC |