diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2019-11-14 11:16:09 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-11-19 16:55:31 -0500 |
commit | d61236952f19c1a1107a11cf11874104c0fe1a9b (patch) | |
tree | 838d700a639cdb358fe744361fc593b453de03b8 /org | |
parent | makefile program version tagging for bin-archive (diff) |
0.8.3 (if exists) get site config & output pathdoc-reform_v0.8.3
- read once & read early:
- once per batch processing
- early (needed by metadata --harvest)
Diffstat (limited to 'org')
-rw-r--r-- | org/default_paths.org | 153 | ||||
-rw-r--r-- | org/doc_reform.org | 58 | ||||
-rw-r--r-- | org/meta_conf_make_meta.org | 9 | ||||
-rw-r--r-- | org/output_harvest_metadata.org | 10 | ||||
-rw-r--r-- | org/source_files_read.org | 57 |
5 files changed, 165 insertions, 122 deletions
diff --git a/org/default_paths.org b/org/default_paths.org index 459d8b9..ed47cac 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -217,6 +217,9 @@ template PathMatters() { string pod_name_with_path() { return (is_pod) ? _manifested.pod_manifest_path : ""; } + string pods_collection_root_path() { + return (is_pod) ? _manifested.pods_collection_root_path : ""; + } string pod_name() { return pod_name_with_path.baseName; } @@ -301,6 +304,9 @@ template PathMatters() { string absolute_path_to_src() { return (_env["pwd"].chainPath(path_and_fn)).dirName.array; } + string path_to_doc_root_path_to_lang_and_filename() { + return _env["pwd"].chainPath(path_and_fn).array; + } string base_dir() { string _dir; if ( @@ -413,7 +419,17 @@ template PathMatters() { return SRC_(); } auto output() { - auto _opt_actions = _opt_actions; + /+ + - command line if output path set + - config file if found and set set + - search for and if exists read config + - default paths to config related to: + - source markup path; + - current dir; + - home dir + - get output path if set + - (program) default within current directory? + +/ auto _env = _env; struct Out_ { auto path() { @@ -453,8 +469,9 @@ template ConfigFilePaths() { mixin DocReformRgxInit; static auto rgx = Rgx(); auto ConfigFilePaths(M,E)( - M _manifested, - E _env, + M _manifested, + E _env, + string _cli_config_path_set = "" ) { struct ConfFilePaths { string config_filename_document() { @@ -470,37 +487,43 @@ template ConfigFilePaths() { /+ config local site (file system only, not in pod) +/ /+ return paths +/ string[] _possible_config_path_locations; - if (_manifested.src.is_pod) { - /+ config document in pod +/ - string _dr_doc_conf_pod; - string _dr_doc_conf_pod_text; - _dr_doc_conf_pod = asNormalizedPath(chainPath( - to!string(_env["pwd"]), - _manifested.pod.manifest_path ~ "/conf" - )).array; - _dr_doc_conf_pod_text = asNormalizedPath(chainPath( - to!string(_env["pwd"]), - _manifested.pod.manifest_path ~ "/media/text/" ~ _manifested.src.lng ~ "/conf" - )).array; - /+ return paths +/ - _possible_config_path_locations = [ - _dr_doc_conf_pod_text, - _dr_doc_conf_pod, - ]; + if (_cli_config_path_set.empty) { + if (_manifested.src.is_pod) { + /+ config document in pod +/ + string _dr_doc_conf_pod; + string _dr_doc_conf_pod_text; + _dr_doc_conf_pod = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifested.pod.manifest_path ~ "/conf" + )).array; + _dr_doc_conf_pod_text = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifested.pod.manifest_path ~ "/media/text/" ~ _manifested.src.lng ~ "/conf" + )).array; + /+ return paths +/ + _possible_config_path_locations = [ + _dr_doc_conf_pod_text, + _dr_doc_conf_pod, + ]; + } else { + /+ config document (& or local site) on filesystem +/ + string _dr_doc_conf_pwd = ((chainPath(to!string(_env["pwd"]), "dr_doc/conf")).asNormalizedPath).array; // think about + string _dr_doc_conf_pwd_a = ((chainPath(to!string(_env["pwd"]), "conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_b = ((chainPath(to!string(_env["pwd"]), "../conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_c = ((chainPath(to!string(_env["pwd"]), "../../conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_d = ((chainPath(to!string(_env["pwd"]), "../../../conf")).asNormalizedPath).array; + /+ return paths +/ + _possible_config_path_locations = [ + _dr_doc_conf_pwd, + _dr_doc_conf_pwd_a, + _dr_doc_conf_pwd_b, + _dr_doc_conf_pwd_c, + _dr_doc_conf_pwd_d, + ]; + } } else { - /+ config document (& or local site) on filesystem +/ - string _dr_doc_conf_pwd = ((chainPath(to!string(_env["pwd"]), "dr_doc/conf")).asNormalizedPath).array; // think about - string _dr_doc_conf_pwd_a = ((chainPath(to!string(_env["pwd"]), "conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_b = ((chainPath(to!string(_env["pwd"]), "../conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_c = ((chainPath(to!string(_env["pwd"]), "../../conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_d = ((chainPath(to!string(_env["pwd"]), "../../../conf")).asNormalizedPath).array; - /+ return paths +/ _possible_config_path_locations = [ - _dr_doc_conf_pwd, - _dr_doc_conf_pwd_a, - _dr_doc_conf_pwd_b, - _dr_doc_conf_pwd_c, - _dr_doc_conf_pwd_d, + _cli_config_path_set ]; } /+ FIX clean up conf paths ↑ @@ -511,39 +534,45 @@ template ConfigFilePaths() { string[] config_local_site() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ - string _dot_pwd = ((chainPath(to!string(_env["pwd"]), ".dr")).asNormalizedPath).array; - string _underscore_pwd = ((chainPath(to!string(_env["pwd"]), "_dr")).asNormalizedPath).array; - string _dot_home = ((chainPath(to!string(_env["home"]), ".dr")).asNormalizedPath).array; - /+ return paths +/ string[] _possible_config_path_locations; - if (_manifested.src.is_pod) { - string _collection_root_a = ((chainPath(to!string(_manifested.pod.collection_root.to!string), ".dr")).asNormalizedPath).array; - string _collection_root_b = ((chainPath(to!string(_manifested.pod.collection_root.to!string), "_dr")).asNormalizedPath).array; - _possible_config_path_locations = [ - _dot_pwd, - _underscore_pwd, - _dot_home, - "/etc/dr", - _collection_root_a, // set priority higher? - _collection_root_b // set priority higher? - ]; + if (_cli_config_path_set.empty) { + string _dot_pwd = ((chainPath(to!string(_env["pwd"]), ".dr")).asNormalizedPath).array; + string _underscore_pwd = ((chainPath(to!string(_env["pwd"]), "_dr")).asNormalizedPath).array; + string _dot_home = ((chainPath(to!string(_env["home"]), ".dr")).asNormalizedPath).array; + /+ return paths +/ + if (_manifested.src.is_pod) { + string _collection_root_a = ((chainPath(to!string(_manifested.pod.collection_root.to!string), ".dr")).asNormalizedPath).array; + string _collection_root_b = ((chainPath(to!string(_manifested.pod.collection_root.to!string), "_dr")).asNormalizedPath).array; + _possible_config_path_locations = [ + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/dr", + _collection_root_a, // set priority higher? + _collection_root_b // set priority higher? + ]; + } else { + /+ config document (& or local site) on filesystem +/ + string _dr_doc_conf_pwd = ((chainPath(to!string(_env["pwd"]), "dr_doc/conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_a = ((chainPath(to!string(_env["pwd"]), "conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_b = ((chainPath(to!string(_env["pwd"]), "../conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_c = ((chainPath(to!string(_env["pwd"]), "../../conf")).asNormalizedPath).array; + string _dr_doc_conf_pwd_d = ((chainPath(to!string(_env["pwd"]), "../../../conf")).asNormalizedPath).array; + _possible_config_path_locations = [ + _dr_doc_conf_pwd, + _dr_doc_conf_pwd_a, + _dr_doc_conf_pwd_b, + _dr_doc_conf_pwd_c, + _dr_doc_conf_pwd_d, + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/dr" + ]; + } } else { - /+ config document (& or local site) on filesystem +/ - string _dr_doc_conf_pwd = ((chainPath(to!string(_env["pwd"]), "dr_doc/conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_a = ((chainPath(to!string(_env["pwd"]), "conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_b = ((chainPath(to!string(_env["pwd"]), "../conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_c = ((chainPath(to!string(_env["pwd"]), "../../conf")).asNormalizedPath).array; - string _dr_doc_conf_pwd_d = ((chainPath(to!string(_env["pwd"]), "../../../conf")).asNormalizedPath).array; _possible_config_path_locations = [ - _dr_doc_conf_pwd, - _dr_doc_conf_pwd_a, - _dr_doc_conf_pwd_b, - _dr_doc_conf_pwd_c, - _dr_doc_conf_pwd_d, - _dot_pwd, - _underscore_pwd, - _dot_home, - "/etc/dr" + _cli_config_path_set ]; } /+ FIX clean up conf paths ↑ diff --git a/org/doc_reform.org b/org/doc_reform.org index 5b44538..0b98147 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -28,7 +28,7 @@ struct Version { int minor; int patch; } -enum _ver = Version(0, 8, 2); +enum _ver = Version(0, 8, 3); #+END_SRC ** compilation restrictions (supported compilers) @@ -121,14 +121,14 @@ void main(string[] args) { } if (hvst.harvests.length > 0) { if (_opt_action.harvest_topics) { - DocReformMetaDocHarvestsTopics!()(hvst, _opt_action); + DocReformMetaDocHarvestsTopics!()(hvst, _make_and_meta_struct, _opt_action); } if (_opt_action.harvest_authors) { - DocReformMetaDocHarvestsAuthors!()(hvst.harvests, _opt_action); + DocReformMetaDocHarvestsAuthors!()(hvst.harvests, _make_and_meta_struct, _opt_action); } if (!(_opt_action.quiet)) { import doc_reform.output.paths_output; - auto out_pth = DocReformPathsHTML!()(_opt_action.output_dir_set, ""); + auto out_pth = DocReformPathsHTML!()(_make_and_meta_struct.conf.output_path, ""); if (_opt_action.harvest_authors) { writeln("- ", out_pth.harvest("authors.html")); } @@ -759,20 +759,35 @@ auto _env = [ #+BEGIN_SRC d auto _manifested = PathMatters!()(_opt_action, _env, ""); auto _manifests = [ _manifested ]; -ConfCompositePlus _make_and_meta_struct_tst; -foreach(arg; args[1..$]) { +ConfComposite _make_and_meta_struct; +if (_opt_action.config_path_set.empty) { + foreach(arg; args[1..$]) { + if (!(arg.match(rgx.flag_action))) { /+ cli markup source path +/ // get first input markup source file names for processing + _manifested = PathMatters!()(_opt_action, _env, arg); + { /+ local site config +/ + auto _config_local_site_struct = readConfigSite!()(_manifested, _env); + if (_config_local_site_struct.filetype == "yaml") { + import doc_reform.meta.conf_make_meta_yaml; + _make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct, _manifested); // - get local site config + break; + } + } + } + } +} else { + { /+ local site config +/ + auto _config_local_site_struct = readConfigSite!()(_manifested, _env, _opt_action.config_path_set); + if (_config_local_site_struct.filetype == "yaml") { + import doc_reform.meta.conf_make_meta_yaml; + _make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct, _manifested); // - get local site config + } + } +} +foreach(arg; args[1..$]) { // refigure how args relate to _opt_action, need path from _opt_action or args early _manifested too late, work on (search for PathMatters and .harvest, auto _manifest_start = PodManifest!()(arg); if (arg.match(rgx.flag_action)) { /+ cli instruction, flag do +/ flag_action ~= " " ~ arg; // flags not taken by getopt } 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 @@ -928,7 +943,6 @@ foreach(arg; args[1..$]) { #+NAME: doc_reform_conf_files_in_yaml #+BEGIN_SRC d -ConfCompositePlus _make_and_meta_struct; { /+ document config/make file +/ auto _config_document_struct = readConfigDoc!()(_manifest, _env); if (_config_document_struct.filetype == "yaml") { @@ -936,13 +950,6 @@ ConfCompositePlus _make_and_meta_struct; _make_and_meta_struct = _config_document_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); } } -{ /+ local site config +/ - auto _config_local_site_struct = readConfigSite!()(_manifest, _env); - if (_config_local_site_struct.filetype == "yaml") { - import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); - } -} #+END_SRC *** opt actions independent of processing files (no files no processing loop) @@ -1007,7 +1014,7 @@ if ((_opt_action.debug_do) ) { writeln("--->\nstepX commence → (document abstraction)"); } -auto t = DocReformAbstraction!()(_env, program_info, _opt_action, manifest); +auto t = DocReformAbstraction!()(_env, program_info, _opt_action, manifest, _make_and_meta_struct); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; @@ -1154,11 +1161,12 @@ template DocReformAbstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstract_obj, doc_has } static auto rgx = Rgx(); - auto DocReformAbstraction(E,P,O,M)( + auto DocReformAbstraction(E,P,O,M,S)( E _env, P program_info, O _opt_action, - M _manifest + M _manifest, + S _make_and_meta_struct ){ <<doc_reform_conf_files_in_yaml>> <<doc_reform_each_file_do_read_and_split_dr_markup_file_content_into_header_and_body>> diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 07befe1..208a028 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -319,11 +319,6 @@ struct MetaComposite { struct ConfComposite { MetaComposite meta; ConfCompositeMakeInit make; - ConfCompositeSiteLocal conf; -} -struct ConfCompositePlus { - MetaComposite meta; - ConfCompositeMakeInit make; ConfCompositeMakeStr make_str; ConfCompositeSiteLocal conf; } @@ -363,7 +358,7 @@ static template contentYAMLtoDocReformStruct() { doc_reform.meta.conf_make_meta_structs, doc_reform.meta.defaults, doc_reform.meta.rgx; - ConfCompositePlus _struct_composite; + ConfComposite _struct_composite; auto contentYAMLtoDocReformStruct(C,Y,M)( C _struct_composite, Y _yaml, @@ -1165,7 +1160,7 @@ static template contentJSONtoDocReformStruct() { doc_reform.meta.conf_make_meta_json, doc_reform.meta.defaults, doc_reform.meta.rgx; - ConfCompositePlus _struct_composite; + ConfComposite _struct_composite; auto contentJSONtoDocReformStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) { mixin DocReformRgxInit; static auto rgx = Rgx(); diff --git a/org/output_harvest_metadata.org b/org/output_harvest_metadata.org index a7ce40f..2fb3485 100644 --- a/org/output_harvest_metadata.org +++ b/org/output_harvest_metadata.org @@ -128,8 +128,9 @@ module doc_reform.meta.metadoc_harvests_topics; mixin DocReformRgxInit; template DocReformMetaDocHarvestsTopics() { auto mkup = InlineMarkup(); - void DocReformMetaDocHarvestsTopics(H,O)( + void DocReformMetaDocHarvestsTopics(H,M,O)( H hvst, + M _make_and_meta_struct, O _opt_action, ) { <<harvested_topics>> @@ -418,7 +419,7 @@ foreach(k0; #+NAME: harvested_topics_html_write #+BEGIN_SRC d import doc_reform.output.paths_output; -auto out_pth = DocReformPathsHTML!()(_opt_action.output_dir_set, ""); +auto out_pth = DocReformPathsHTML!()(_make_and_meta_struct.conf.output_path, ""); try { auto f = File(out_pth.harvest("topics.html"), "w"); foreach (o; topics) { @@ -450,8 +451,9 @@ module doc_reform.meta.metadoc_harvests_authors; mixin DocReformRgxInit; template DocReformMetaDocHarvestsAuthors() { auto mkup = InlineMarkup(); - void DocReformMetaDocHarvestsAuthors(H,O)( + void DocReformMetaDocHarvestsAuthors(H,M,O)( H harvests, + M _make_and_meta_struct, O _opt_action, ) { <<harvested_html_themes>> @@ -567,7 +569,7 @@ template DocReformMetaDocHarvestsAuthors() { #+NAME: harvested_authors_html_write #+BEGIN_SRC d import doc_reform.output.paths_output; -auto out_pth = DocReformPathsHTML!()(_opt_action.output_dir_set, ""); +auto out_pth = DocReformPathsHTML!()(_make_and_meta_struct.conf.output_path, ""); try { auto f = File(out_pth.harvest("authors.html"), "w"); foreach (o; authors) { diff --git a/org/source_files_read.org b/org/source_files_read.org index 8549cda..e182475 100644 --- a/org/source_files_read.org +++ b/org/source_files_read.org @@ -51,30 +51,42 @@ static template readConfigSite() { doc_reform.meta.rgx; <<imports_std>> mixin DocReformRgxInit; - final auto readConfigSite(M,E)(M _manifested, E _env) { + final auto readConfigSite(M,E)( + M _manifested, + E _env, + string _cli_config_path_set = "" + ) { static auto rgx = Rgx(); string config_file_str; string conf_filename = "NONE"; - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); + auto _conf_file_details = ConfigFilePaths!()(_manifested, _env, _cli_config_path_set); string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.config_local_site; foreach(conf_fn; [_conf_file_details.config_filename_site]) { foreach(pth; possible_config_path_locations) { - char[] conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; + char[] conf_file; conf_filename = conf_fn; - if (config_file_str.length > 0) { - // conf_filename = conf_fn; - break; - } - try { - if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); + if (exists(pth)) { + auto f_attrib = pth.getLinkAttributes; + if ( + possible_config_path_locations.length == 1 + && f_attrib.attrIsFile + ) { + conf_file = pth.to!(char[]); + conf_filename = pth.baseName; + } else if (f_attrib.attrIsDir) { + conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; + conf_filename = conf_fn; + } + try { + if (exists(conf_file)) { + if (conf_file.getLinkAttributes.attrIsFile) { + config_file_str = conf_file.readText; + break; + } } - config_file_str = conf_file.readText; - break; + } catch (ErrnoException ex) { + } catch (FileException ex) { } - } catch (ErrnoException ex) { - } catch (FileException ex) { } } if (config_file_str.length > 0) { break; } @@ -119,16 +131,14 @@ static template readConfigDoc() { auto conf_file = ((chainPath(pth.to!string, conf_fn)).asNormalizedPath).array; conf_filename = conf_fn; if (config_file_str.length > 0) { - // conf_filename = conf_fn; break; } try { if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); + if (conf_file.getLinkAttributes.attrIsFile) { + config_file_str = conf_file.readText; + break; } - config_file_str = conf_file.readText; - break; } } catch (ErrnoException ex) { } catch (FileException ex) { @@ -182,7 +192,6 @@ static template configYAML() { #+BEGIN_SRC d static template configReadSiteYAML() { <<imports_std>> - import dyaml; final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); @@ -332,10 +341,10 @@ final private string readInMarkupSource(in char[] fn_src) { string source_txt_str; try { if (exists(fn_src)) { - debug(io) { - writeln("in src, markup source file found: ", fn_src); + if (fn_src.getLinkAttributes.attrIsFile) { + source_txt_str = fn_src.readText; + } else { } - source_txt_str = fn_src.readText; } } catch (ErrnoException ex) { } catch (UTFException ex) { |