aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/sdp.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2018-01-25 17:13:52 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit524baa6ddd5f9cb49b1c5b015fbd6ef75ff72968 (patch)
treec66713d8559aa04f15f95825a6f5faec16827ce6 /org/sdp.org
parent0.23.3 work on source & target file paths/locations (diff)
paths, further adjustmentsdoc-reform_v0.0.23
Diffstat (limited to 'org/sdp.org')
-rw-r--r--org/sdp.org316
1 files changed, 115 insertions, 201 deletions
diff --git a/org/sdp.org b/org/sdp.org
index 799f4ec..d277ec0 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -59,12 +59,12 @@ version (Posix) {
** 0. sdp src/sdp :template:
+- process files (act according to requirements of each type)
+ - by sourcefilename
+ - by sourcefiles contents identifier
+ - by zip filename
+
#+BEGIN_SRC d :tangle ../src/sdp/sdp.d :shebang #!/usr/bin/env rdmd
-/+
- sdp: sisu document parser
- a SiSU document parser writen in D
- see http://sisudoc.org.
-+/
module sdp.sisu_document_parser;
import
sdp.conf.compile_time_info,
@@ -72,7 +72,11 @@ import
<<imports_sdp>>
<<mixin_sdp_version>>
<<mixin_pre_main>>
-/++ A SiSU document parser writen in D. +/
+/++
+name "sdp"
+description "A SiSU inspired document parser writen in D."
+homepage "http://sisudoc.org"
++/
void main(string[] args) {
<<sdp_mixin>>
<<sdp_args>>
@@ -82,7 +86,7 @@ void main(string[] args) {
foreach(manifest; _manifests[1..$]) {
if (!empty(manifest.src.filename)) {
<<sdp_each_file_do_scope>>
- <<sdp_abstraction>>
+ <<sdp_each_file_do_abstraction>>
<<sdp_each_file_do_debugs_checkdoc>>
<<sdp_each_file_do_selected_output>>
<<sdp_each_file_do_scope_exit>>
@@ -93,11 +97,6 @@ void main(string[] args) {
}
}
unittest {
- /++
- name "sdp"
- description "A SiSU document parser writen in D."
- homepage "http://sisudoc.org"
- +/
}
#+END_SRC
@@ -134,9 +133,9 @@ import
├── src
│   ├── sdp.d
│   └── sdp
-│    ├── metadoc_from_src.d
-│    ├── ...
-│    └── compile_time_info.d
+│ ├── conf
+│ ├── meta
+│ └── output
└── views
   └── version.txt
@@ -150,6 +149,7 @@ import
[[./sdp.org][sdp]]
keep up to date, configuration in ../maker.org
+
check:
- http://github.com/Abscissa/SDLang-D
- https://github.com/abscissa/libInputVisitor
@@ -326,158 +326,121 @@ if (helpInfo.helpWanted) {
#+BEGIN_SRC d
struct OptActions {
auto assertions() {
- auto _k = opts["assertions"];
- return _k;
+ return opts["assertions"];
}
auto concordance() {
- auto _k = opts["concordance"];
- return _k;
+ return opts["concordance"];
}
auto debug_do() {
- auto _k = opts["debug"];
- return _k;
+ return opts["debug"];
}
auto digest() {
- auto _k = opts["digest"];
- return _k;
+ return opts["digest"];
}
auto docbook() {
- auto _k = opts["docbook"];
- return _k;
+ return opts["docbook"];
}
auto epub() {
- auto _k = opts["epub"];
- return _k;
+ return opts["epub"];
}
auto html() {
- auto _k = opts["html"];
- return _k;
+ return opts["html"];
}
auto html_seg() {
- auto _k = opts["html-seg"];
- return _k;
+ return opts["html-seg"];
}
auto html_scroll() {
- auto _k = opts["html-scroll"];
- return _k;
+ return opts["html-scroll"];
}
auto manifest() {
- auto _k = opts["manifest"];
- return _k;
+ return opts["manifest"];
}
auto ocn() {
- auto _k = opts["ocn"];
- return _k;
+ return opts["ocn"];
}
auto odt() {
- auto _k = opts["odt"];
- return _k;
+ return opts["odt"];
}
auto pdf() {
- auto _k = opts["pdf"];
- return _k;
+ return opts["pdf"];
}
auto postgresql() {
- auto _k = opts["postgresql"];
- return _k;
+ return opts["postgresql"];
}
auto qrcode() {
- auto _k = opts["qrcode"];
- return _k;
+ return opts["qrcode"];
}
auto sisupod() {
- auto _k = opts["sisupod"];
- return _k;
+ return opts["sisupod"];
}
auto source() {
- auto _k = opts["source"];
- return _k;
+ return opts["source"];
}
auto sqlite_discrete() {
- auto _k = opts["sqlite-discrete"];
- return _k;
+ return opts["sqlite-discrete"];
}
auto sqlite_update() {
- auto _k = opts["sqlite-update"];
- return _k;
+ return opts["sqlite-update"];
}
auto sqlite_create() {
- auto _k = opts["sqlite-create"];
- return _k;
+ return opts["sqlite-create"];
}
auto sqlite_drop() {
- auto _k = opts["sqlite-drop"];
- return _k;
+ return opts["sqlite-drop"];
}
auto text() {
- auto _k = opts["text"];
- return _k;
+ return opts["text"];
}
auto verbose() {
- auto _k = opts["verbose"];
- return _k;
+ return opts["verbose"];
}
auto xhtml() {
- auto _k = opts["xhtml"];
- return _k;
+ return opts["xhtml"];
}
auto xml_dom() {
- auto _k = opts["xml-dom"];
- return _k;
+ return opts["xml-dom"];
}
auto xml_sax() {
- auto _k = opts["xml-sax"];
- return _k;
+ return opts["xml-sax"];
}
auto section_toc() {
- auto _k = opts["section_toc"];
- return _k;
+ return opts["section_toc"];
}
auto section_body() {
- auto _k = opts["section_body"];
- return _k;
+ return opts["section_body"];
}
auto section_endnotes() {
- auto _k = opts["section_endnotes"];
- return _k;
+ return opts["section_endnotes"];
}
auto section_glossary() {
- auto _k = opts["section_glossary"];
- return _k;
+ return opts["section_glossary"];
}
auto section_biblio() {
- auto _k = opts["section_biblio"];
- return _k;
+ return opts["section_biblio"];
}
auto section_bookindex() {
- auto _k = opts["section_bookindex"];
- return _k;
+ return opts["section_bookindex"];
}
auto section_blurb() {
- auto _k = opts["section_blurb"];
- return _k;
+ return opts["section_blurb"];
}
auto backmatter() {
- auto _k = opts["backmatter"];
- return _k;
+ return opts["backmatter"];
}
auto skip_output() {
- auto _k = opts["skip-output"];
- return _k;
+ return opts["skip-output"];
}
auto languages_set() {
- auto _k = settings["lang"].split(",");
- return _k;
+ return settings["lang"].split(",");
}
auto output_dir_set() {
- auto _k = settings["output-dir"];
- return _k;
+ return settings["output-dir"];
}
}
auto _opt_action = OptActions();
#+END_SRC
-***** getopt processing path, _manifest[] >>
+***** getopt processing path, _manifest[] >>
#+NAME: sdp_args
#+BEGIN_SRC d
@@ -504,24 +467,28 @@ foreach(arg; args[1..$]) {
"file not found: «" ~
sisudoc_txt_ ~ "»"
);
- try {
- if (exists(sisudoc_txt_)) {
- contents_location_raw_ = sisudoc_txt_.readText;
+ if (exists(sisudoc_txt_)) {
+ try {
+ if (exists(sisudoc_txt_)) {
+ contents_location_raw_ = sisudoc_txt_.readText;
+ }
}
- }
- catch (ErrnoException ex) {
- }
- catch (FileException ex) {
- // Handle errors
- }
- if (contents_location_raw_.match(rgx.pod_content_location)) { // (file name followed by language codes \n)+
- foreach (m; contents_location_raw_.matchAll(rgx.pod_content_location)) {
- foreach (n; m.captures[2].matchAll(rgx.language_codes)) {
- contents_location_ ~= "media/text/" ~ n.captures[1].to!string ~ "/" ~ m.captures[1].to!string ~ "\n";
+ catch (ErrnoException ex) {
+ }
+ catch (FileException ex) {
+ // Handle errors
+ }
+ if (contents_location_raw_.match(rgx.pod_content_location)) { // (file name followed by language codes \n)+
+ foreach (m; contents_location_raw_.matchAll(rgx.pod_content_location)) {
+ foreach (n; m.captures[2].matchAll(rgx.language_codes)) {
+ contents_location_ ~= "media/text/" ~ n.captures[1].to!string ~ "/" ~ m.captures[1].to!string ~ "\n";
+ }
}
+ } else {
+ contents_location_ = contents_location_raw_;
}
- } else { // (file name with path \n)+
- contents_location_ = contents_location_raw_;
+ } else {
+ writeln("manifest not found: ", sisudoc_txt_);
}
auto contents_locations_arr
= (cast(char[]) contents_location_).split;
@@ -542,7 +509,11 @@ foreach(arg; args[1..$]) {
}
}
} else if (arg.match(rgx.src_pth_sst_or_ssm)) {
- _manifests ~= PathMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing
+ if (exists(arg)==0) {
+ writeln("ERROR >> Processing Skipped! File not found: ", arg);
+ } else {
+ _manifests ~= PathMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing
+ }
} else if (arg.match(rgx.src_pth_zip)) {
// fns_src ~= arg; // gather input markup source file names for processing
} else { // anything remaining, unused
@@ -564,11 +535,17 @@ auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_documen
#+NAME: sdp_do_selected
#+BEGIN_SRC d
if (!(_opt_action.skip_output)) {
+ debug(steps) {
+ writeln("step0 commence → (without processing files)");
+ }
outputHubOp!()(_opt_action);
+ debug(steps) {
+ writeln("- step0 complete");
+ }
}
#+END_SRC
-** _2b. processing: loop each file_ [+2] :loop:files:
+** _2b. processing: (loop each file)_ [+2] :loop:files:
*** scope (loop) :scope:
#+NAME: sdp_each_file_do_scope
@@ -604,7 +581,7 @@ enforce(
- doc_abstraction (the document)
- doc_matters
-#+NAME: sdp_abstraction
+#+NAME: sdp_each_file_do_abstraction
#+BEGIN_SRC d
auto t = SiSUabstraction!()(_env, _opt_action, manifest);
static assert(!isTypeTuple!(t));
@@ -644,7 +621,13 @@ if ((doc_matters.opt.action.debug_do)
#+BEGIN_SRC d
/+ ↓ output hub +/
if (!(doc_matters.opt.action.skip_output)) {
+ debug(steps) {
+ writeln("step5 commence → (process outputs)");
+ }
outputHub!()(doc_abstraction, doc_matters);
+ debug(steps) {
+ writeln("- step5 complete");
+ }
}
#+END_SRC
@@ -700,7 +683,7 @@ template SiSUabstraction() {
}
#+END_SRC
-** 1. raw file content split, doc: _header_, _content_ +(lists: subdocs? images?) >>
+** 1. raw file content split, doc: _header_, _content_ +(lists: subdocs? images?) >>
- [[./meta_read_source_files.org][meta_read_source_files]]
- read in the _marked up source document_ and
@@ -731,8 +714,7 @@ if build source pod requested all information needed to build it available at th
/+ ↓ read file (filename with path) +/
/+ ↓ file tuple of header and content +/
debug(steps) {
- writeln(__LINE__, ":", __FILE__,
- ": step1 commence → (get document header & body & insert file list & if needed image list)"
+ writeln("step1 commence → (get document header & body & insert file list & if needed image list)"
);
}
auto _header_body_insertfilelist_imagelist
@@ -740,7 +722,7 @@ auto _header_body_insertfilelist_imagelist
static assert(!isTypeTuple!(_header_body_insertfilelist_imagelist));
static assert(_header_body_insertfilelist_imagelist.length==4);
debug(steps) {
- writeln(__LINE__, ":", __FILE__, ": step1 complete");
+ writeln("- step1 complete");
}
debug(header_and_body) {
writeln(header);
@@ -766,21 +748,19 @@ debug(header_and_body) {
#+BEGIN_SRC d
/+ ↓ split header into make and meta +/
debug(steps) {
- writeln(__LINE__, ":", __FILE__,
- ": step2 commence → (doc header: make & meta as struct)"
- );
+ writeln("step2 commence → (read document header - toml or sdlang, return struct)");
}
auto _make_and_meta_struct
= docHeaderMakeAndMetaTupExtractAndConvertToStruct!()(
conf_files_composite_make,
_header_body_insertfilelist_imagelist[headBody.header]
- ); // breakage ...
+ );
debug(steps) {
- writeln(__LINE__, ":", __FILE__, ": step2 complete");
+ writeln("- step2 complete");
}
#+END_SRC
-** 3. _document abstraction, tuple_ (output-pre-processing) >>
+** 3. _document abstraction, tuple_ (output-pre-processing) >>
- [[./meta_abstraction.org][meta_abstraction]]
- prepare the document abstraction used in downstream processing
@@ -798,7 +778,7 @@ debug(steps) {
#+BEGIN_SRC d
/+ ↓ document abstraction: process document, return abstraction as tuple +/
debug(steps) {
- writeln(__LINE__, ":", __FILE__, ": step3 commence → (document abstraction (da); da keys; segnames; doc_matters)");
+ writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters)");
}
auto da = SiSUdocAbstraction!()(
_header_body_insertfilelist_imagelist[headBody.body_content],
@@ -813,11 +793,11 @@ string[] _doc_html_segnames = da[docAbst.segnames];
string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4];
auto _images = da[docAbst.images];
debug(steps) {
- writeln(__LINE__, ":", __FILE__, ": step3 complete");
+ writeln("- step3 complete");
}
#+END_SRC
-** 4. _document matters_ (doc info gathered, various sources) >>
+** 4. _document matters_ (doc info gathered, various sources) >>
- prepare document_matters, miscellany about processing and the document of use
in downstream processing
@@ -825,12 +805,11 @@ debug(steps) {
#+NAME: sdp_each_file_do_document_matters
#+BEGIN_SRC d
debug(steps) {
- writeln(__LINE__, ":", __FILE__, ": step4 commence → (doc_matters)");
+ writeln("step4 commence → (doc_matters)");
}
struct DocumentMatters {
auto conf_make_meta() { // TODO meld with all make instructions
- auto _k = _make_and_meta_struct;
- return _k;
+ return _make_and_meta_struct;
}
auto env() {
struct Env_ {
@@ -856,51 +835,15 @@ struct DocumentMatters {
return Opt_();
}
auto src() {
+ return _manifest.src;
+ }
+ auto src_path_info() {
+ return SiSUpathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path
+ }
+ auto srcs() {
struct SRC_ {
- auto is_pod() {
- return _manifest.src.is_pod;
- }
- auto filename() {
- return _manifest.src.filename;
- }
- auto language() {
- return _manifest.src.lng;
- }
- auto path_info() {
- auto _k = SiSUpathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path
- return _k;
- }
- auto file_with_absolute_path() {
- auto _k = _manifest.src.file_with_absolute_path;
- return _k;
- }
- auto absolute_path_to_src() {
- auto _k = _manifest.src.absolute_path_to_src;
- return _k;
- }
- auto base_dir() {
- auto _k = _manifest.src.base_dir;
- return _k;
- }
- auto base_parent_dir_path() {
- auto _k = _manifest.src.base_parent_dir_path;
- return _k;
- }
- auto base_dir_path() {
- auto _k = _manifest.src.base_dir_path;
- return _k;
- }
- auto media_dir_path() {
- auto _k = _manifest.src.media_dir_path;
- return _k;
- }
- auto base_parent_dir() {
- auto _k = _manifest.src.base_parent_dir;
- return _k;
- }
auto file_insert_list() {
- string[] _k = _header_body_insertfilelist_imagelist[headBody.insert_file_list];
- return _k;
+ return _header_body_insertfilelist_imagelist[headBody.insert_file_list];
}
auto image_list() {
return _images;
@@ -909,48 +852,19 @@ struct DocumentMatters {
return SRC_();
}
auto pod() {
- struct Pod_ {
- auto src_is_pod() {
- return _manifest.pod.src_is_pod;
- }
- auto manifest_list_of_filenames() {
- return _manifest.pod.manifest_list_of_filenames;
- }
- auto manifest_list_of_languages() {
- return _manifest.pod.manifest_list_of_languages;
- }
- auto manifest_filename() {
- return _manifest.pod.manifest_filename;
- }
- auto manifest_path() {
- return _manifest.pod.manifest_path;
- }
- auto manifest_file_with_path() {
- return _manifest.pod.manifest_file_with_path;
- }
- auto config_dirs() {
- return _manifest.pod.config_dirs;
- }
- auto image_dirs() {
- return _manifest.pod.image_dirs;
- }
- }
- return Pod_();
+ return _manifest.pod;
}
auto xml() {
struct XML_ {
auto keys_seq() {
/+ contains .seg & .scroll sequences +/
- auto _k = _document_section_keys_sequenced;
- return _k;
+ return _document_section_keys_sequenced;
}
string[] segnames() {
- string[] _k = _doc_html_segnames;
- return _k;
+ return _doc_html_segnames;
}
string[] segnames_lv_0_to_4() {
- string[] _k = _doc_epub_segnames_0_4;
- return _k;
+ return _doc_epub_segnames_0_4;
}
}
return XML_();
@@ -961,7 +875,7 @@ struct DocumentMatters {
}
auto doc_matters = DocumentMatters();
debug(steps) {
- writeln(__LINE__, ":", __FILE__, ": step4 complete");
+ writeln("- step4 complete");
}
#+END_SRC