diff options
Diffstat (limited to 'org/doc_reform.org')
-rw-r--r-- | org/doc_reform.org | 349 |
1 files changed, 151 insertions, 198 deletions
diff --git a/org/doc_reform.org b/org/doc_reform.org index 995dde6..f367dea 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -483,65 +483,31 @@ struct OptActions { return opts["epub"]; } bool harvest() { - bool _is = ( - opts["harvest"] - || opts["harvest-authors"] - || opts["harvest-topics"] - ) - ? true : false; - return _is; + return (opts["harvest"] || opts["harvest-authors"] || opts["harvest-topics"]) ? true : false; } bool harvest_authors() { - bool _is = ( - opts["harvest"] - || opts["harvest-authors"] - ) - ? true : false; - return _is; + return (opts["harvest"] || opts["harvest-authors"]) ? true : false; } bool harvest_topics() { - bool _is = ( - opts["harvest"] - || opts["harvest-topics"] - ) - ? true : false; - return _is; + return (opts["harvest"] || opts["harvest-topics"]) ? true : false; } bool html() { - bool _is; - if ( opts["html"] || opts["html-seg"] || opts["html-scroll"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-seg"] || opts["html-scroll"]) ? true : false; } bool html_seg() { - bool _is; - if ( opts["html"] || opts["html-seg"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-seg"]) ? true : false; } bool html_scroll() { - bool _is; - if ( opts["html"] || opts["html-scroll"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-scroll"]) ? true : false; } bool html_stuff() { - bool _is; - if (opts["html"] || opts["html-scroll"] || opts["html-seg"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["html"] || opts["html-scroll"] || opts["html-seg"]) ? true : false; } bool latex() { - bool _is; - if ( opts["latex"] || opts["pdf"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["latex"] || opts["pdf"]) ? true : false; } bool odt() { - bool _is; - if ( opts["odf"] || opts["odt"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["odf"] || opts["odt"]) ? true : false; } bool manifest() { return opts["manifest"]; @@ -580,44 +546,31 @@ struct OptActions { return opts["sqlite-discrete"]; } bool sqlite_db_drop() { - bool _is; - if ( opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) ? true : false; } bool sqlite_db_create() { - bool _is; - if ( opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) ? true : false; } bool sqlite_delete() { return opts["sqlite-delete"]; } bool sqlite_update() { - bool _is; - if (opts["sqlite-update"] || opts["sqlite-insert"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["sqlite-update"] || opts["sqlite-insert"]) ? true : false; } bool sqlite_shared_db_action() { - bool _is; - if (opts["sqlite-db-recreate"] + return ( + opts["sqlite-db-recreate"] || opts["sqlite-db-create"] || opts["sqlite-delete"] || opts["sqlite-insert"] || opts["sqlite-update"] - ) { _is = true; } else { _is = false; } - return _is; + ) ? true : false; } bool text() { return opts["text"]; } bool verbose() { - bool _is; - if (opts["verbose"] || opts["very-verbose"]) - { _is = true; } else { _is = false; } - return _is; + return (opts["verbose"] || opts["very-verbose"]) ? true : false; } bool very_verbose() { return opts["very-verbose"]; @@ -672,7 +625,8 @@ struct OptActions { } else if (opts["parallel"] == false && opts["serial"] == true) { _is = false; - } else if (opts["abstraction"] + } else if ( + opts["abstraction"] || concordance || harvest || html @@ -719,8 +673,8 @@ struct OptActions { return schedule.sort().uniq; } bool abstraction() { - bool _is; - if (opts["abstraction"] + return ( + opts["abstraction"] || concordance || source_or_pod || harvest @@ -732,31 +686,28 @@ struct OptActions { || sqlite_discrete || sqlite_delete || sqlite_update - ) { _is = true; } else { _is = false; } - return _is; + ) ? true : false; } bool meta_processing_general() { - bool _is; - if (opts["abstraction"] + return ( + opts["abstraction"] || html || epub || odt || latex || sqlite_discrete || sqlite_update - ) { _is = true; } else { _is = false; } - return _is; + ) ? true :false; } bool meta_processing_xml_dom() { - bool _is; - if (opts["abstraction"] + return ( + opts["abstraction"] || html || epub || odt || sqlite_discrete || sqlite_update - ) { _is = true; } else { _is = false; } - return _is; + ) ? true : false; } } auto _opt_action = OptActions(); @@ -803,77 +754,110 @@ auto _env = [ #+NAME: doc_reform_args #+BEGIN_SRC d -auto _manifest_matter = PathMatters!()(_opt_action, _env, ""); -auto _manifests = [ _manifest_matter ]; +auto _manifested = PathMatters!()(_opt_action, _env, ""); +auto _manifests = [ _manifested ]; ConfCompositePlus _make_and_meta_struct_tst; foreach(arg; args[1..$]) { - _manifest_matter = PathMatters!()(_opt_action, _env, arg); // gather input markup source file names for processing - auto _config_local_site_struct = readConfigSite!()(_manifest_matter, _env); - { /+ local site config +/ - if (_config_local_site_struct.filetype == "yaml") { - import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct_tst = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct_tst, _manifest_matter); - } - } auto _manifest_start = PodManifest!()(arg); - if (arg.match(rgx.flag_action)) { + if (arg.match(rgx.flag_action)) { /+ cli instruction, flag do +/ flag_action ~= " " ~ arg; // flags not taken by getopt - } else if ( - !(arg.match(rgx.src_pth_sst_or_ssm)) - && _manifest_start.pod_manifest_file_with_path - && _opt_action.abstraction - ) { - string pod_manifest_root_content_paths_to_markup_location_raw_; - string markup_contents_location_; - string sisudoc_txt_ = _manifest_start.pod_manifest_file_with_path; - enforce( - exists(sisudoc_txt_)!=0, - "file not found: «" ~ - sisudoc_txt_ ~ "»" - ); - if (exists(sisudoc_txt_)) { - try { - if (exists(sisudoc_txt_)) { - import dyaml; - try { - Node pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); - if ("doc" in pod_manifest_yaml) { - if (pod_manifest_yaml["doc"].type.mapping - && pod_manifest_yaml["doc"].tag.match(rgx.yaml_tag_is_map) - ) { - if ("path" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_seq)) { - foreach (string _path; pod_manifest_yaml["doc"]["path"]) { - markup_contents_location_ ~= _path ~ "\n"; - pod_manifest_root_content_paths_to_markup_location_raw_ ~= - _path ~ "\n"; + } else { /+ cli, assumed to be path to source files +/ + _manifested = PathMatters!()(_opt_action, _env, arg); // gather input markup source file names for processing + auto _config_local_site_struct = readConfigSite!()(_manifested, _env); + { /+ local site config +/ + if (_config_local_site_struct.filetype == "yaml") { + import doc_reform.meta.conf_make_meta_yaml; + _make_and_meta_struct_tst = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct_tst, _manifested); + } + } + if ( /+ pod files +/ + !(arg.match(rgx.src_pth_sst_or_ssm)) + && _manifest_start.pod_manifest_file_with_path + && _opt_action.abstraction + ) { + string pod_manifest_root_content_paths_to_markup_location_raw_; + string markup_contents_location_; + string sisudoc_txt_ = _manifest_start.pod_manifest_file_with_path; + enforce( + exists(sisudoc_txt_)!=0, + "file not found: «" ~ + sisudoc_txt_ ~ "»" + ); + if (exists(sisudoc_txt_)) { + try { + if (exists(sisudoc_txt_)) { + import dyaml; + try { + Node pod_manifest_yaml = Loader.fromFile(sisudoc_txt_).load(); + if ("doc" in pod_manifest_yaml) { + if (pod_manifest_yaml["doc"].type.mapping + && pod_manifest_yaml["doc"].tag.match(rgx.yaml_tag_is_map) + ) { + if ("path" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_seq)) { + foreach (string _path; pod_manifest_yaml["doc"]["path"]) { + markup_contents_location_ ~= _path ~ "\n"; + pod_manifest_root_content_paths_to_markup_location_raw_ ~= + _path ~ "\n"; + } + } else if ( + pod_manifest_yaml["doc"]["path"].type.string + && pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_str) + ) { + markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; + pod_manifest_root_content_paths_to_markup_location_raw_ = + pod_manifest_yaml["doc"]["path"].get!string; } - } else if ( - pod_manifest_yaml["doc"]["path"].type.string - && pod_manifest_yaml["doc"]["path"].tag.match(rgx.yaml_tag_is_str) - ) { - markup_contents_location_ = pod_manifest_yaml["doc"]["path"].get!string; - pod_manifest_root_content_paths_to_markup_location_raw_ = - pod_manifest_yaml["doc"]["path"].get!string; } - } - if ("filename" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_seq)) { - foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { + if ("filename" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_seq)) { + foreach (string _filename; pod_manifest_yaml["doc"]["filename"]) { + if ("language" in pod_manifest_yaml["doc"]) { + if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_seq)) { + foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { + markup_contents_location_ ~= + "media/text/" + ~ _lang ~ "/" + ~ _filename ~ "\n"; + } + } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str) + ) { + markup_contents_location_ = + "media/text/" + ~ pod_manifest_yaml["doc"]["language"].get!string + ~ "/" ~ _filename ~ "\n"; + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } + } else { + string _lang_default = "en"; + markup_contents_location_ ~= + "media/text/" + ~ _lang_default ~ "/" + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; + } + } + } else if ( + pod_manifest_yaml["doc"]["filename"].type.string + && pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_str) + ) { if ("language" in pod_manifest_yaml["doc"]) { if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_seq)) { foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { markup_contents_location_ ~= "media/text/" ~ _lang ~ "/" - ~ _filename ~ "\n"; + ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } - } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str) - ) { + } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str)) { markup_contents_location_ = "media/text/" ~ pod_manifest_yaml["doc"]["language"].get!string - ~ "/" ~ _filename ~ "\n"; + ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } else { string _lang_default = "en"; markup_contents_location_ ~= @@ -889,81 +873,50 @@ foreach(arg; args[1..$]) { ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; } } - } else if ( - pod_manifest_yaml["doc"]["filename"].type.string - && pod_manifest_yaml["doc"]["filename"].tag.match(rgx.yaml_tag_is_str) - ) { - if ("language" in pod_manifest_yaml["doc"]) { - if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_seq)) { - foreach (string _lang; pod_manifest_yaml["doc"]["language"]) { - markup_contents_location_ ~= - "media/text/" - ~ _lang ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } else if (pod_manifest_yaml["doc"]["language"].tag.match(rgx.yaml_tag_is_str)) { - markup_contents_location_ = - "media/text/" - ~ pod_manifest_yaml["doc"]["language"].get!string - ~ "/" ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } else { - string _lang_default = "en"; - markup_contents_location_ ~= - "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } - } else { - string _lang_default = "en"; - markup_contents_location_ ~= - "media/text/" - ~ _lang_default ~ "/" - ~ pod_manifest_yaml["doc"]["filename"].get!string ~ "\n"; - } } } } - } - } catch (ErrnoException ex) { + } catch (ErrnoException ex) { + } } + } catch (ErrnoException ex) { + } catch (FileException ex) { + // Handle errors } - } catch (ErrnoException ex) { - } catch (FileException ex) { - // Handle errors + } else { + writeln("manifest not found: ", sisudoc_txt_); } - } else { - writeln("manifest not found: ", sisudoc_txt_); - } - auto markup_contents_locations_arr - = (cast(char[]) markup_contents_location_).split; - auto tmp_dir_ = (sisudoc_txt_).dirName.array; - foreach (markup_contents_location; markup_contents_locations_arr) { - assert(markup_contents_location.match(rgx.src_pth_sst_or_ssm), - "not a recognised file: «" ~ - markup_contents_location ~ "»" - ); - auto markup_contents_location_pth_ = (markup_contents_location).to!string; - Regex!(char) lang_rgx_ = regex(r"/(" ~ _opt_action.languages_set.join("|") ~ ")/"); - if (_opt_action.languages_set[0] == "all" - || (markup_contents_location_pth_).match(lang_rgx_) - ) { - auto _fns = (((tmp_dir_).chainPath(markup_contents_location_pth_)).array).to!string; - _manifest_matter = PathMatters!()(_opt_action, _env, arg, _fns, markup_contents_locations_arr); - _manifests ~= _manifest_matter; + auto markup_contents_locations_arr + = (cast(char[]) markup_contents_location_).split; + auto tmp_dir_ = (sisudoc_txt_).dirName.array; + foreach (markup_contents_location; markup_contents_locations_arr) { + assert(markup_contents_location.match(rgx.src_pth_sst_or_ssm), + "not a recognised file: «" ~ + markup_contents_location ~ "»" + ); + auto markup_contents_location_pth_ = (markup_contents_location).to!string; + Regex!(char) lang_rgx_ = regex(r"/(" ~ _opt_action.languages_set.join("|") ~ ")/"); + if (_opt_action.languages_set[0] == "all" + || (markup_contents_location_pth_).match(lang_rgx_) + ) { + auto _fns = (((tmp_dir_).chainPath(markup_contents_location_pth_)).array).to!string; + _manifested = PathMatters!()(_opt_action, _env, arg, _fns, markup_contents_locations_arr); + _manifests ~= _manifested; + } } + } else if (arg.match(rgx.src_pth_sst_or_ssm)) { /+ markup txt files +/ + if (exists(arg)==0) { + writeln("ERROR >> Processing Skipped! File not found: ", arg); + } else { + _manifested = PathMatters!()(_opt_action, _env, arg, arg); + _manifests ~= _manifested; + } + } else if (arg.match(rgx.src_pth_zip)) { + // fns_src ~= arg; // gather input markup source file names for processing + } else { // anything remaining, unused + arg_unrecognized ~= " " ~ arg; } - } else if (arg.match(rgx.src_pth_sst_or_ssm)) { - if (exists(arg)==0) { - writeln("ERROR >> Processing Skipped! File not found: ", arg); - } else { - _manifest_matter = PathMatters!()(_opt_action, _env, arg, arg); - _manifests ~= _manifest_matter; - } - } else if (arg.match(rgx.src_pth_zip)) { - // fns_src ~= arg; // gather input markup source file names for processing - } else { // anything remaining, unused - arg_unrecognized ~= " " ~ arg; } } #+END_SRC @@ -973,7 +926,7 @@ foreach(arg; args[1..$]) { #+NAME: doc_reform_conf_files_in_yaml #+BEGIN_SRC d ConfCompositePlus _make_and_meta_struct; -{ /+ document config file +/ +{ /+ document config/make file +/ auto _config_document_struct = readConfigDoc!()(_manifest, _env); if (_config_document_struct.filetype == "yaml") { import doc_reform.meta.conf_make_meta_yaml; |