diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-06-16 01:49:06 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-04 14:48:18 -0400 |
commit | 8ab7e935913c102fb039110e20b71f698a68c6ee (patch) | |
tree | 3472debd16ce656a57150399ce666e248565f011 /src/sdp.d | |
parent | step4.1 as step4 but extract header meta & make on first reading in document (diff) |
step5 sdlang used for config files and doc headers
Diffstat (limited to 'src/sdp.d')
-rwxr-xr-x | src/sdp.d | 155 |
1 files changed, 92 insertions, 63 deletions
@@ -8,13 +8,18 @@ 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_config_files, // sdp/ao_read_config_files.d ao_read_source_files, // sdp/ao_read_source_files.d ao_output_debugs, // sdp/ao_output_debugs.d ao_rgx, // sdp/ao_rgx.d ao_ansi_colors, // sdp/ao_ansi_colors.d output_hub; // output_hub.d // std.conv; +/+ sdlang http://sdlang.org +/ +import sdlang; // sdlang.d + // sdlang.parser, // sdlang/parser.d + // sdlang.exceptions; // sdp/ao_ansi_colors.d + // // std.conv; /+ sdp sisu document parser +/ private import std.getopt, @@ -36,74 +41,73 @@ private import std.utf, // std.variant, std.conv : to; +struct SDPoutput { + auto hub(S)( + auto ref const S contents, + string[][string][string] bookindex_unordered_hashes, + JSONValue[] biblio, + // JSONValue[string] dochead_make_json, + // JSONValue[string] dochead_meta_json, + string fn_src, + bool[string] opt_action_bool + ) { + mixin ScreenTxtColors; + mixin RgxInit; + mixin SiSUoutputHub; + auto rgx = Rgx(); + uint return_ = 0; + if (opt_action_bool["source"]) { + writeln("sisupod source"); + } + if (opt_action_bool["sisupod"]) { + writeln("sisupod source"); + } + if (opt_action_bool["text"]) { + writeln("text processing"); + // auto text=SDPoutput_text(); + // text.scroll(contents, bookindex_unordered_hashes, biblio, fn_src, opt_action_bool); + // // text.scroll(contents, bookindex_unordered_hashes, biblio, dochead_make, dochead_meta, fn_src, opt_action_bool); + } + 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_json, dochead_meta_json, fn_src, opt_action_bool); + } + if (opt_action_bool["epub"]) { + writeln("epub processing"); + } + if (opt_action_bool["pdf"]) { + writeln("pdf processing"); + } + if (opt_action_bool["odt"]) { + writeln("odt processing"); + } + if (opt_action_bool["sqlite"]) { + writeln("sqlite processing"); + } + if (opt_action_bool["postgresql"]) { + writeln("pgsql processing"); + } + return return_; + } +} mixin(import("version.txt")); mixin CompileTimeInfo; mixin RgxInit; void main(string[] args) { - struct SDPoutput { - auto hub(S)( - auto ref const S contents, - string[][string][string] bookindex_unordered_hashes, - JSONValue[] biblio, - // JSONValue[string] dochead_make_json, - // JSONValue[string] dochead_meta_json, - string fn_src, - bool[string] opt_action_bool - ) { - mixin ScreenTxtColors; - mixin RgxInit; - mixin SiSUoutputHub; - auto rgx = Rgx(); - uint return_ = 0; - if (opt_action_bool["source"]) { - writeln("sisupod source"); - } - if (opt_action_bool["sisupod"]) { - writeln("sisupod source"); - } - if (opt_action_bool["text"]) { - writeln("text processing"); - // auto text=SDPoutput_text(); - // text.scroll(contents, bookindex_unordered_hashes, biblio, fn_src, opt_action_bool); - // // text.scroll(contents, bookindex_unordered_hashes, biblio, dochead_make, dochead_meta, fn_src, opt_action_bool); - } - 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_json, dochead_meta_json, fn_src, opt_action_bool); - } - if (opt_action_bool["epub"]) { - writeln("epub processing"); - } - if (opt_action_bool["pdf"]) { - writeln("pdf processing"); - } - if (opt_action_bool["odt"]) { - writeln("odt processing"); - } - if (opt_action_bool["sqlite"]) { - writeln("sqlite processing"); - } - if (opt_action_bool["postgresql"]) { - writeln("pgsql processing"); - } - return return_; - } - } mixin SiSUheaderSkel; - mixin SiSUheaderExtract; mixin SiSUbiblio; mixin SiSUrgxInitFlags; - // mixin SiSUconfiguration; + mixin SiSUconfiguration; mixin SiSUmarkupRaw; mixin SiSUdocAbstraction; mixin SiSUoutputDebugs; mixin SiSUoutputHub; mixin ScreenTxtColors; auto raw = MarkupRaw(); - auto head = HeaderDocMetadataMakeJson(); + auto headsdl = HeaderExtractSDL(); auto abs = Abstraction(); auto dbg = SDPoutputDebugs(); auto output = SDPoutput(); @@ -200,6 +204,34 @@ void main(string[] args) { arg_unrecognized ~= " " ~ arg; } } + auto conf = Config(); + auto configuration = conf.readInConfigFile(); + /+ sdlang config +/ + Tag sdl_root_conf; + try { + sdl_root_conf = parseSource(configuration); + } + catch(SDLangParseException e) { + stderr.writeln("SDLang problem with config.sdl content"); + // Error messages of the form: + // myFile.sdl(5:28): Error: Invalid integer suffix. + stderr.writeln(e.msg); + } + debug(sdlang) { + // Value is a std.variant.Algebraic + Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0]; + assert(output_dir_structure_by.type == typeid(string)); + writeln(output_dir_structure_by); + + // Tag person = sdl_root_conf.namespaces["myNamespace"].tags["person"][0]; + // writeln("Name: ", person.attributes["name"][0].value); + // + // int age = person.tags["age"][0].values[0].get!int(); + // writeln("Age: ", age); + + writeln("config SDL:"); + writeln(sdl_root_conf.toSDLDocument()); + } foreach(fn_src; fns_src) { // foreach(fn_src; fns_src) { if (!empty(fn_src)) { @@ -234,13 +266,10 @@ void main(string[] args) { writeln(header_and_content_tuple.length); writeln(sourcefile_content[0]); } - /+ ↓ 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]; + /+ ↓ headers metadata & make sdlang +/ + auto header_sdlang = headsdl.headerSDLang(header); /+ ↓ porcess document, return abstraction as tuple +/ - auto t = abs.abstract_doc_source(sourcefile_content, dochead_make_json, dochead_meta_json); + auto t = abs.abstract_doc_source(sourcefile_content); static assert(!isTypeTuple!(t)); auto doc_ao_contents = t[0]; // contents ~ endnotes ~ bookindex; // static assert(!isIterable!(doc_ao_contents)); @@ -253,8 +282,8 @@ void main(string[] args) { doc_ao_contents, doc_ao_bookindex_unordered_hashes, doc_ao_biblio, - dochead_make_json, - dochead_meta_json, + // doc_ao_make_json, + // doc_ao_metadata_json, fn_src, opt_action_bool ); |