From 9bec897cdada305cae8ce78809dc3f9fe9cf8776 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Jun 2016 23:25:36 -0400 Subject: step4.1 as step4 but extract header meta & make on first reading in document --- org/sdp.org | 116 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 51 deletions(-) (limited to 'org/sdp.org') diff --git a/org/sdp.org b/org/sdp.org index 0b2fc53..80b7a45 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -28,7 +28,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 4, 0); +enum ver = Version(0, 4, 1); #+END_SRC ** pre loop init @@ -60,11 +60,12 @@ import compile_time_info, // sdp/compile_time_info.d ao_abstract_doc_source, // sdp/ao_abstract_doc_source.d ao_defaults, // sdp/ao_defaults.d + ao_header_extract, // sdp/ao_header_extract.d ao_read_source_files, // sdp/ao_read_source_files.d ao_output_debugs, // sdp/ao_output_debugs.d - output_hub, // output_hub.d ao_rgx, // sdp/ao_rgx.d - ao_ansi_colors; // sdp/ao_ansi_colors.d + ao_ansi_colors, // sdp/ao_ansi_colors.d + output_hub; // output_hub.d // std.conv; #+END_SRC @@ -94,27 +95,6 @@ private import std.conv : to; #+END_SRC -**** version.txt :version: - -#+NAME: sdp_version_mixin -#+BEGIN_SRC d -mixin(import("version.txt")); -#+END_SRC - -*** mixin :mixin: - -#+NAME: sdp_args -#+BEGIN_SRC d -mixin SiSUheader; -mixin SiSUbiblio; -mixin SiSUrgxInitFlags; -mixin SiSUmarkupRaw; -mixin SiSUdocAbstraction; -mixin SiSUoutputDebugs; -mixin SiSUoutputHub; -mixin ScreenTxtColors; -#+END_SRC - *** sdp output :output: #+NAME: sdp_args #+BEGIN_SRC d @@ -123,15 +103,14 @@ struct SDPoutput { auto ref const S contents, string[][string][string] bookindex_unordered_hashes, JSONValue[] biblio, - JSONValue[string] dochead_make, - JSONValue[string] dochead_meta, + // JSONValue[string] dochead_make_json, + // JSONValue[string] dochead_meta_json, string fn_src, bool[string] opt_action_bool ) { mixin ScreenTxtColors; mixin RgxInit; mixin SiSUoutputHub; - // mixin SiSUoutput; auto rgx = Rgx(); uint return_ = 0; if (opt_action_bool["source"]) { @@ -149,8 +128,8 @@ struct SDPoutput { if (opt_action_bool["html"]) { auto html=SDPoutputHTML(); html.css_write; - // html.scroll(contents, bookindex_unordered_hashes, biblio, fn_src, opt_action_bool); - html.scroll(contents, bookindex_unordered_hashes, biblio, dochead_make, dochead_meta, fn_src, opt_action_bool); + html.scroll(contents, bookindex_unordered_hashes, biblio, fn_src, opt_action_bool); + // html.scroll(contents, bookindex_unordered_hashes, biblio, dochead_make_json, dochead_meta_json, fn_src, opt_action_bool); } if (opt_action_bool["epub"]) { writeln("epub processing"); @@ -172,18 +151,42 @@ struct SDPoutput { } #+END_SRC +**** version.txt :version: + +#+NAME: sdp_version_mixin +#+BEGIN_SRC d +mixin(import("version.txt")); +#+END_SRC + +*** mixin :mixin: + +#+NAME: sdp_args +#+BEGIN_SRC d +mixin SiSUheaderSkel; +mixin SiSUheaderExtract; +mixin SiSUbiblio; +mixin SiSUrgxInitFlags; +// mixin SiSUconfiguration; +mixin SiSUmarkupRaw; +mixin SiSUdocAbstraction; +mixin SiSUoutputDebugs; +mixin SiSUoutputHub; +mixin ScreenTxtColors; +#+END_SRC + *** init :init: #+NAME: sdp_args #+BEGIN_SRC d auto raw = MarkupRaw(); +auto head = HeaderDocMetadataMakeJson(); auto abs = Abstraction(); auto dbg = SDPoutputDebugs(); auto output = SDPoutput(); /+ struct DocumentParts { string[string][] contents; - JSONValue[string] metadata_json; + JSONValue[string] meta_json; JSONValue[string] make_json; string[][string][string] bookindex_unordered_hashes; JSONValue[] biblio; @@ -202,8 +205,7 @@ auto rgx = Rgx(); scope(success) { debug(checkdoc) { writefln( - "%s~ run complete, ok ~ %s (sdp-%s.%s.%s, %s v%s, %s %s)", - scr_txt_color["cyan"], scr_txt_color["off"], + "~ run complete, ok ~ (sdp-%s.%s.%s, %s v%s, %s %s)", ver.major, ver.minor, ver.patch, __VENDOR__, __VERSION__, bits, os, @@ -299,10 +301,7 @@ foreach(arg; args) { #+BEGIN_SRC d scope(success) { debug(checkdoc) { - writefln( - "%s~ document complete, ok ~%s", - scr_txt_color["green"], scr_txt_color["off"], - ); + writeln("~ document complete, ok ~"); } // stderr.writeln("0"); } @@ -329,22 +328,37 @@ enforce( #+NAME: sdp_each_file_do #+BEGIN_SRC d /+ ↓ read file +/ -auto sourcefile_content = - raw.sourceContent(fn_src); +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) { + writeln(header); + writeln(header_and_content_tuple.length); + writeln(sourcefile_content[0]); +} +#+END_SRC + +**** [#A] read doc header: metadata & make :doc:header:metadata:make: +#+NAME: sdp_each_file_do +#+BEGIN_SRC d +/+ ↓ headers metadata & make +/ +auto header_content = head.headerContentJSON(header); +static assert(!isTypeTuple!(header_content)); +auto dochead_make_json = header_content[0]; +auto dochead_meta_json = header_content[1]; #+END_SRC **** [#A] processing: document abstraction, tuple :processing: #+NAME: sdp_each_file_do #+BEGIN_SRC d /+ ↓ porcess document, return abstraction as tuple +/ -auto t = abs.abstract_doc_source(sourcefile_content); +auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_json, dochead_meta_json); static assert(!isTypeTuple!(t)); auto doc_ao_contents = t[0]; // contents ~ endnotes ~ bookindex; // static assert(!isIterable!(doc_ao_contents)); -auto doc_ao_metadata_json = t[1]; -auto doc_ao_make_json = t[2]; -auto doc_ao_bookindex_unordered_hashes = t[3]; -auto doc_ao_biblio = t[4]; +auto doc_ao_bookindex_unordered_hashes = t[1]; +auto doc_ao_biblio = t[2]; // destroy(t); #+END_SRC @@ -358,8 +372,8 @@ debug(checkdoc) { // checkbook & dumpdoc doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - doc_ao_make_json, - doc_ao_metadata_json, + dochead_make_json, + dochead_meta_json, fn_src, opt_action_bool ); @@ -367,7 +381,7 @@ debug(checkdoc) { // checkbook & dumpdoc #+END_SRC **** TODO process outputs :outputs: -***** [#A] html :html: + #+NAME: sdp_each_file_do #+BEGIN_SRC d /+ ↓ output hub +/ @@ -375,8 +389,8 @@ output.hub( doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - doc_ao_make_json, - doc_ao_metadata_json, + // doc_ao_make_json, + // doc_ao_meta_json, fn_src, opt_action_bool ); @@ -395,9 +409,9 @@ scope(exit) { destroy(sourcefile_content); destroy(t); destroy(doc_ao_contents); - destroy(doc_ao_make_json); - destroy(doc_ao_metadata_json); - destroy(doc_ao_bookindex_unordered_hashes); + // destroy(doc_ao_make_json); + // destroy(doc_ao_meta_json); + // destroy(doc_ao_bookindex_unordered_hashes); destroy(doc_ao_biblio); destroy(fn_src); } -- cgit v1.2.3