aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/doc_reform.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2019-05-22 10:50:33 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-10-17 19:07:20 -0400
commite973365c4b74be2b2cff9be970ccba5928dbe368 (patch)
treef5af8c28ba939095b9c1310c5ea7b91816c12ddf /org/doc_reform.org
parent0.7.2 latex (for pdf) (initial stub) (diff)
0.7.3 start to look at document harvest (initial stub)
Diffstat (limited to 'org/doc_reform.org')
-rw-r--r--org/doc_reform.org227
1 files changed, 186 insertions, 41 deletions
diff --git a/org/doc_reform.org b/org/doc_reform.org
index 12eb46a..7bb8029 100644
--- a/org/doc_reform.org
+++ b/org/doc_reform.org
@@ -27,7 +27,7 @@ struct Version {
int minor;
int patch;
}
-enum _ver = Version(0, 7, 2);
+enum _ver = Version(0, 7, 3);
#+END_SRC
** compilation restrictions (supported compilers)
@@ -71,8 +71,7 @@ version (Posix) {
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;
<<imports_doc_reform>>
import std.algorithm;
import std.parallelism;
@@ -86,6 +85,7 @@ homepage "http://sisudoc.org"
+/
void main(string[] args) {
<<doc_reform_mixin>>
+ <<doc_reform_init>>
<<doc_reform_args>>
<<doc_reform_do_selected>>
if (_manifests.length > 1 // _manifests[0] initialized dummy element
@@ -117,6 +117,38 @@ 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);
+ }
+ }
}
#+END_SRC
@@ -193,6 +225,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,
@@ -266,7 +299,25 @@ mixin outputHub;
**** init :init:
-#+NAME: doc_reform_args
+#+NAME: doc_reform_init
+#+BEGIN_SRC d
+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;
+#+END_SRC
+
+**** args :args:
+
+#+NAME: doc_reform_init
#+BEGIN_SRC d
string flag_action;
string arg_unrecognized;
@@ -276,7 +327,7 @@ static auto rgx = Rgx();
*** scope (run complete) :scope:
-#+NAME: doc_reform_args
+#+NAME: doc_reform_init
#+BEGIN_SRC d
scope(success) {
writefln(
@@ -311,6 +362,9 @@ bool[string] opts = [
"debug" : false,
"digest" : false,
"epub" : false,
+ "harvest" : false,
+ "harvest-authors" : false,
+ "harvest-topics" : false,
"html" : false,
"html-seg" : false,
"html-scroll" : false,
@@ -366,6 +420,9 @@ auto helpInfo = getopt(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"],
@@ -449,6 +506,22 @@ struct OptActions {
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"])
@@ -886,7 +959,29 @@ if ((doc_matters.opt.action.debug_do)
#+BEGIN_SRC d
/+ ↓ debugs +/
if (doc_matters.opt.action.verbose) {
- DocReformAbstractionSummary!()(doc_abstraction, doc_matters);
+ DocReformMetaDocSummary!()(doc_abstraction, doc_matters);
+}
+#+END_SRC
+
+**** 0. abstraction harvest :abstraction:harvest:
+- abstraction harvest
+
+#+NAME: doc_reform_each_file_do_debugs_checkdoc
+#+BEGIN_SRC d
+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);
}
#+END_SRC
@@ -947,34 +1042,6 @@ break; // terminate, stop
#+END_SRC
* 2. pre-processing
-** Harvest _get document head_ for harvest (separate thread)
-*** 0 module template
-- harvest, get document head
-
-#+BEGIN_SRC d :tangle "../src/doc_reform/meta/metadochead.d"
-module doc_reform.meta.metadochead;
-template DocReformHarvestGetFromHead() { // TODO
- <<imports_doc_reform>>
- <<doc_reform_mixin>>
- enum headBody { header, body_content, insert_file_list, image_list }
- enum makeMeta { make, meta }
- static auto rgx = Rgx();
- auto DocReformHarvestGetFromHead(E,O,M)( // TODO
- E _env,
- O _opt_action,
- M _manifest
- ){
- <<doc_reform_conf_files_in_toml>>
- <<doc_reform_each_file_do_read_and_split_sisu_markup_file_content_into_header_and_body>>
- <<doc_reform_each_file_do_split_sisu_markup_file_header_into_make_and_meta_structs>>
- <<doc_reform_each_file_do_document_matters_abridged>>
- auto t = tuple(doc_matters_shared, doc_matters_abridged_collected);
- static assert(t.length==2);
- return t;
- }
-}
-#+END_SRC
-
** Output _document abstraction functions_ :module:doc_reform:abstraction:
*** 0 module template
- abstraction template
@@ -1294,13 +1361,13 @@ if ((_opt_action.debug_do)
#+END_SRC
* 3. document abstraction _summary_ :module:doc_reform:metadoc_summary:
-** 0. module template
+** 0. module template metadoc summary
- document summary from abstraction
#+BEGIN_SRC d :tangle "../src/doc_reform/meta/metadoc_summary.d"
module doc_reform.meta.metadoc_summary;
-template DocReformAbstractionSummary() {
- void DocReformAbstractionSummary(S,T)(
+template DocReformMetaDocSummary() {
+ void DocReformMetaDocSummary(S,T)(
const S doc_abstraction,
T doc_matters,
) {
@@ -1308,7 +1375,7 @@ template DocReformAbstractionSummary() {
mixin InternalMarkup;
<<metadoc_summary_initialize>>
if (doc_matters.opt.action.verbose) {
- <<meta_metadoc_summary>>
+ <<meta_metadoc_summary_document>>
}
}
}
@@ -1344,7 +1411,7 @@ auto markup = InlineMarkup();
** (last ocn)
-#+name: meta_metadoc_summary
+#+name: meta_metadoc_summary_document
#+BEGIN_SRC d
string[string] check = [
"last_object_number" : "NA [debug \"checkdoc\" not run]",
@@ -1372,9 +1439,9 @@ foreach (k; doc_matters.has.keys_seq.seg) {
}
#+END_SRC
-** summary
+** document summary
-#+name: meta_metadoc_summary
+#+name: meta_metadoc_summary_document
#+BEGIN_SRC d
auto min_repeat_number = 66;
auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length
@@ -1439,6 +1506,84 @@ writefln(
);
#+END_SRC
+** 0. module template metadoc harvest
+
+#+BEGIN_SRC d :tangle "../src/doc_reform/meta/metadoc_harvest.d"
+module doc_reform.meta.metadoc_harvest;
+template DocReformMetaDocHarvest() {
+ auto DocReformMetaDocHarvest(T,H)(
+ T doc_matters,
+ H harvest,
+ ) {
+ <<metadoc_harvest_imports>>
+ mixin InternalMarkup;
+ <<metadoc_harvest_initialize>>
+ <<meta_metadoc_harvest>>
+ }
+}
+#+END_SRC
+
+** init
+*** imports
+
+#+name: metadoc_harvest_imports
+#+BEGIN_SRC d
+import
+ doc_reform.meta.defaults,
+ doc_reform.meta.rgx;
+import
+ std.array,
+ std.exception,
+ std.regex,
+ std.stdio,
+ std.string,
+ std.traits,
+ std.typecons,
+ std.uni,
+ std.utf,
+ std.conv : to;
+#+END_SRC
+
+*** initialize :report:
+
+#+name: metadoc_harvest_initialize
+#+BEGIN_SRC d
+auto markup = InlineMarkup();
+#+END_SRC
+
+** harvest summary
+
+#+name: meta_metadoc_harvest_summary
+#+BEGIN_SRC d
+auto min_repeat_number = 66;
+auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length
+ + doc_matters.conf_make_meta.meta.creator_author.length + 4);
+char_repeat_number = (char_repeat_number > min_repeat_number)
+? char_repeat_number
+: min_repeat_number;
+writefln(
+ "%s\n\"%s\", %s\n%s\n%s\n%s",
+ markup.repeat_character_by_number_provided("-", char_repeat_number),
+ doc_matters.conf_make_meta.meta.title_full,
+ doc_matters.conf_make_meta.meta.creator_author,
+ doc_matters.src.filename,
+ doc_matters.conf_make_meta.meta.classify_topic_register_arr,
+ markup.repeat_character_by_number_provided("-", char_repeat_number),
+);
+#+END_SRC
+
+** return harvest
+
+#+name: meta_metadoc_harvest
+#+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.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;
+#+END_SRC
+
* __END__
dev notes