From 81a26c19c55a98918cf433da2f867db6b693b6df Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 8 Jun 2019 14:15:46 -0400 Subject: harvest, document reporting --- org/doc_reform.org | 74 +++++++++++++++++++++------- org/meta_conf_make_meta.org | 23 ++++----- src/doc_reform/doc_reform.d | 54 +++++++++++++++----- src/doc_reform/meta/conf_make_meta_json.d | 10 +--- src/doc_reform/meta/conf_make_meta_structs.d | 1 - src/doc_reform/meta/conf_make_meta_toml.d | 12 +++-- src/doc_reform/meta/metadoc.d | 15 ++++-- src/doc_reform/meta/metadoc_harvest.d | 5 +- 8 files changed, 128 insertions(+), 66 deletions(-) diff --git a/org/doc_reform.org b/org/doc_reform.org index 7bb8029..b13d086 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -117,33 +117,58 @@ void main(string[] args) { } } } - if (_opt_action.verbose - && harvests.length > 1 + if (_opt_action.very_verbose + && harvests.length > 0 ) { auto min_repeat_number = 42; - foreach(doc_harvest; harvests) { + string[] _document_topic_register; + string[] _topic_register; + string[] _sub_topic_register; + foreach(k, doc_harvest; harvests) { + _topic_register = []; + foreach(topic; doc_harvest.topic_register_arr.sort) { + _sub_topic_register = []; + string _spaces; + foreach (i, _top; topic.split(mkup.sep)) { + _sub_topic_register ~= format( + " %s- %s", + " ".repeat(i).join, + _top, + ); + } + _topic_register ~= _sub_topic_register.join("\n"); + } auto char_repeat_number = (doc_harvest.title.length + doc_harvest.author.length + 16); char_repeat_number = (char_repeat_number > min_repeat_number) ? char_repeat_number : min_repeat_number; - writefln( - "%s\n\"%s\", %s%s", - mkup.repeat_character_by_number_provided("-", char_repeat_number), + _document_topic_register ~= format( + "\"%s\", %s%s\n%s", doc_harvest.title, doc_harvest.author, (doc_harvest.date_published.length > 0) ? " (" ~ doc_harvest.date_published ~ ")" : "", + _topic_register.sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release.join("\n"), ); - string[] _topic_arr; - foreach(topic; doc_harvest.topic_register_arr.sort) { - foreach (i, _top; topic.split(mkup.sep)) { - writeln(" ", (" ".repeat(i).join), "- ", _top); - } + foreach(_dtr; _document_topic_register.sort) { + writeln(_dtr); } } + } + if ((_opt_action.verbose + || _opt_action.very_verbose) + && harvests.length > 0 + ) { string[] _author_date_title; foreach(doc_harvest; harvests) { - _author_date_title ~= doc_harvest.author_date_title; + _author_date_title ~= format( + "%s %s \"%s\" [%s]", + doc_harvest.author_surname_fn, + (doc_harvest.date_published.length > 0) + ? "(" ~ doc_harvest.date_published ~ ")" : "", + doc_harvest.title, + doc_harvest.language, + ); } foreach(_adt; _author_date_title.sort) { writeln(_adt); @@ -304,7 +329,10 @@ mixin outputHub; struct Harvest { string title = ""; string author = ""; - string author_date_title = ""; + string author_surname_fn = ""; + string language = ""; + string language_original = ""; + string uid = ""; string date_published = ""; string[] topic_register_arr = [""]; string html_seg_toc = ""; @@ -870,11 +898,15 @@ foreach(arg; args[1..$]) { #+NAME: doc_reform_conf_files_in_toml #+BEGIN_SRC d -auto _config_document_struct = readConfigDoc!()(_manifest, _env); // document config file -auto _config_local_site_struct = readConfigSite!()(_manifest, _env); // local site config ConfCompositePlus _make_and_meta_struct; -_make_and_meta_struct = configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _config_document_struct); -_make_and_meta_struct = configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _config_local_site_struct); +{ /+ document config file +/ + auto _config_document_struct = readConfigDoc!()(_manifest, _env); + _make_and_meta_struct = _config_document_struct.configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); +} +{ /+ local site config +/ + auto _config_local_site_struct = readConfigSite!()(_manifest, _env); + _make_and_meta_struct = _config_local_site_struct.configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); +} #+END_SRC *** opt actions independent of processing files (no files no processing loop) @@ -1150,7 +1182,8 @@ if ((_opt_action.debug_do) _make_and_meta_struct = docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct!()( _make_and_meta_struct, - _header_body_insertfilelist_imagelist[headBody.header] + _header_body_insertfilelist_imagelist[headBody.header], + _manifest, ); if ((_opt_action.debug_do) || (_opt_action.very_verbose) @@ -1578,7 +1611,10 @@ writefln( #+BEGIN_SRC d harvest.title = doc_matters.conf_make_meta.meta.title_full; harvest.author = doc_matters.conf_make_meta.meta.creator_author; -harvest.author_date_title = doc_matters.conf_make_meta.meta.author_date_title; +harvest.author_surname_fn = doc_matters.conf_make_meta.meta.creator_author_surname_fn; +harvest.language_original = doc_matters.conf_make_meta.meta.original_language; +harvest.language = doc_matters.src.language; +harvest.uid = doc_matters.src.doc_uid; harvest.date_published = doc_matters.conf_make_meta.meta.date_published; harvest.topic_register_arr = doc_matters.conf_make_meta.meta.classify_topic_register_arr; return harvest; diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 79ee9e7..0f8c8bf 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -304,7 +304,6 @@ struct MetaComposite { string title_short; string title_sub; string title_subtitle; - string author_date_title; } #+END_SRC @@ -450,7 +449,7 @@ static template contentJSONtoDocReformStruct() { doc_reform.meta.defaults, doc_reform.meta.rgx; ConfCompositePlus _struct_composite; - auto contentJSONtoDocReformStruct(C,J)(C _struct_composite, J _json, string _identifier) { + auto contentJSONtoDocReformStruct(C,J,M)(C _struct_composite, J _json, M _manifest, string _identifier) { mixin DocReformRgxInit; static auto rgx = Rgx(); debug (json) { @@ -996,13 +995,7 @@ if ("date" in _json.object) { ) { _struct_composite.meta.date_valid = _json.object["date"]["valid"].str; } - _struct_composite.meta.author_date_title = format( - "%s %s \"%s\"", - _struct_composite.meta.creator_author_surname_fn, - (_struct_composite.meta.date_published.length > 0) - ? "(" ~ _struct_composite.meta.date_published ~ ")" : "", - _struct_composite.meta.title_full, - ); + _struct_composite.meta.language_document_char = _manifest.src.language; } if ("links" in _json.object) {} if ("notes" in _json.object) { @@ -1130,14 +1123,15 @@ static template configParseTOMLreturnDocReformStruct() { doc_reform.meta.conf_make_meta_structs, doc_reform.meta.conf_make_meta_json; mixin contentJSONtoDocReformStruct; - auto configParseTOMLreturnDocReformStruct(CCm, T)( + auto configParseTOMLreturnDocReformStruct(T,CCm,M)( + T _document_struct, CCm _make_and_meta_struct, - T _document_struct + M _manifest ){ TOMLDocument _doc = parseTOML(cast(string)(_document_struct.content)); auto _doc_json = _doc.toJSON; _make_and_meta_struct - = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _document_struct.filename); // struct from json + = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, _document_struct.filename); // struct from json return _make_and_meta_struct; } } @@ -1165,9 +1159,10 @@ static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { mixin DocReformRgxInit; mixin contentJSONtoDocReformStruct; static auto rgx = Rgx(); - auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm, Src)( + auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm,Src,M)( CCm _make_and_meta_struct, Src header_src, + M _manifest, ) { TOMLDocument _doc; if (header_src.match(rgx.toml_header_meta_title)) { @@ -1178,7 +1173,7 @@ static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { } auto _doc_json = _doc.toJSON; auto _header_and_make_and_meta_struct - = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, "header"); + = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, "header"); return _header_and_make_and_meta_struct; } } diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index 908a3a6..663fb4d 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -94,7 +94,10 @@ void main(string[] args) { struct Harvest { string title = ""; string author = ""; - string author_date_title = ""; + string author_surname_fn = ""; + string language = ""; + string language_original = ""; + string uid = ""; string date_published = ""; string[] topic_register_arr = [""]; string html_seg_toc = ""; @@ -819,33 +822,58 @@ void main(string[] args) { } } } - if (_opt_action.verbose - && harvests.length > 1 + if (_opt_action.very_verbose + && harvests.length > 0 ) { auto min_repeat_number = 42; - foreach(doc_harvest; harvests) { + string[] _document_topic_register; + string[] _topic_register; + string[] _sub_topic_register; + foreach(k, doc_harvest; harvests) { + _topic_register = []; + foreach(topic; doc_harvest.topic_register_arr.sort) { + _sub_topic_register = []; + string _spaces; + foreach (i, _top; topic.split(mkup.sep)) { + _sub_topic_register ~= format( + " %s- %s", + " ".repeat(i).join, + _top, + ); + } + _topic_register ~= _sub_topic_register.join("\n"); + } auto char_repeat_number = (doc_harvest.title.length + doc_harvest.author.length + 16); char_repeat_number = (char_repeat_number > min_repeat_number) ? char_repeat_number : min_repeat_number; - writefln( - "%s\n\"%s\", %s%s", - mkup.repeat_character_by_number_provided("-", char_repeat_number), + _document_topic_register ~= format( + "\"%s\", %s%s\n%s", doc_harvest.title, doc_harvest.author, (doc_harvest.date_published.length > 0) ? " (" ~ doc_harvest.date_published ~ ")" : "", + _topic_register.sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release.join("\n"), ); - string[] _topic_arr; - foreach(topic; doc_harvest.topic_register_arr.sort) { - foreach (i, _top; topic.split(mkup.sep)) { - writeln(" ", (" ".repeat(i).join), "- ", _top); - } + foreach(_dtr; _document_topic_register.sort) { + writeln(_dtr); } } + } + if ((_opt_action.verbose + || _opt_action.very_verbose) + && harvests.length > 0 + ) { string[] _author_date_title; foreach(doc_harvest; harvests) { - _author_date_title ~= doc_harvest.author_date_title; + _author_date_title ~= format( + "%s %s \"%s\" [%s]", + doc_harvest.author_surname_fn, + (doc_harvest.date_published.length > 0) + ? "(" ~ doc_harvest.date_published ~ ")" : "", + doc_harvest.title, + doc_harvest.language, + ); } foreach(_adt; _author_date_title.sort) { writeln(_adt); diff --git a/src/doc_reform/meta/conf_make_meta_json.d b/src/doc_reform/meta/conf_make_meta_json.d index 5fd4499..45d3a5a 100644 --- a/src/doc_reform/meta/conf_make_meta_json.d +++ b/src/doc_reform/meta/conf_make_meta_json.d @@ -21,7 +21,7 @@ static template contentJSONtoDocReformStruct() { doc_reform.meta.defaults, doc_reform.meta.rgx; ConfCompositePlus _struct_composite; - auto contentJSONtoDocReformStruct(C,J)(C _struct_composite, J _json, string _identifier) { + auto contentJSONtoDocReformStruct(C,J,M)(C _struct_composite, J _json, M _manifest, string _identifier) { mixin DocReformRgxInit; static auto rgx = Rgx(); debug (json) { @@ -545,13 +545,7 @@ static template contentJSONtoDocReformStruct() { ) { _struct_composite.meta.date_valid = _json.object["date"]["valid"].str; } - _struct_composite.meta.author_date_title = format( - "%s %s \"%s\"", - _struct_composite.meta.creator_author_surname_fn, - (_struct_composite.meta.date_published.length > 0) - ? "(" ~ _struct_composite.meta.date_published ~ ")" : "", - _struct_composite.meta.title_full, - ); + _struct_composite.meta.language_document_char = _manifest.src.language; } if ("links" in _json.object) {} if ("notes" in _json.object) { diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d index ff1ec76..3bd29e2 100644 --- a/src/doc_reform/meta/conf_make_meta_structs.d +++ b/src/doc_reform/meta/conf_make_meta_structs.d @@ -225,7 +225,6 @@ struct MetaComposite { string title_short; string title_sub; string title_subtitle; - string author_date_title; } struct ConfComposite { MetaComposite meta; diff --git a/src/doc_reform/meta/conf_make_meta_toml.d b/src/doc_reform/meta/conf_make_meta_toml.d index f047c5d..6008996 100644 --- a/src/doc_reform/meta/conf_make_meta_toml.d +++ b/src/doc_reform/meta/conf_make_meta_toml.d @@ -30,14 +30,15 @@ static template configParseTOMLreturnDocReformStruct() { doc_reform.meta.conf_make_meta_structs, doc_reform.meta.conf_make_meta_json; mixin contentJSONtoDocReformStruct; - auto configParseTOMLreturnDocReformStruct(CCm, T)( + auto configParseTOMLreturnDocReformStruct(T,CCm,M)( + T _document_struct, CCm _make_and_meta_struct, - T _document_struct + M _manifest ){ TOMLDocument _doc = parseTOML(cast(string)(_document_struct.content)); auto _doc_json = _doc.toJSON; _make_and_meta_struct - = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _document_struct.filename); // struct from json + = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, _document_struct.filename); // struct from json return _make_and_meta_struct; } } @@ -60,9 +61,10 @@ static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { mixin DocReformRgxInit; mixin contentJSONtoDocReformStruct; static auto rgx = Rgx(); - auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm, Src)( + auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm,Src,M)( CCm _make_and_meta_struct, Src header_src, + M _manifest, ) { TOMLDocument _doc; if (header_src.match(rgx.toml_header_meta_title)) { @@ -73,7 +75,7 @@ static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { } auto _doc_json = _doc.toJSON; auto _header_and_make_and_meta_struct - = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, "header"); + = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, "header"); return _header_and_make_and_meta_struct; } } diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index a4b920b..a26756b 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -36,11 +36,15 @@ template DocReformAbstraction() { O _opt_action, M _manifest ){ - auto _config_document_struct = readConfigDoc!()(_manifest, _env); // document config file - auto _config_local_site_struct = readConfigSite!()(_manifest, _env); // local site config ConfCompositePlus _make_and_meta_struct; - _make_and_meta_struct = configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _config_document_struct); - _make_and_meta_struct = configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _config_local_site_struct); + { /+ document config file +/ + auto _config_document_struct = readConfigDoc!()(_manifest, _env); + _make_and_meta_struct = _config_document_struct.configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); + } + { /+ local site config +/ + auto _config_local_site_struct = readConfigSite!()(_manifest, _env); + _make_and_meta_struct = _config_local_site_struct.configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); + } /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ if ((_opt_action.debug_do) @@ -72,7 +76,8 @@ template DocReformAbstraction() { _make_and_meta_struct = docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct!()( _make_and_meta_struct, - _header_body_insertfilelist_imagelist[headBody.header] + _header_body_insertfilelist_imagelist[headBody.header], + _manifest, ); if ((_opt_action.debug_do) || (_opt_action.very_verbose) diff --git a/src/doc_reform/meta/metadoc_harvest.d b/src/doc_reform/meta/metadoc_harvest.d index c3534f9..da1cae8 100644 --- a/src/doc_reform/meta/metadoc_harvest.d +++ b/src/doc_reform/meta/metadoc_harvest.d @@ -22,7 +22,10 @@ template DocReformMetaDocHarvest() { auto markup = InlineMarkup(); harvest.title = doc_matters.conf_make_meta.meta.title_full; harvest.author = doc_matters.conf_make_meta.meta.creator_author; - harvest.author_date_title = doc_matters.conf_make_meta.meta.author_date_title; + harvest.author_surname_fn = doc_matters.conf_make_meta.meta.creator_author_surname_fn; + harvest.language_original = doc_matters.conf_make_meta.meta.original_language; + harvest.language = doc_matters.src.language; + harvest.uid = doc_matters.src.doc_uid; harvest.date_published = doc_matters.conf_make_meta.meta.date_published; harvest.topic_register_arr = doc_matters.conf_make_meta.meta.classify_topic_register_arr; return harvest; -- cgit v1.2.3