From dcbc43ba94c484c7b5741bc9efc88b51e9b04e31 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jan 2019 13:28:27 -0500 Subject: doc generator info related --- org/doc_reform.org | 62 +++++++++++++++++++++++++++++++++++++++++-- src/doc_reform/doc_reform.d | 20 ++++++++++++-- src/doc_reform/meta/metadoc.d | 39 ++++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 5 deletions(-) diff --git a/org/doc_reform.org b/org/doc_reform.org index bef16f0..422d25c 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -125,6 +125,7 @@ void main(string[] args) { #+NAME: imports_doc_reform #+BEGIN_SRC d import + std.datetime, std.getopt, std.file, std.path, @@ -594,6 +595,21 @@ auto _opt_action = OptActions(); #+NAME: doc_reform_args #+BEGIN_SRC d +auto program_info() { + struct ProgramInfo { + string name() { + return program_name; + } + auto ver() { + string ver_ = format( + "%s.%s.%s", + _ver.major, _ver.minor, _ver.patch, + ); + return ver_; + } + } + return ProgramInfo(); +} auto _env = [ "pwd" : environment["PWD"], "home" : environment["HOME"], @@ -751,7 +767,7 @@ if ((_opt_action.debug_do) ) { writeln("--->\nstepX commence → (document abstraction)"); } -auto t = DocReformAbstraction!()(_env, _opt_action, manifest); +auto t = DocReformAbstraction!()(_env, program_info, _opt_action, manifest); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; @@ -843,8 +859,9 @@ template DocReformAbstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, tag_assoc, images } static auto rgx = Rgx(); - auto DocReformAbstraction(E,O,M)( + auto DocReformAbstraction(E,P,O,M)( E _env, + P program_info, O _opt_action, M _manifest ){ @@ -1011,6 +1028,47 @@ if ((_opt_action.debug_do) struct DocumentMatters { #+END_SRC +**** generator related + +#+NAME: doc_reform_each_file_do_document_matters +#+BEGIN_SRC d + auto generator_program() { + struct Prog_ { + auto name() { + return program_info.name; + } + auto ver() { + return program_info.ver; + } + auto name_and_version() { + return format( + "%s-%s", + program_info.name, + program_info.ver, + ); + } + auto url_home() { + return "http://sisudoc.org"; + } + auto url_git() { + return "https://git.sisudoc.org/software/sisu"; + } + } + return Prog_(); + } + auto generated_time() { + auto _st = Clock.currTime(UTC()); + auto _time = _st.year.to!string + ~ "-" ~ _st.month.to!int.to!string // prefer as month number + ~ "-" ~ _st.day.to!string + ~ " [" ~ _st.isoWeek.to!string ~ "/" ~ _st.dayOfWeek.to!int.to!string ~ "]" + ~ " " ~ _st.hour.to!string + ~ ":" ~ _st.minute.to!string + ~ ":" ~ _st.second.to!string; + return _time; + } +#+END_SRC + **** config make & meta #+NAME: doc_reform_each_file_do_document_matters diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index f1d8d18..53ddbcf 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -4,6 +4,7 @@ import doc_reform.conf.compile_time_info, doc_reform.meta.metadoc; import + std.datetime, std.getopt, std.file, std.path, @@ -396,6 +397,21 @@ void main(string[] args) { } } auto _opt_action = OptActions(); + auto program_info() { + struct ProgramInfo { + string name() { + return program_name; + } + auto ver() { + string ver_ = format( + "%s.%s.%s", + _ver.major, _ver.minor, _ver.patch, + ); + return ver_; + } + } + return ProgramInfo(); + } auto _env = [ "pwd" : environment["PWD"], "home" : environment["HOME"], @@ -518,7 +534,7 @@ void main(string[] args) { ) { writeln("--->\nstepX commence → (document abstraction)"); } - auto t = DocReformAbstraction!()(_env, _opt_action, manifest); + auto t = DocReformAbstraction!()(_env, program_info, _opt_action, manifest); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; @@ -598,7 +614,7 @@ void main(string[] args) { ) { writeln("--->\nstepX commence → (document abstraction)"); } - auto t = DocReformAbstraction!()(_env, _opt_action, manifest); + auto t = DocReformAbstraction!()(_env, program_info, _opt_action, manifest); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index 4cb218e..a57159d 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -1,6 +1,7 @@ module doc_reform.meta.metadoc; template DocReformAbstraction() { import + std.datetime, std.getopt, std.file, std.path, @@ -28,8 +29,9 @@ template DocReformAbstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, tag_assoc, images } static auto rgx = Rgx(); - auto DocReformAbstraction(E,O,M)( + auto DocReformAbstraction(E,P,O,M)( E _env, + P program_info, O _opt_action, M _manifest ){ @@ -112,6 +114,41 @@ template DocReformAbstraction() { writeln("step4 commence → (doc_matters)"); } struct DocumentMatters { + auto generator_program() { + struct Prog_ { + auto name() { + return program_info.name; + } + auto ver() { + return program_info.ver; + } + auto name_and_version() { + return format( + "%s-%s", + program_info.name, + program_info.ver, + ); + } + auto url_home() { + return "http://sisudoc.org"; + } + auto url_git() { + return "https://git.sisudoc.org/software/sisu"; + } + } + return Prog_(); + } + auto generated_time() { + auto _st = Clock.currTime(UTC()); + auto _time = _st.year.to!string + ~ "-" ~ _st.month.to!int.to!string // prefer as month number + ~ "-" ~ _st.day.to!string + ~ " [" ~ _st.isoWeek.to!string ~ "/" ~ _st.dayOfWeek.to!int.to!string ~ "]" + ~ " " ~ _st.hour.to!string + ~ ":" ~ _st.minute.to!string + ~ ":" ~ _st.second.to!string; + return _time; + } auto conf_make_meta() { // TODO meld with all make instructions return _make_and_meta_struct; } -- cgit v1.2.3