diff options
Diffstat (limited to 'src/doc_reform/doc_reform.d')
-rwxr-xr-x | src/doc_reform/doc_reform.d | 104 |
1 files changed, 100 insertions, 4 deletions
diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index 06866c2..908a3a6 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -53,8 +53,7 @@ module doc_reform.sisu_document_parser; import doc_reform.conf.compile_time_info, - doc_reform.meta.metadoc, - doc_reform.meta.metadochead; + doc_reform.meta.metadoc; import std.datetime, std.getopt, @@ -64,6 +63,7 @@ import import doc_reform.meta, doc_reform.meta.metadoc_summary, + doc_reform.meta.metadoc_harvest, doc_reform.meta.metadoc_from_src, doc_reform.meta.conf_make_meta_structs, doc_reform.meta.conf_make_meta_toml, @@ -91,6 +91,18 @@ void main(string[] args) { mixin DocReformBiblio; mixin DocReformRgxInitFlags; mixin outputHub; + struct Harvest { + string title = ""; + string author = ""; + string author_date_title = ""; + string date_published = ""; + string[] topic_register_arr = [""]; + string html_seg_toc = ""; + string html_scroll = ""; + string epub = ""; + } + Harvest harvested; + Harvest[] harvests; string flag_action; string arg_unrecognized; enum dAM { abstraction, matters } @@ -119,6 +131,9 @@ void main(string[] args) { "debug" : false, "digest" : false, "epub" : false, + "harvest" : false, + "harvest-authors" : false, + "harvest-topics" : false, "html" : false, "html-seg" : false, "html-scroll" : false, @@ -174,6 +189,9 @@ void main(string[] args) { "debug", "--debug", &opts["debug"], "digest", "--digest hash digest for each object", &opts["digest"], "epub", "--epub process epub output", &opts["epub"], + "harvest", "--harvest extract info on authors & topics from document header metadata", &opts["harvest"], + "harvest-authors", "--harvest-authors extract info on authors from document header metadata", &opts["harvest-authors"], + "harvest-topics", "--harvest-topics extract info on topics from document header metadata", &opts["harvest-topics"], "html", "--html process html output", &opts["html"], "html-seg", "--html-seg process html output", &opts["html-seg"], "html-scroll", "--html-seg process html output", &opts["html-scroll"], @@ -250,6 +268,22 @@ void main(string[] args) { bool epub() { return opts["epub"]; } + bool harvest() { + bool _is = ( + opts["harvest"] + || opts["harvest-authors"] + || opts["harvest-topics"] + ) + ? true + : false; + return _is; + } + bool harvest_authors() { + return opts["harvest-authors"]; + } + bool harvest_topics() { + return opts["harvest-topics"]; + } bool html() { bool _is; if ( opts["html"] || opts["html-seg"] || opts["html-scroll"]) @@ -637,7 +671,22 @@ void main(string[] args) { } /+ ↓ debugs +/ if (doc_matters.opt.action.verbose) { - DocReformAbstractionSummary!()(doc_abstraction, doc_matters); + DocReformMetaDocSummary!()(doc_abstraction, doc_matters); + } + if (doc_matters.opt.action.harvest) { + if (doc_matters.opt.action.harvest_authors) { + } + if (doc_matters.opt.action.harvest_topics) { + } + Harvest[] DocReformMetaDocHarvests()( + Harvest harvested, + Harvest[] harvests, + ) { + harvests ~= harvested; + return harvests; + } + harvested = DocReformMetaDocHarvest!()(doc_matters, harvested); + harvests = DocReformMetaDocHarvests!()(harvested, harvests); } /+ ↓ debugs +/ if (doc_matters.opt.action.debug_do) { @@ -717,7 +766,22 @@ void main(string[] args) { } /+ ↓ debugs +/ if (doc_matters.opt.action.verbose) { - DocReformAbstractionSummary!()(doc_abstraction, doc_matters); + DocReformMetaDocSummary!()(doc_abstraction, doc_matters); + } + if (doc_matters.opt.action.harvest) { + if (doc_matters.opt.action.harvest_authors) { + } + if (doc_matters.opt.action.harvest_topics) { + } + Harvest[] DocReformMetaDocHarvests()( + Harvest harvested, + Harvest[] harvests, + ) { + harvests ~= harvested; + return harvests; + } + harvested = DocReformMetaDocHarvest!()(doc_matters, harvested); + harvests = DocReformMetaDocHarvests!()(harvested, harvests); } /+ ↓ debugs +/ if (doc_matters.opt.action.debug_do) { @@ -755,4 +819,36 @@ void main(string[] args) { } } } + if (_opt_action.verbose + && harvests.length > 1 + ) { + auto min_repeat_number = 42; + foreach(doc_harvest; harvests) { + 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), + doc_harvest.title, + doc_harvest.author, + (doc_harvest.date_published.length > 0) ? " (" ~ doc_harvest.date_published ~ ")" : "", + ); + string[] _topic_arr; + foreach(topic; doc_harvest.topic_register_arr.sort) { + foreach (i, _top; topic.split(mkup.sep)) { + writeln(" ", (" ".repeat(i).join), "- ", _top); + } + } + } + string[] _author_date_title; + foreach(doc_harvest; harvests) { + _author_date_title ~= doc_harvest.author_date_title; + } + foreach(_adt; _author_date_title.sort) { + writeln(_adt); + } + } } |