From e280a374991a3a6db3c40fd1fa03a2d9c6fa66eb Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 6 Jun 2017 17:58:10 -0400 Subject: naming mostly --- src/sdp/ao/abstraction.d | 18 +++--- src/sdp/ao/conf_make_meta_native.d | 4 +- src/sdp/ao/conf_make_meta_sdlang.d | 73 ++++++++++++++++-------- src/sdp/ao/defaults.d | 15 ++--- src/sdp/ao/doc_debugs.d | 4 +- src/sdp/ao/read_config_files.d | 17 ++---- src/sdp/ao/read_source_files.d | 6 +- src/sdp/output/hub.d | 15 +++-- src/sdp/output/paths_source.d | 10 ++-- src/sdp/sdp.d | 113 +++++++++++++++++++------------------ 10 files changed, 150 insertions(+), 125 deletions(-) (limited to 'src/sdp') diff --git a/src/sdp/ao/abstraction.d b/src/sdp/ao/abstraction.d index c592436..317f841 100644 --- a/src/sdp/ao/abstraction.d +++ b/src/sdp/ao/abstraction.d @@ -30,8 +30,8 @@ template SiSUabstraction() { enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } auto rgx = Rgx(); auto SiSUabstraction(Fn,O,E)(Fn fn_src, O opts, E env){ - auto sdl_root_configuration = ConfigHub!()("conf.sdl", env); - auto sdl_root_doc_make = ConfigHub!()("sisu_document_make", env); + auto sdl_root_configuration = configRead!()("conf.sdl", env); + auto sdl_root_doc_make = configRead!()("sisu_document_make", env); auto confsdl = HeaderExtractSDL(); auto conf_settings_aa = confsdl.configSettingsSDLangToAAmake(sdl_root_configuration); auto conf_doc_make_aa = confsdl.documentMakeSDLangToAAmake(sdl_root_doc_make); @@ -47,15 +47,15 @@ template SiSUabstraction() { writeln(_header_body_inserts.length[headBody.body_content][0]); } /+ ↓ split header into make and meta +/ - auto _make_and_meta = + auto _make_and_meta_tup = SiSUheaderExtractHub!()(_header_body_inserts[headBody.header], conf_doc_make_aa); - static assert(!isTypeTuple!(_make_and_meta)); - static assert(_make_and_meta.length==2); + static assert(!isTypeTuple!(_make_and_meta_tup)); + static assert(_make_and_meta_tup.length==2); /+ ↓ document abstraction: process document, return abstraction as tuple +/ auto da = SiSUdocAbstraction!()( _header_body_inserts[headBody.body_content], - _make_and_meta[makeMeta.make], - _make_and_meta[makeMeta.meta], + _make_and_meta_tup[makeMeta.make], + _make_and_meta_tup[makeMeta.meta], opts ); static assert(!isTypeTuple!(da)); @@ -80,11 +80,11 @@ template SiSUabstraction() { return _k; } auto dochead_make() { - string[string][string] _k = _make_and_meta[makeMeta.make]; + string[string][string] _k = _make_and_meta_tup[makeMeta.make]; return _k; } auto dochead_meta() { - string[string][string] _k = _make_and_meta[makeMeta.meta]; + string[string][string] _k = _make_and_meta_tup[makeMeta.meta]; return _k; } auto src_path_info() { diff --git a/src/sdp/ao/conf_make_meta_native.d b/src/sdp/ao/conf_make_meta_native.d index 8954c9a..aae0b4d 100644 --- a/src/sdp/ao/conf_make_meta_native.d +++ b/src/sdp/ao/conf_make_meta_native.d @@ -286,8 +286,8 @@ template SiSUheaderExtractNative() { ]; string[string] an_object; int[string] line_occur; - auto dochead_make = make_aa; - auto dochead_meta = meta_aa; + auto dochead_make = conf_aa_empty; + auto dochead_meta = meta_aa_empty; auto set_header = HeaderDocMetadataAndMakeNativeToAA(); char[][] source_header_arr = (cast(char[]) src_header).split(rgx.newline_eol_delimiter); diff --git a/src/sdp/ao/conf_make_meta_sdlang.d b/src/sdp/ao/conf_make_meta_sdlang.d index 567853e..7e7dd62 100644 --- a/src/sdp/ao/conf_make_meta_sdlang.d +++ b/src/sdp/ao/conf_make_meta_sdlang.d @@ -20,20 +20,35 @@ template SiSUheaderExtractSDLang() { mixin SiSUregisters; mixin SiSUrgxInit; auto rgx = Rgx(); - private auto sdlangToAAmake(C,Tag)(C conf, Tag conf_sdlang) { + private auto sdlangToAAheaderMakeMeta(C,Tag)(C conf, Tag conf_sdlang) { debug(asserts){ static assert(is(typeof(conf) == string[string][string])); } foreach (maintag, subtags; conf) { foreach (subtag, content; subtags) { - if (!(conf_sdlang.maybe.tags[maintag].empty)) { - if (!(conf_sdlang.tags[maintag][0].maybe.attributes[subtag].empty) - && (conf_sdlang.tags[maintag][0].attributes[subtag][0].value.length > 0)) { + if (maintag in conf_sdlang.maybe.tags) { + Tag _maintag = conf_sdlang.getTag(maintag); + if ((subtag in _maintag.maybe.tags) + && (_maintag.getTagValues(subtag).length > 0)) { debug(headersdlang) { - writeln(conf_sdlang.tags[maintag][0].attributes[subtag][0].value); + writeln(__LINE__, ": ", maintag, ":", subtag, ": ", _maintag.getTagValues(subtag)[0]); + } + if (_maintag.getTagValues(subtag).length == 1) { + conf[maintag][subtag] = + (_maintag.getTagValues(subtag)[0]).to!string; + } else if (_maintag.getTagValues(subtag).length > 1) { + foreach (st; _maintag.getTagValues(subtag)) { + conf[maintag][subtag] ~= + st.to!string ~ ";"; + } + } + } else if ((subtag in _maintag.maybe.attributes) + && (_maintag.maybe.attributes[subtag][0].value.length > 0)) { + debug(headersdlang) { + writeln(__LINE__, ": ", maintag, ":", subtag, ": ", conf_sdlang.tags[maintag][0].attributes[subtag][0].value); } conf[maintag][subtag] = - to!string(conf_sdlang.tags[maintag][0].attributes[subtag][0].value); + (conf_sdlang.tags[maintag][0].attributes[subtag][0].value).to!string; } } } @@ -41,11 +56,11 @@ template SiSUheaderExtractSDLang() { return conf; } private auto configSettingsSDLangToAAmake(Tag)(Tag conf_sdlang) { - auto conf = sdlangToAAmake(conf_aa, conf_sdlang); + auto conf = sdlangToAAheaderMakeMeta(conf_aa_empty, conf_sdlang); return conf; } private auto documentMakeSDLangToAAmake(Tag)(Tag document_make_sdlang) { - auto dochead_make = sdlangToAAmake(make_aa, document_make_sdlang); + auto dochead_make = sdlangToAAheaderMakeMeta(conf_aa_empty, document_make_sdlang); return dochead_make; } final private auto headerMakeSDLang(Hs)(Hs src_header) { @@ -73,7 +88,19 @@ template SiSUheaderExtractSDLang() { } debug(sdlang) { writeln("header SDL:"); - writeln(sdl_root_header.toSDLDocument()); + writeln(__LINE__, ": ", sdl_root_header.toSDLDocument()); + writeln(__LINE__, ": ", sdl_root_header.maybe.namespaces); + writeln("header make sdlang: ", sdl_root_header.toSDLDocument()); + writeln(__LINE__, ": ", sdl_root_header.getTagValues("title")); + writeln(__LINE__, ": ", sdl_root_header.getTagValues("creator")); + Tag creator = sdl_root_header.getTag("creator"); + if (creator !is null) { + if ("author" in creator.maybe.tags) { + writeln(__LINE__, ": ", creator.getTagValues("author")); + } else if ("author" in creator.maybe.attributes) { + writeln(__LINE__, ": ", creator.maybe.attributes["author"][0].value); + } + } } return sdl_root_header; } @@ -91,26 +118,28 @@ template SiSUheaderExtractSDLang() { } /+ get sdlang tags +/ auto header_sdlang=headerMakeSDLang(to!string(header_clean)); - debug(sdlang) { - writeln("--------------"); - stdout.rawWrite( header_sdlang.toSDLDocument() ); - writeln("--------------"); - Value test = header_sdlang.tags["title"][0].values[0]; - assert(test == typeid(string)); - // writeln(header_sdlang.maybe.tags["title"]); - // writeln(header_sdlang.maybe.tags["title"][0].maybe.attributes["subtitle"]); - } return header_sdlang; // sdlang.ast.Tag } private auto headerSDLangToAAmake(Tag,Ma)(Tag header_sdlang, Ma dochead_make) { debug(asserts){ static assert(is(typeof(dochead_make) == string[string][string])); } - dochead_make = sdlangToAAmake(dochead_make, header_sdlang); - auto dochead_meta = sdlangToAAmake(meta_aa, header_sdlang); + dochead_make = sdlangToAAheaderMakeMeta(dochead_make, header_sdlang); + auto dochead_meta = sdlangToAAheaderMakeMeta(meta_aa_empty, header_sdlang); if (dochead_meta["title"]["main"].empty) { - dochead_meta["title"]["main"] = - to!string(header_sdlang.maybe.tags["title"][0].values[0]); + { + Tag _maintag = header_sdlang.getTag("title"); + if (_maintag !is null) { + if ("main" in _maintag.maybe.tags) { + dochead_meta["title"]["main"] = + to!string(_maintag.getTagValues("main")); + } else if ("main" !in _maintag.maybe.attributes) { + writeln(__LINE__, ": ", _maintag.values[0]); + dochead_meta["title"]["main"] = + (_maintag.values[0]).to!string; // test that this exists + } + } + } } if (!(dochead_meta["title"]["subtitle"].empty) && (dochead_meta["title"]["sub"].empty)) { diff --git a/src/sdp/ao/defaults.d b/src/sdp/ao/defaults.d index 4a989b6..caee701 100644 --- a/src/sdp/ao/defaults.d +++ b/src/sdp/ao/defaults.d @@ -22,7 +22,7 @@ template SiSUregisters() { std.uni, std.utf, std.conv : to; - string[string][string] conf_aa() { + string[string][string] conf_aa_empty() { auto conf_ = [ "webserv": [ "url_root" : "", @@ -77,12 +77,7 @@ template SiSUregisters() { "action" : "", "db" : "", "title" : "" - ] - ]; - return conf_; - } - string[string][string] make_aa() { - auto make_ = [ + ], "make": [ "bold" : "", "breaks" : "", @@ -98,11 +93,11 @@ template SiSUregisters() { "num_depth" : "", "substitute" : "", "texpdf_font" : "" - ] + ], ]; - return make_; + return conf_; } - string[string][string] meta_aa() { + string[string][string] meta_aa_empty() { auto meta_ = [ "classify": [ "dewey" : "", diff --git a/src/sdp/ao/doc_debugs.d b/src/sdp/ao/doc_debugs.d index 419f5cd..87a64f4 100644 --- a/src/sdp/ao/doc_debugs.d +++ b/src/sdp/ao/doc_debugs.d @@ -60,7 +60,7 @@ template SiSUdebugs() { __FILE__, __LINE__, ); - foreach (obj; contents) { + foreach (obj; contents[key]) { if (obj.use != "empty") { writefln( "[%s][%s]\n%s", @@ -235,7 +235,7 @@ template SiSUdebugs() { __FILE__, __LINE__, ); - foreach (obj; contents) { + foreach (obj; contents[key]) { if (obj.use != "empty") { writefln( "* [%s][%s] %s", diff --git a/src/sdp/ao/read_config_files.d b/src/sdp/ao/read_config_files.d index 57213c4..8f525f3 100644 --- a/src/sdp/ao/read_config_files.d +++ b/src/sdp/ao/read_config_files.d @@ -4,12 +4,12 @@ ao_config_files.d +/ module sdp.ao.read_config_files; -template ConfigIn() { +template configIn() { import sdp.ao, std.file, std.path; - final string ConfigIn(C,E)(C conf_sdl, E env) { + final string configIn(C,E)(C conf_sdl, E env) { string dot_pwd = chainPath(to!string(env["pwd"]), ".sisu").array; string underscore_pwd = chainPath(to!string(env["pwd"]), "_sisu").array; string dot_home = chainPath(to!string(env["home"]), ".sisu").array; @@ -61,26 +61,19 @@ template ConfigSDLang() { stderr.writeln("SDLang problem with content for ", conf_sdl_filename); stderr.writeln(e.msg); } - debug(sdlang) { - 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); - writeln("conf SDL:"); - writeln(sdl_root_conf.toSDLDocument()); - } return sdl_root_conf; } } /+ +/ -template ConfigHub() { +template configRead() { import sdp.ao, std.file, std.path; - final auto ConfigHub(C,E)(C conf_sdl, E env) { - auto configuration = ConfigIn!()(conf_sdl, env); + final auto configRead(C,E)(C conf_sdl, E env) { + auto configuration = configIn!()(conf_sdl, env); auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); return sdl_root; } diff --git a/src/sdp/ao/read_source_files.d b/src/sdp/ao/read_source_files.d index 3b348f3..db20cfd 100644 --- a/src/sdp/ao/read_source_files.d +++ b/src/sdp/ao/read_source_files.d @@ -115,14 +115,14 @@ template SiSUrawMarkupContent() { return t; } final char[][] getInsertMarkupSourceContentRawLineArray( - in char[] fn_src, + in char[] fn_src_insert, Regex!(char) rgx_file ) { enforce( - fn_src.match(rgx_file), + fn_src_insert.match(rgx_file), "not a sisu markup filename" ); - auto source_txt_str = readInMarkupSource(fn_src); + auto source_txt_str = readInMarkupSource(fn_src_insert); auto source_line_arr = markupSourceLineArray(source_txt_str); return source_line_arr; } diff --git a/src/sdp/output/hub.d b/src/sdp/output/hub.d index fd64851..2a1221f 100644 --- a/src/sdp/output/hub.d +++ b/src/sdp/output/hub.d @@ -27,9 +27,11 @@ template outputHub() { { writeln("sisupod source processing... "); } SiSUpod!()(doc_matters); if ((doc_matters.opt_action["verbose"]) + && (doc_matters.opt_action["debug"]) && (doc_matters.opt_action["source"])) { writeln("sisu source done"); } if ((doc_matters.opt_action["verbose"]) + && (doc_matters.opt_action["debug"]) && (doc_matters.opt_action["sisupod"])) { writeln("sisupod done"); } } @@ -40,24 +42,27 @@ template outputHub() { if (doc_matters.opt_action["html"]) { if ((doc_matters.opt_action["verbose"])) { writeln("html scroll processing... "); } outputHTML!().scroll(doc_abstraction, doc_matters); - if ((doc_matters.opt_action["verbose"])) { writeln("html scroll done"); } + if ((doc_matters.opt_action["verbose"]) && (doc_matters.opt_action["debug"])) { writeln("html scroll done"); } if ((doc_matters.opt_action["verbose"])) { writeln("html seg processing... "); } outputHTML!().seg(doc_abstraction, doc_matters); - if ((doc_matters.opt_action["verbose"])) { writeln("html seg done"); } + if ((doc_matters.opt_action["verbose"]) && (doc_matters.opt_action["debug"])) { writeln("html seg done"); } + outputHTML!().css(doc_matters); } else if (doc_matters.opt_action["html-seg"]) { if ((doc_matters.opt_action["verbose"])) { writeln("html seg processing... "); } outputHTML!().seg(doc_abstraction, doc_matters); - if ((doc_matters.opt_action["verbose"])) { writeln("html seg done"); } + if ((doc_matters.opt_action["verbose"]) && (doc_matters.opt_action["debug"])) { writeln("html seg done"); } + outputHTML!().css(doc_matters); } else if (doc_matters.opt_action["html-scroll"]) { if ((doc_matters.opt_action["verbose"])) { writeln("html scroll processing... "); } outputHTML!().scroll(doc_abstraction, doc_matters); - if ((doc_matters.opt_action["verbose"])) { writeln("html scroll done"); } + if ((doc_matters.opt_action["verbose"]) && (doc_matters.opt_action["debug"])) { writeln("html scroll done"); } + outputHTML!().css(doc_matters); } if (doc_matters.opt_action["epub"]) { if ((doc_matters.opt_action["verbose"])) { writeln("epub3 processing... "); } outputEPub3!()(doc_abstraction, doc_matters); // epub.css_write; - if ((doc_matters.opt_action["verbose"])) { writeln("epub3 done"); } + if ((doc_matters.opt_action["verbose"]) && (doc_matters.opt_action["debug"])) { writeln("epub3 done"); } } if (doc_matters.opt_action["pdf"]) { /+ mixin outputPDF; +/ diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 7658df5..80e2c1a 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -14,7 +14,7 @@ template SiSUpathsSRC() { auto rgx = Rgx(); auto SiSUpathsSRC(D,Fn)( D _pwd, - Fn _fn_src, + Fn _fn_src_and_relative_path, ) { struct SisuSrcPaths { auto pwd() { @@ -23,10 +23,10 @@ template SiSUpathsSRC() { auto language() { // use command line info as well? string _k; - if (auto m = _fn_src.match(rgx.language_code_and_filename)) { + if (auto m = _fn_src_and_relative_path.match(rgx.language_code_and_filename)) { _k = m.captures[1]; } else { - _k = "en"; + _k = "xx"; // original default was "en" but is not known } return _k; } @@ -49,10 +49,10 @@ template SiSUpathsSRC() { return text_root.chainPath(language).array; } auto doc_src_with_relative_path() { - return pwd.chainPath(_fn_src).array; + return pwd.chainPath(_fn_src_and_relative_path).array; } auto doc_src_fn() { - return _fn_src.baseName.array; + return _fn_src_and_relative_path.baseName.array; } } return SisuSrcPaths(); diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d index 3816f9b..60d56f9 100755 --- a/src/sdp/sdp.d +++ b/src/sdp/sdp.d @@ -147,68 +147,71 @@ void main(string[] args) { "pwd" : environment["PWD"], "home" : environment["HOME"], ]; - auto sdl_root_configuration = ConfigHub!()("conf.sdl", env); - auto sdl_root_doc_make = ConfigHub!()("sisu_document_make", env); + auto sdl_root_configuration = configRead!()("conf.sdl", env); + auto sdl_root_doc_make = configRead!()("sisu_document_make", env); auto confsdl = HeaderExtractSDL(); auto conf_settings_aa = confsdl.configSettingsSDLangToAAmake(sdl_root_configuration); auto conf_doc_make_aa = confsdl.documentMakeSDLangToAAmake(sdl_root_doc_make); - foreach(fn_src; fns_src) { - if (!empty(fn_src)) { - scope(success) { - debug(checkdoc) { - writefln( - "%s\n%s", - "~ document complete, ok ~", - "------------------------------------------------------------------", - ); + + if (fns_src.length > 0) { + foreach(fn_src; fns_src) { + if (!empty(fn_src)) { + scope(success) { + debug(checkdoc) { + writefln( + "%s\n%s", + "~ document complete, ok ~", + "------------------------------------------------------------------", + ); + } } - } - scope(failure) { - debug(checkdoc) { - stderr.writefln( - "~ document run failure ~ (%s v%s)\n\t%s", - __VENDOR__, __VERSION__, - fn_src - ); + scope(failure) { + debug(checkdoc) { + stderr.writefln( + "~ document run failure ~ (%s v%s)\n\t%s", + __VENDOR__, __VERSION__, + fn_src + ); + } } - } - enforce( - fn_src.match(rgx.src_pth), - "not a sisu markup filename" - ); - auto t = - SiSUabstraction!()(fn_src, opts, env); - static assert(!isTypeTuple!(t)); - static assert(t.length==2); - auto doc_abstraction = t[dAM.abstraction]; - auto doc_matters = t[dAM.matters]; - /+ ↓ debugs +/ - if (doc_matters.opt_action["verbose"]) { - SiSUabstractionSummary!()(doc_abstraction, doc_matters); - } - /+ ↓ debugs +/ - if ((doc_matters.opt_action["debug"]) - || (doc_matters.opt_action["verbose"]) - ) { - SiSUdebugs!()(doc_abstraction, doc_matters); - } - /+ ↓ output hub +/ - if (!(opts["skip-output"])) { - outputHub!()(doc_abstraction, doc_matters); - } - scope(exit) { - debug(checkdoc) { - writefln( - "processed file: %s", - fn_src - ); + enforce( + fn_src.match(rgx.src_pth), + "not a sisu markup filename" + ); + auto t = + SiSUabstraction!()(fn_src, opts, env); + static assert(!isTypeTuple!(t)); + static assert(t.length==2); + auto doc_abstraction = t[dAM.abstraction]; + auto doc_matters = t[dAM.matters]; + /+ ↓ debugs +/ + if (doc_matters.opt_action["verbose"]) { + SiSUabstractionSummary!()(doc_abstraction, doc_matters); + } + /+ ↓ debugs +/ + if ((doc_matters.opt_action["debug"]) + || (doc_matters.opt_action["verbose"]) + ) { + SiSUdebugs!()(doc_abstraction, doc_matters); + } + /+ ↓ output hub +/ + if (!(opts["skip-output"])) { + outputHub!()(doc_abstraction, doc_matters); + } + scope(exit) { + debug(checkdoc) { + writefln( + "processed file: %s", + fn_src + ); + } + destroy(fn_src); } - destroy(fn_src); + } else { + /+ no recognized filename provided +/ + writeln("no recognized filename"); + break; // terminate, stop } - } else { - /+ no recognized filename provided +/ - writeln("no recognized filename"); - break; // terminate, stop } } } -- cgit v1.2.3