From 524baa6ddd5f9cb49b1c5b015fbd6ef75ff72968 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 25 Jan 2018 17:13:52 -0500 Subject: paths, further adjustments --- src/sdp/meta/metadoc.d | 111 +++++------------------- src/sdp/meta/read_config_files.d | 12 +-- src/sdp/meta/rgx.d | 1 + src/sdp/output/epub3.d | 14 +-- src/sdp/output/paths_output.d | 2 +- src/sdp/output/paths_source.d | 67 ++++++++++----- src/sdp/output/rgx.d | 1 + src/sdp/output/source_sisupod.d | 46 +++++----- src/sdp/output/sqlite.d | 30 ++++--- src/sdp/output/sqlite_discrete.d | 30 ++++--- src/sdp/sdp.d | 179 +++++++++++++++++---------------------- 11 files changed, 224 insertions(+), 269 deletions(-) (limited to 'src') diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d index 129e53c..cbc5d51 100644 --- a/src/sdp/meta/metadoc.d +++ b/src/sdp/meta/metadoc.d @@ -42,8 +42,7 @@ template SiSUabstraction() { /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ debug(steps) { - writeln(__LINE__, ":", __FILE__, - ": step1 commence → (get document header & body & insert file list & if needed image list)" + writeln("step1 commence → (get document header & body & insert file list & if needed image list)" ); } auto _header_body_insertfilelist_imagelist @@ -51,7 +50,7 @@ template SiSUabstraction() { static assert(!isTypeTuple!(_header_body_insertfilelist_imagelist)); static assert(_header_body_insertfilelist_imagelist.length==4); debug(steps) { - writeln(__LINE__, ":", __FILE__, ": step1 complete"); + writeln("- step1 complete"); } debug(header_and_body) { writeln(header); @@ -60,21 +59,19 @@ template SiSUabstraction() { } /+ ↓ split header into make and meta +/ debug(steps) { - writeln(__LINE__, ":", __FILE__, - ": step2 commence → (doc header: make & meta as struct)" - ); + writeln("step2 commence → (read document header - toml or sdlang, return struct)"); } auto _make_and_meta_struct = docHeaderMakeAndMetaTupExtractAndConvertToStruct!()( conf_files_composite_make, _header_body_insertfilelist_imagelist[headBody.header] - ); // breakage ... + ); debug(steps) { - writeln(__LINE__, ":", __FILE__, ": step2 complete"); + writeln("- step2 complete"); } /+ ↓ document abstraction: process document, return abstraction as tuple +/ debug(steps) { - writeln(__LINE__, ":", __FILE__, ": step3 commence → (document abstraction (da); da keys; segnames; doc_matters)"); + writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters)"); } auto da = SiSUdocAbstraction!()( _header_body_insertfilelist_imagelist[headBody.body_content], @@ -89,15 +86,14 @@ template SiSUabstraction() { string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; auto _images = da[docAbst.images]; debug(steps) { - writeln(__LINE__, ":", __FILE__, ": step3 complete"); + writeln("- step3 complete"); } debug(steps) { - writeln(__LINE__, ":", __FILE__, ": step4 commence → (doc_matters)"); + writeln("step4 commence → (doc_matters)"); } struct DocumentMatters { auto conf_make_meta() { // TODO meld with all make instructions - auto _k = _make_and_meta_struct; - return _k; + return _make_and_meta_struct; } auto env() { struct Env_ { @@ -123,51 +119,15 @@ template SiSUabstraction() { return Opt_(); } auto src() { + return _manifest.src; + } + auto src_path_info() { + return SiSUpathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path + } + auto srcs() { struct SRC_ { - auto is_pod() { - return _manifest.src.is_pod; - } - auto filename() { - return _manifest.src.filename; - } - auto language() { - return _manifest.src.lng; - } - auto path_info() { - auto _k = SiSUpathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path - return _k; - } - auto file_with_absolute_path() { - auto _k = _manifest.src.file_with_absolute_path; - return _k; - } - auto absolute_path_to_src() { - auto _k = _manifest.src.absolute_path_to_src; - return _k; - } - auto base_dir() { - auto _k = _manifest.src.base_dir; - return _k; - } - auto base_parent_dir_path() { - auto _k = _manifest.src.base_parent_dir_path; - return _k; - } - auto base_dir_path() { - auto _k = _manifest.src.base_dir_path; - return _k; - } - auto media_dir_path() { - auto _k = _manifest.src.media_dir_path; - return _k; - } - auto base_parent_dir() { - auto _k = _manifest.src.base_parent_dir; - return _k; - } auto file_insert_list() { - string[] _k = _header_body_insertfilelist_imagelist[headBody.insert_file_list]; - return _k; + return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; } auto image_list() { return _images; @@ -176,48 +136,19 @@ template SiSUabstraction() { return SRC_(); } auto pod() { - struct Pod_ { - auto src_is_pod() { - return _manifest.pod.src_is_pod; - } - auto manifest_list_of_filenames() { - return _manifest.pod.manifest_list_of_filenames; - } - auto manifest_list_of_languages() { - return _manifest.pod.manifest_list_of_languages; - } - auto manifest_filename() { - return _manifest.pod.manifest_filename; - } - auto manifest_path() { - return _manifest.pod.manifest_path; - } - auto manifest_file_with_path() { - return _manifest.pod.manifest_file_with_path; - } - auto config_dirs() { - return _manifest.pod.config_dirs; - } - auto image_dirs() { - return _manifest.pod.image_dirs; - } - } - return Pod_(); + return _manifest.pod; } auto xml() { struct XML_ { auto keys_seq() { /+ contains .seg & .scroll sequences +/ - auto _k = _document_section_keys_sequenced; - return _k; + return _document_section_keys_sequenced; } string[] segnames() { - string[] _k = _doc_html_segnames; - return _k; + return _doc_html_segnames; } string[] segnames_lv_0_to_4() { - string[] _k = _doc_epub_segnames_0_4; - return _k; + return _doc_epub_segnames_0_4; } } return XML_(); @@ -228,7 +159,7 @@ template SiSUabstraction() { } auto doc_matters = DocumentMatters(); debug(steps) { - writeln(__LINE__, ":", __FILE__, ": step4 complete"); + writeln("- step4 complete"); } auto t = tuple(doc_abstraction, doc_matters); static assert(t.length==2); diff --git a/src/sdp/meta/read_config_files.d b/src/sdp/meta/read_config_files.d index 52446e8..15a7a67 100644 --- a/src/sdp/meta/read_config_files.d +++ b/src/sdp/meta/read_config_files.d @@ -16,8 +16,8 @@ static template configInSite() { auto possible_config_path_locations = conf_file_details.possible_config_path_locations.local_site; string config_file_str; debug(io) { - writeln("in config filename: ", conf_sdl); - writeln("in config possible path locations: ", possible_config_path_locations); + writeln("WARNING (io debug) in config filename: ", conf_sdl); + writeln("WARNING (io debug) in config possible path locations: ", possible_config_path_locations); } foreach(pth; possible_config_path_locations) { auto conf_file = asNormalizedPath(chainPath(to!string(pth), conf_sdl)).array; @@ -27,7 +27,7 @@ static template configInSite() { try { if (exists(conf_file)) { debug(io) { - writeln("in config file found: ", conf_file); + writeln("WARNING (io debug) in config file found: ", conf_file); } config_file_str = conf_file.readText; break; @@ -53,8 +53,8 @@ static template configInDoc() { auto possible_config_path_locations = conf_file_details.possible_config_path_locations.document; string config_file_str; debug(io) { - writeln("in config filename: ", conf_sdl); - writeln("in config possible path locations: ", possible_config_path_locations); + writeln("WARNING (io debug) in config filename: ", conf_sdl); + writeln("WARNING (io debug) in config possible path locations: ", possible_config_path_locations); } foreach(pth; possible_config_path_locations) { auto conf_file = asNormalizedPath(chainPath(to!string(pth), conf_sdl)).array; @@ -64,7 +64,7 @@ static template configInDoc() { try { if (exists(conf_file)) { debug(io) { - writeln("in config file found: ", conf_file); + writeln("WARNING (io debug) in config file found: ", conf_file); } config_file_str = conf_file.readText; break; diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d index c196ad2..fe9e36d 100644 --- a/src/sdp/meta/rgx.d +++ b/src/sdp/meta/rgx.d @@ -212,6 +212,7 @@ static template SiSUrgxInit() { static src_fn_find_inserts = ctRegex!(`^(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[im])$`); static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[ti])$`); static src_base_parent_dir_name = ctRegex!(`[/](?P(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure + static src_formalised_file_path_parts = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalized dir structure /+ inline markup footnotes endnotes +/ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d index 3c8eb4d..131d6f9 100644 --- a/src/sdp/output/epub3.d +++ b/src/sdp/output/epub3.d @@ -84,7 +84,7 @@ template outputEPub3() { content ~= parts["manifest_documents"]; // TODO sort jpg & png content ~= " " ~ "" ~ "\n "; - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { content ~= format(q"¶ ¶", image.baseName.stripExtension, @@ -712,24 +712,24 @@ template outputEPub3() { createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/_sisu/image (images) +/ - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { debug(epub_output) { - if (exists(doc_matters.src.path_info.image_root ~ "/" ~ image)) { - (doc_matters.src.path_info.image_root ~ "/" ~ image) + if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { + (doc_matters.src_path_info.image_root ~ "/" ~ image) .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); } } } - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { debug(epub_output) { debug(epub_images) { writeln( - doc_matters.src.path_info.image_root, image, " -> ", + doc_matters.src_path_info.image_root, image, " -> ", pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image ); } } - auto fn_src = doc_matters.src.path_info.image_root ~ image; + auto fn_src = doc_matters.src_path_info.image_root ~ image; auto fn_out = pth_epub3.doc_oebps_image(doc_matters.src.filename).to!string ~ "/" ~ image; if (exists(fn_src)) { { diff --git a/src/sdp/output/paths_output.d b/src/sdp/output/paths_output.d index 4a1c2e4..537de45 100644 --- a/src/sdp/output/paths_output.d +++ b/src/sdp/output/paths_output.d @@ -211,7 +211,7 @@ template SiSUpathsSQLite() { return fn_src.baseName.stripExtension; } string base() { - return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; + return asNormalizedPath((out_pth.output_root).chainPath(base_dir)).array; } string seg(string fn_src) { return asNormalizedPath(base.chainPath(base_filename(fn_src))).array; diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index d141b86..731fff3 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -24,19 +24,30 @@ template PodManifest() { } auto pod_manifest_path() { string _manifest_path; - if (isValidPath(_pth) && _pth.isDir - && ((_pth.chainPath(pod_manifest_filename).array).isFile)) { + if ((isValidPath(_pth) && exists(_pth)!=0 && _pth.isDir) + && (exists(_pth.chainPath(pod_manifest_filename).array)!=0 + && (_pth.chainPath(pod_manifest_filename).array).isFile)) { _manifest_path = _pth; } else if (_pth.match(rgx.src_pth_contents) - && (_pth.isFile)) { + && exists(_pth)!=0 && _pth.isDir && (_pth.isFile)) { _manifest_path = dirName(_pth); - // } else { // _manifest_path = ""; + } else { + _manifest_path = _pth; // _manifest_path = null; } return _manifest_path; } - auto pod_manifest_file_with_path() { - string _manifest_path_and_file = pod_manifest_path.chainPath(pod_manifest_filename).array; - return _manifest_path_and_file; + string pod_manifest_file_with_path() { + string _k; + if (exists(pod_manifest_path.chainPath(pod_manifest_filename).array)!=0) { + _k = pod_manifest_path.chainPath(pod_manifest_filename).array; + } else if (exists(pod_manifest_path)!=0) { + _k = pod_manifest_path; + } + if (exists(_k)==0) { + writeln("ERROR >> Processing Skipped! Manifest not found: ", _k); + _k = null; + } + return _k; } } return ManifestFile_(); @@ -139,6 +150,9 @@ template PathMatters() { } return _k; } + auto language() { + return lng(); + } auto file_with_absolute_path() { string _pth = _env["pwd"].chainPath(path_and_fn).array; return _pth; @@ -153,13 +167,15 @@ template PathMatters() { auto m = (absolute_path_to_src) .match(regex(r"[/](?P(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) ) { - _dir = asAbsolutePath(path_and_fn.chainPath("../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../")).array; assert(_dir == m.captures["dir"]); } else { - _dir = asAbsolutePath(path_and_fn.chainPath("../../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../../")).array; assert(_dir == absolute_path_to_src.match(rgx.src_base_parent_dir_name).captures["dir"]); } - writeln("--> ", _dir); + if ((_opt_actions.debug_do)) { + writeln("--> (base_dir) ", _dir); + } return _dir; } auto base_parent_dir_path() { @@ -168,35 +184,42 @@ template PathMatters() { auto m = (absolute_path_to_src) .match(regex(r"[/](?P(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) ) { - _dir = asAbsolutePath(path_and_fn.chainPath("../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../")).array; } else { - _dir = asAbsolutePath(path_and_fn.chainPath("../../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../../")).array; } return _dir; } auto base_dir_path() { // looks like there is work to do string _dir; - if ( // TODO this should catch generated --source sisupod, untested, needs manifest + if ( auto m = (absolute_path_to_src) - .match(regex(r"[/](?P(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) + .match(rgx.src_formalised_file_path_parts) + ) { + _dir = asNormalizedPath(m.captures["pth"]).array; + } else if ( // TODO this should catch generated --source sisupod, untested, needs manifest + auto m = (absolute_path_to_src) + .match(regex(r"[/](?P(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) ) { - _dir = asAbsolutePath(path_and_fn.chainPath("../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../")).array; } else { - _dir = asAbsolutePath(path_and_fn.chainPath("../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../")).array; + } + if ((_opt_actions.debug_do)) { + writeln("--> (base_dir_path) ", _dir); } - writeln("--> ", _dir); return _dir; } auto media_dir_path() { // TODO rework, can base directly on src fn path - auto _dir = asAbsolutePath(base_dir_path.chainPath("media")).array; + string _dir = asNormalizedPath(base_dir_path.chainPath("media")).array; return _dir; } auto image_dir_path() { - auto _dir = asAbsolutePath(base_dir_path.chainPath("media/image")).array; + string _dir = asNormalizedPath(base_dir_path.chainPath("media/image")).array; return _dir; } auto conf_dir_path() { - auto _dir = asAbsolutePath(base_dir_path.chainPath("conf")).array; + auto _dir = asNormalizedPath(base_dir_path.chainPath("conf")).array; return _dir; } auto base_parent_dir() { @@ -209,7 +232,9 @@ template PathMatters() { } else { _dir = (absolute_path_to_src).match(rgx.src_base_parent_dir_name).captures["dir"]; } - writeln("--> ", _dir); + if ((_opt_actions.debug_do)) { + writeln("--> (base_parent_dir) ", _dir); + } return _dir; } auto config_dirs() { // TODO diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index 1c32351..c962937 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -31,6 +31,7 @@ static template SiSUoutputRgxInit() { static src_fn_find_inserts = ctRegex!(`^(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[im])$`); static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[ti])$`); static src_base_parent_dir_name = ctRegex!(`[/](?P(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure + static src_formalised_file_path_parts = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalized dir structure /+ inline markup footnotes endnotes +/ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index c48a0e3..4e3bfc1 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -16,8 +16,8 @@ template SiSUpod() { } mixin SiSUoutputRgxInit; string pwd = doc_matters.env.pwd; - auto src_path_info = doc_matters.src.path_info; - auto pth_sisudoc_src = doc_matters.src.path_info; + auto src_path_info = doc_matters.src_path_info; + auto pth_sisudoc_src = doc_matters.src_path_info; auto pths_sisupod = SiSUpathsSisupods!()(doc_matters); mixin SiSUlanguageCodes; auto lang = Lang(); @@ -58,14 +58,17 @@ template SiSUpod() { auto zip = new ZipArchive(); auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.src.filename).zpod; { /+ bundle images +/ - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { debug(sisupodimages) { writeln( pth_sisudoc_src.image_root.to!string, "/", image, " -> ", pths_sisupod.image_root(doc_matters.src.filename).zpod, "/", image ); } - auto fn_src_in = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; + auto fn_src_in = ((doc_matters.src.is_pod) + ? doc_matters.src.image_dir_path + : pth_sisudoc_src.image_root).to!string + ~ "/" ~ image; auto fn_src_out_sisupod_zip_base = pths_sisupod.image_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ image; @@ -74,7 +77,7 @@ template SiSUpod() { ~ "/" ~ image; if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } if (doc_matters.opt.action.source) { fn_src_in.copy(fn_src_out_filesystem); @@ -89,13 +92,15 @@ template SiSUpod() { } } else { if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (image): ", fn_src_in); + writeln("WARNING (io) src out NOT found (image): ", fn_src_in); } } } } { /+ bundle sisu_document_make +/ - auto fn_src_in - = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make) + auto fn_src_in = ((doc_matters.src.is_pod) + ? doc_matters.src.conf_dir_path + : pth_sisudoc_src.conf_root).to!string + ~ "/" ~ "sisu_document_make"; auto fn_src_out_sisupod_zip_base = pths_sisupod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "sisu_document_make"; auto fn_src_out_filesystem @@ -103,7 +108,7 @@ template SiSUpod() { ~ "/" ~ "sisu_document_make"; // TODO if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } if (doc_matters.opt.action.source) { fn_src_in.copy(fn_src_out_filesystem); @@ -117,8 +122,9 @@ template SiSUpod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (document make): ", fn_src_in); + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); } } } { /+ TODO bundle primary file +/ @@ -133,7 +139,7 @@ template SiSUpod() { string[] filelist_src_zpod_arr; if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } filelist_src_out_sisupod_arr ~= fn_src_out_sisupod_zip_base; filelist_src_zpod_arr ~= fn_src_out_inside_pod; @@ -154,13 +160,14 @@ template SiSUpod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (markup source): ", fn_src_in); + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (markup source): ", fn_src_in); } } } { /+ bundle insert files +/ - if (doc_matters.src.file_insert_list.length > 0) { - foreach (insert_file; doc_matters.src.file_insert_list) { + if (doc_matters.srcs.file_insert_list.length > 0) { + foreach (insert_file; doc_matters.srcs.file_insert_list) { debug(sisupod) { writeln( insert_file, " -> ", @@ -186,7 +193,7 @@ template SiSUpod() { ).filesystem_open_zpod.to!string; if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } if (doc_matters.opt.action.source) { fn_src_in.copy(fn_src_out_filesystem); @@ -201,8 +208,9 @@ template SiSUpod() { createZipFile!()(fn_sisupod, zip.build()); } } else { - if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (insert file): ", fn_src_in); + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); } } } diff --git a/src/sdp/output/sqlite.d b/src/sdp/output/sqlite.d index 4abe3d1..25940cc 100644 --- a/src/sdp/output/sqlite.d +++ b/src/sdp/output/sqlite.d @@ -457,6 +457,7 @@ template SQLiteBuildTablesAndPopulate() { auto ref I doc_matters, ) { auto pth_sqlite = SiSUpathsSQLite!()(doc_matters.output_path, doc_matters.src.language); + pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file(doc_matters.env.pwd.baseName)); // auto db = Database(":memory:"); // open database in memory if (doc_matters.opt.action.sqlite_create) { @@ -816,7 +817,10 @@ template SQLiteBuildTablesAndPopulate() { // insert_metadata.bind(":links", doc_matters.conf_make_meta.meta.links); insert_metadata.execute(); insert_metadata.reset(); /+ watch +/ - writeln("sql statement executed"); + writeln(" ", pth_sqlite.sqlite_file(doc_matters.env.pwd.baseName)); + if ((doc_matters.opt.action.verbose)) { + writeln("sql statement executed"); + } assert(db.totalChanges == 1); // Statement insert_doc_objects = db.prepare(" @@ -1030,17 +1034,19 @@ template SQLiteBuildTablesAndPopulate() { break; } if (obj.is_a == "heading") { - writeln( - "markup: ", obj.heading_lev_markup, - "> ", obj.dom_markedup, - "; collapsed: ", obj.heading_lev_collapsed, - "> ", obj.dom_collapsed, - "; ocn: ", obj.ocn, - " node: ", obj.node, - "; parent: ", obj.parent_lev_markup, - "; ocn: ", obj.parent_ocn, - "; ", - ); + if ((doc_matters.opt.action.verbose)) { + writeln( + "markup: ", obj.heading_lev_markup, + "> ", obj.dom_markedup, + "; collapsed: ", obj.heading_lev_collapsed, + "> ", obj.dom_collapsed, + "; ocn: ", obj.ocn, + " node: ", obj.node, + "; parent: ", obj.parent_lev_markup, + "; ocn: ", obj.parent_ocn, + "; ", + ); + } } insert_doc_objects.bind(":t_of", obj.is_of); insert_doc_objects.bind(":t_is", obj.is_a); diff --git a/src/sdp/output/sqlite_discrete.d b/src/sdp/output/sqlite_discrete.d index 0c323d1..b256389 100644 --- a/src/sdp/output/sqlite_discrete.d +++ b/src/sdp/output/sqlite_discrete.d @@ -457,6 +457,7 @@ template SQLiteDiscreteBuildTablesAndPopulate() { auto ref I doc_matters, ) { auto pth_sqlite = SiSUpathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); + pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename)); // auto db = Database(":memory:"); // open database in memory db.run(" @@ -813,7 +814,10 @@ template SQLiteDiscreteBuildTablesAndPopulate() { // insert_metadata.bind(":links", doc_matters.conf_make_meta.meta.links); insert_metadata.execute(); insert_metadata.reset(); /+ watch +/ - writeln("sql statement executed"); + writeln(" ", pth_sqlite.sqlite_file(doc_matters.src.filename)); + if ((doc_matters.opt.action.verbose)) { + writeln("sql statement executed"); + } assert(db.totalChanges == 1); // Statement insert_doc_objects = db.prepare(" @@ -1027,17 +1031,19 @@ template SQLiteDiscreteBuildTablesAndPopulate() { break; } if (obj.is_a == "heading") { - writeln( - "markup: ", obj.heading_lev_markup, - "> ", obj.dom_markedup, - "; collapsed: ", obj.heading_lev_collapsed, - "> ", obj.dom_collapsed, - "; ocn: ", obj.ocn, - " node: ", obj.node, - "; parent: ", obj.parent_lev_markup, - "; ocn: ", obj.parent_ocn, - "; ", - ); + if ((doc_matters.opt.action.verbose)) { + writeln( + "markup: ", obj.heading_lev_markup, + "> ", obj.dom_markedup, + "; collapsed: ", obj.heading_lev_collapsed, + "> ", obj.dom_collapsed, + "; ocn: ", obj.ocn, + " node: ", obj.node, + "; parent: ", obj.parent_lev_markup, + "; ocn: ", obj.parent_ocn, + "; ", + ); + } } insert_doc_objects.bind(":t_of", obj.is_of); insert_doc_objects.bind(":t_is", obj.is_a); diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d index 4e43a67..b0e75e6 100755 --- a/src/sdp/sdp.d +++ b/src/sdp/sdp.d @@ -1,9 +1,4 @@ #!/usr/bin/env rdmd -/+ - sdp: sisu document parser - a SiSU document parser writen in D - see http://sisudoc.org. -+/ module sdp.sisu_document_parser; import sdp.conf.compile_time_info, @@ -30,7 +25,11 @@ import sdp.output.paths_source; mixin(import("version.txt")); mixin CompileTimeInfo; -/++ A SiSU document parser writen in D. +/ +/++ +name "sdp" +description "A SiSU inspired document parser writen in D." +homepage "http://sisudoc.org" ++/ void main(string[] args) { mixin SiSUrgxInit; mixin SiSUregisters; @@ -149,152 +148,115 @@ void main(string[] args) { } struct OptActions { auto assertions() { - auto _k = opts["assertions"]; - return _k; + return opts["assertions"]; } auto concordance() { - auto _k = opts["concordance"]; - return _k; + return opts["concordance"]; } auto debug_do() { - auto _k = opts["debug"]; - return _k; + return opts["debug"]; } auto digest() { - auto _k = opts["digest"]; - return _k; + return opts["digest"]; } auto docbook() { - auto _k = opts["docbook"]; - return _k; + return opts["docbook"]; } auto epub() { - auto _k = opts["epub"]; - return _k; + return opts["epub"]; } auto html() { - auto _k = opts["html"]; - return _k; + return opts["html"]; } auto html_seg() { - auto _k = opts["html-seg"]; - return _k; + return opts["html-seg"]; } auto html_scroll() { - auto _k = opts["html-scroll"]; - return _k; + return opts["html-scroll"]; } auto manifest() { - auto _k = opts["manifest"]; - return _k; + return opts["manifest"]; } auto ocn() { - auto _k = opts["ocn"]; - return _k; + return opts["ocn"]; } auto odt() { - auto _k = opts["odt"]; - return _k; + return opts["odt"]; } auto pdf() { - auto _k = opts["pdf"]; - return _k; + return opts["pdf"]; } auto postgresql() { - auto _k = opts["postgresql"]; - return _k; + return opts["postgresql"]; } auto qrcode() { - auto _k = opts["qrcode"]; - return _k; + return opts["qrcode"]; } auto sisupod() { - auto _k = opts["sisupod"]; - return _k; + return opts["sisupod"]; } auto source() { - auto _k = opts["source"]; - return _k; + return opts["source"]; } auto sqlite_discrete() { - auto _k = opts["sqlite-discrete"]; - return _k; + return opts["sqlite-discrete"]; } auto sqlite_update() { - auto _k = opts["sqlite-update"]; - return _k; + return opts["sqlite-update"]; } auto sqlite_create() { - auto _k = opts["sqlite-create"]; - return _k; + return opts["sqlite-create"]; } auto sqlite_drop() { - auto _k = opts["sqlite-drop"]; - return _k; + return opts["sqlite-drop"]; } auto text() { - auto _k = opts["text"]; - return _k; + return opts["text"]; } auto verbose() { - auto _k = opts["verbose"]; - return _k; + return opts["verbose"]; } auto xhtml() { - auto _k = opts["xhtml"]; - return _k; + return opts["xhtml"]; } auto xml_dom() { - auto _k = opts["xml-dom"]; - return _k; + return opts["xml-dom"]; } auto xml_sax() { - auto _k = opts["xml-sax"]; - return _k; + return opts["xml-sax"]; } auto section_toc() { - auto _k = opts["section_toc"]; - return _k; + return opts["section_toc"]; } auto section_body() { - auto _k = opts["section_body"]; - return _k; + return opts["section_body"]; } auto section_endnotes() { - auto _k = opts["section_endnotes"]; - return _k; + return opts["section_endnotes"]; } auto section_glossary() { - auto _k = opts["section_glossary"]; - return _k; + return opts["section_glossary"]; } auto section_biblio() { - auto _k = opts["section_biblio"]; - return _k; + return opts["section_biblio"]; } auto section_bookindex() { - auto _k = opts["section_bookindex"]; - return _k; + return opts["section_bookindex"]; } auto section_blurb() { - auto _k = opts["section_blurb"]; - return _k; + return opts["section_blurb"]; } auto backmatter() { - auto _k = opts["backmatter"]; - return _k; + return opts["backmatter"]; } auto skip_output() { - auto _k = opts["skip-output"]; - return _k; + return opts["skip-output"]; } auto languages_set() { - auto _k = settings["lang"].split(","); - return _k; + return settings["lang"].split(","); } auto output_dir_set() { - auto _k = settings["output-dir"]; - return _k; + return settings["output-dir"]; } } auto _opt_action = OptActions(); @@ -321,24 +283,28 @@ void main(string[] args) { "file not found: «" ~ sisudoc_txt_ ~ "»" ); - try { - if (exists(sisudoc_txt_)) { - contents_location_raw_ = sisudoc_txt_.readText; + if (exists(sisudoc_txt_)) { + try { + if (exists(sisudoc_txt_)) { + contents_location_raw_ = sisudoc_txt_.readText; + } } - } - catch (ErrnoException ex) { - } - catch (FileException ex) { - // Handle errors - } - if (contents_location_raw_.match(rgx.pod_content_location)) { // (file name followed by language codes \n)+ - foreach (m; contents_location_raw_.matchAll(rgx.pod_content_location)) { - foreach (n; m.captures[2].matchAll(rgx.language_codes)) { - contents_location_ ~= "media/text/" ~ n.captures[1].to!string ~ "/" ~ m.captures[1].to!string ~ "\n"; + catch (ErrnoException ex) { + } + catch (FileException ex) { + // Handle errors + } + if (contents_location_raw_.match(rgx.pod_content_location)) { // (file name followed by language codes \n)+ + foreach (m; contents_location_raw_.matchAll(rgx.pod_content_location)) { + foreach (n; m.captures[2].matchAll(rgx.language_codes)) { + contents_location_ ~= "media/text/" ~ n.captures[1].to!string ~ "/" ~ m.captures[1].to!string ~ "\n"; + } } + } else { + contents_location_ = contents_location_raw_; } - } else { // (file name with path \n)+ - contents_location_ = contents_location_raw_; + } else { + writeln("manifest not found: ", sisudoc_txt_); } auto contents_locations_arr = (cast(char[]) contents_location_).split; @@ -359,7 +325,11 @@ void main(string[] args) { } } } else if (arg.match(rgx.src_pth_sst_or_ssm)) { - _manifests ~= PathMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing + if (exists(arg)==0) { + writeln("ERROR >> Processing Skipped! File not found: ", arg); + } else { + _manifests ~= PathMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing + } } else if (arg.match(rgx.src_pth_zip)) { // fns_src ~= arg; // gather input markup source file names for processing } else { // anything remaining, unused @@ -368,7 +338,13 @@ void main(string[] args) { } if (!(_opt_action.skip_output)) { + debug(steps) { + writeln("step0 commence → (without processing files)"); + } outputHubOp!()(_opt_action); + debug(steps) { + writeln("- step0 complete"); + } } if (_manifests.length > 1) { // _manifests[0] initialized dummy element foreach(manifest; _manifests[1..$]) { @@ -413,7 +389,13 @@ void main(string[] args) { } /+ ↓ output hub +/ if (!(doc_matters.opt.action.skip_output)) { + debug(steps) { + writeln("step5 commence → (process outputs)"); + } outputHub!()(doc_abstraction, doc_matters); + debug(steps) { + writeln("- step5 complete"); + } } scope(exit) { debug(checkdoc) { @@ -433,9 +415,4 @@ void main(string[] args) { } } unittest { - /++ - name "sdp" - description "A SiSU document parser writen in D." - homepage "http://sisudoc.org" - +/ } -- cgit v1.2.3