aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-11-29 18:37:41 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit23920cdf33513ead479801568735f4d6545422aa (patch)
tree6be80cc175d8d32fde9aeb6488f76b5d7dc87723 /org
parentpaths, manifest (diff)
0.21.0 paths, pod manifest source alternativedoc-reform_v0.0.21
- sisupod.manifest - list alternative processable files with paths e.g.: media/text/en/live-manual.ssm media/text/fr/live-manual.ssm ... - name file followed by list of language codes e.g.: live-manual.ssm en, ca, de, es, fr, it, ja, pl, ro live-manual_next.ssm en, de, es, fr, it, ja
Diffstat (limited to 'org')
-rw-r--r--org/default_paths.org133
-rw-r--r--org/default_regex.org7
-rw-r--r--org/output_sisupod.org18
-rw-r--r--org/sdp.org107
4 files changed, 195 insertions, 70 deletions
diff --git a/org/default_paths.org b/org/default_paths.org
index 623584e..b2c1980 100644
--- a/org/default_paths.org
+++ b/org/default_paths.org
@@ -46,11 +46,11 @@ template PodManifest() {
mixin SiSUrgxInit;
static auto rgx = Rgx();
auto PodManifest(P)(
- P _pth,
+ P _pth = "",
) {
struct ManifestFile_ {
auto pod_manifest_filename() {
- string _manifest_file = "sisudoc.txt";
+ string _manifest_file = "sisupod.manifest";
return _manifest_file;
}
auto pod_manifest_path() {
@@ -61,8 +61,7 @@ template PodManifest() {
} else if (_pth.match(rgx.src_pth_contents)
&& (_pth.isFile)) {
_manifest_path = dirName(_pth);
- } else {
- // _manifest_path = "";
+ // } else { // _manifest_path = "";
}
return _manifest_path;
}
@@ -76,6 +75,111 @@ template PodManifest() {
}
#+END_SRC
+** _manifest and source files_ :manifest:
+
+#+name: template_paths_src
+#+BEGIN_SRC d
+template PodManifestAndSrcFile() {
+ mixin SiSUrgxInit;
+ static auto rgx = Rgx();
+ auto PodManifestAndSrcFile(O,E,P,F)(
+ O _opt_actions,
+ E _env,
+ P _pth = "",
+ F _fns = "",
+ char[][] _manifest_fn_list = [[]],
+ ) {
+ auto _manifest = PodManifest!()(_pth);
+ struct ManifestFilePlus_ {
+ auto pwd() {
+ return _env["pwd"];
+ }
+ auto home() {
+ return _env["home"];
+ }
+ auto opt_action() {
+ return _opt_actions;
+ }
+ auto is_pod() {
+ auto _is_pod = (_manifest.pod_manifest_path.length > 0) ? true : false;
+ return _is_pod;
+ }
+ auto pod_manifest_list_of_filenames() {
+ return _manifest_fn_list;
+ }
+ auto pod_manifest_list_of_languages() {
+ string[] _lngs;
+ foreach (filename_; pod_manifest_list_of_filenames) {
+ string _k = "en";
+ if (auto m = (filename_).match(rgx.language_code_and_filename)) {
+ _k = m.captures[1].to!string;
+ }
+ _lngs ~= _k; // all the languages from the manifest list of filenames with paths
+ }
+ return _lngs;
+ }
+ auto pod_manifest_filename() {
+ return _manifest.pod_manifest_filename;
+ }
+ auto pod_manifest_path() {
+ return _manifest.pod_manifest_path;
+ }
+ auto pod_manifest_file_with_path() {
+ return _manifest.pod_manifest_file_with_path;
+ }
+ auto pod_config_dirs() { // TODO
+ string[] _config_dirs;
+ return _config_dirs;
+ }
+ auto pod_image_dirs() { // TODO
+ string[] _image_dirs;
+ return _image_dirs;
+ }
+ auto src_fn() {
+ return _fns;
+ }
+ auto src_lng() {
+ string _k;
+ if (auto m = (src_fn).match(rgx.language_code_and_filename)) {
+ _k = m.captures[1];
+ } else {
+ _k = "en";
+ }
+ return _k;
+ }
+ auto output_path() {
+ auto _output_path = pwd;
+ if ((_opt_actions.output_dir_set.length > 0)
+ && isValidPath(_opt_actions.output_dir_set)
+ ) {
+ _output_path = asNormalizedPath(_opt_actions.output_dir_set).array;
+ if (!exists(_output_path)) {
+ _output_path.mkdirRecurse;
+ }
+ assert(_output_path.isDir);
+ }
+ return _output_path;
+ }
+ auto src_config_dirs() { // TODO
+ string[] _config_dirs;
+ if (is_pod) {
+ } else {
+ }
+ return _config_dirs;
+ }
+ auto src_image_dirs() { // TODO
+ string[] _image_dirs;
+ if (is_pod) {
+ } else {
+ }
+ return _image_dirs;
+ }
+ }
+ return ManifestFilePlus_();
+ }
+}
+#+END_SRC
+
** _config_ :config:
#+name: template_paths_src
@@ -136,7 +240,7 @@ sisupod
│  │  ├── [conf]
│   │ └── [image]
│   └── video
- └── sisudoc.txt
+ └── sisupod.manifest
_replace:_
@@ -274,10 +378,7 @@ template SiSUpathsSisupods() {
string _base_dir_pod = "sisupod";
string _base_dir_doc = "sisudoc";
string _suffix = ".zip";
- auto SiSUpathsSisupods(Ps,Lng)(
- Ps src_pth_info,
- Lng lng,
- ) {
+ auto SiSUpathsSisupods()() {
struct _PodPaths {
string base_filename_(string fn_src) {
auto pth = fn_src.baseName.stripExtension;
@@ -432,7 +533,7 @@ template SiSUpathsSisupods() {
}
return _pods();
}
- auto doc_lng(string fn_src) {
+ auto doc_lng(string fn_src, string lng) {
auto pod_root_ = pod_root(fn_src);
auto pth_1_ = text_root(fn_src).zpod.chainPath(lng).array;
auto pth_2_ = text_root(fn_src).filesystem_open_zpod.chainPath(lng).array;
@@ -478,10 +579,10 @@ template SiSUpathsSisupods() {
}
return _pods();
}
- auto fn_doc(string fn_src) {
+ auto fn_doc(string fn_src, string lng) {
auto pod_root_ = pod_root(fn_src);
- auto pth_1_ = doc_lng(fn_src).zpod.chainPath(fn_src.baseName).array;
- auto pth_2_ = doc_lng(fn_src).filesystem_open_zpod.chainPath(fn_src.baseName).array;
+ auto pth_1_ = doc_lng(fn_src, lng).zpod.chainPath(fn_src.baseName).array;
+ auto pth_2_ = doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_src.baseName).array;
struct _pods {
auto zpod() {
return pth_1_;
@@ -493,10 +594,10 @@ template SiSUpathsSisupods() {
}
return _pods();
}
- auto fn_doc_insert(string fn_src, string fn_insert) {
+ auto fn_doc_insert(string fn_src, string fn_insert, string lng) {
auto pod_root_ = pod_root(fn_src);
- auto pth_1_ = doc_lng(fn_src).zpod.chainPath(fn_insert.baseName).array;
- auto pth_2_ = doc_lng(fn_src).filesystem_open_zpod.chainPath(fn_insert.baseName).array;
+ auto pth_1_ = doc_lng(fn_src, lng).zpod.chainPath(fn_insert.baseName).array;
+ auto pth_2_ = doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_insert.baseName).array;
struct _pods {
auto zpod() {
return pth_1_;
diff --git a/org/default_regex.org b/org/default_regex.org
index 334b025..92197ef 100644
--- a/org/default_regex.org
+++ b/org/default_regex.org
@@ -412,10 +412,13 @@ static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg")
#+name: prgmkup_rgx
#+BEGIN_SRC d
static src_pth = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`);
-static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+)/sisudoc[.]txt$`);
+static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+)/sisupod[.]manifest$`);
static src_pth_zip = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`);
static src_pth_unzip_pod = ctRegex!(`^(?P<path>media/text/[a-z]{2}/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`);
-static src_pth_types = ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/sisudoc[.]txt)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`);
+static src_pth_types =
+ ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/sisupod[.]manifest)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`);
+static pod_content_location =
+ ctRegex!(`^(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])(?P<languages>(?:\s+[a-z]{2}(?:,|$))+)`, "mg");
static src_fn =
ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`);
static src_fn_master = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`);
diff --git a/org/output_sisupod.org b/org/output_sisupod.org
index 398af1c..a267384 100644
--- a/org/output_sisupod.org
+++ b/org/output_sisupod.org
@@ -63,9 +63,8 @@ debug(asserts) {
mixin SiSUoutputRgxInit;
string pwd = doc_matters.environment["pwd"];
auto src_path_info = doc_matters.src_path_info;
-string lng = doc_matters.language;
auto pth_sisudoc_src = doc_matters.src_path_info;
-auto pths_sisupod = SiSUpathsSisupods!()(src_path_info, lng);
+auto pths_sisupod = SiSUpathsSisupods!()();
mixin SiSUlanguageCodes;
auto lang = Lang();
static auto rgx = Rgx();
@@ -95,8 +94,8 @@ if (doc_matters.opt_action.source) {
if (!exists(pths_sisupod.image_root(doc_matters.source_filename).filesystem_open_zpod)) {
pths_sisupod.image_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse;
}
- if (!exists(pths_sisupod.doc_lng(doc_matters.source_filename).filesystem_open_zpod)) {
- pths_sisupod.doc_lng(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse;
+ if (!exists(pths_sisupod.doc_lng(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod)) {
+ pths_sisupod.doc_lng(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod.mkdirRecurse;
}
}
#+END_SRC
@@ -108,7 +107,7 @@ if (doc_matters.opt_action.source) {
debug(sisupod) {
writeln(__LINE__, ": ",
doc_matters.source_filename, " -> ",
- pths_sisupod.fn_doc(doc_matters.source_filename).filesystem_open_zpod
+ pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod
);
}
auto zip = new ZipArchive();
@@ -157,9 +156,9 @@ auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.source_filename).zpo
}
} { /+ TODO bundle primary file +/
auto fn_src_in = doc_matters.source_filename;
- auto fn_src_out_sisupod_zip_base = pths_sisupod.fn_doc(doc_matters.source_filename).zpod.to!string;
- auto fn_src_out_filesystem = pths_sisupod.fn_doc(doc_matters.source_filename).filesystem_open_zpod.to!string; // needed without root path:
- auto fn_src_out_inside_pod = pths_sisupod.fn_doc(doc_matters.source_filename).zpod.to!string; // needed without root path:
+ auto fn_src_out_sisupod_zip_base = pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).zpod.to!string;
+ auto fn_src_out_filesystem = pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod.to!string; // needed without root path:
+ auto fn_src_out_inside_pod = pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).zpod.to!string; // needed without root path:
string[] filelist_src_out_sisupod_arr;
string[] filelist_src_zpod_arr;
if (exists(fn_src_in)) {
@@ -190,6 +189,7 @@ auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.source_filename).zpo
pths_sisupod.fn_doc_insert(
doc_matters.source_filename,
insert_file,
+ doc_matters.language,
).zpod
);
}
@@ -198,11 +198,13 @@ auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.source_filename).zpo
pths_sisupod.fn_doc_insert(
doc_matters.source_filename,
insert_file,
+ doc_matters.language,
).zpod.to!string;
auto fn_src_out_filesystem =
pths_sisupod.fn_doc_insert(
doc_matters.source_filename,
insert_file,
+ doc_matters.language,
).filesystem_open_zpod.to!string;
if (exists(fn_src_in)) {
if (doc_matters.opt_action.source) {
diff --git a/org/sdp.org b/org/sdp.org
index fb00a4b..32e9833 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -26,11 +26,9 @@ struct Version {
int minor;
int patch;
}
-enum ver = Version(0, 20, 2);
+enum ver = Version(0, 21, 0);
#+END_SRC
-#+NAME: version_txt
-
** compilation restrictions (supported compilers)
http://dlang.org/spec/version.html#predefined-versions
@@ -80,9 +78,9 @@ void main(string[] args) {
<<sdp_args>>
<<sdp_env>>
<<sdp_do_selected>>
- if (fns_src.length > 0) {
- foreach(fn_src; fns_src) {
- if (!empty(fn_src)) {
+ if (_manifests.length > 1) { // _manifests[0] is dummy element used in initialization to be removed
+ foreach(manifest; _manifests[1..$]) {
+ if (!empty(manifest.src_fn)) {
<<sdp_each_file_do_scope>>
<<sdp_abstraction>>
<<sdp_each_file_do_debugs_checkdoc>>
@@ -193,7 +191,6 @@ mixin outputHub;
#+NAME: sdp_args
#+BEGIN_SRC d
-string[] fns_src;
string flag_action;
string arg_unrecognized;
enum dAM { abstraction, matters }
@@ -484,13 +481,21 @@ auto _opt_action = OptActions();
#+NAME: sdp_args
#+BEGIN_SRC d
+auto _env = [
+ "pwd" : environment["PWD"],
+ "home" : environment["HOME"],
+];
+auto _manifest = PodManifest!()();
+auto _manifest_plus = PodManifestAndSrcFile!()(_opt_action, _env);
+auto _manifests = [ _manifest_plus ];
foreach(arg; args[1..$]) {
- auto _manifest = PodManifest!()(arg);
+ _manifest = PodManifest!()(arg);
if (arg.match(rgx.flag_action)) {
flag_action ~= " " ~ arg; // flags not taken by getopt
} else if (arg.match(rgx.src_pth)) {
- fns_src ~= arg; // gather input markup source file names for processing
+ _manifests ~= PodManifestAndSrcFile!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing
} else if (_manifest.pod_manifest_file_with_path) {
+ string contents_location_raw_;
string contents_location_;
string sisudoc_txt_ = _manifest.pod_manifest_file_with_path;
enforce(
@@ -500,7 +505,7 @@ foreach(arg; args[1..$]) {
);
try {
if (exists(sisudoc_txt_)) {
- contents_location_ = sisudoc_txt_.readText;
+ contents_location_raw_ = sisudoc_txt_.readText;
}
}
catch (ErrnoException ex) {
@@ -508,6 +513,15 @@ foreach(arg; args[1..$]) {
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 { // (file name with path \n)+
+ contents_location_ = contents_location_raw_;
+ }
auto contents_locations_arr =
(cast(char[]) contents_location_).split;
auto tmp_dir_ = (sisudoc_txt_).dirName.array;
@@ -521,7 +535,9 @@ foreach(arg; args[1..$]) {
if (_opt_action.languages_set[0] == "all"
|| (contents_location_pth_).match(lang_rgx_)
) {
- fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]);
+ auto _fns = (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(string);
+ _manifest_plus = PodManifestAndSrcFile!()(_opt_action, _env, arg, _fns, contents_locations_arr);
+ _manifests ~= _manifest_plus; // TODO how to capture?
}
}
} else if (arg.match(rgx.src_pth_zip)) {
@@ -532,26 +548,16 @@ foreach(arg; args[1..$]) {
}
#+END_SRC
-**** environment :environment:
-
-#+NAME: sdp_env
-#+BEGIN_SRC d
-auto env = [
- "pwd" : environment["PWD"],
- "home" : environment["HOME"],
-];
-#+END_SRC
-
**** TODO config files (load & read) (so far only SDLang) :config:files:
#+NAME: sdp_conf_files
#+BEGIN_SRC d
-auto sdl_root_config_share = configRead!()("config_share", env);
-auto sdl_root_config_local = configRead!()("config_local", env);
+auto sdl_root_config_share = configRead!()("config_share", _env);
+auto sdl_root_config_local = configRead!()("config_local", _env);
auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_share, sdl_root_config_local);
#+END_SRC
-** 2a. actions independed of processing files
+** 2a. actions independent of processing files
#+NAME: sdp_do_selected
#+BEGIN_SRC d
if (!(_opt_action.skip_output)) {
@@ -578,14 +584,14 @@ scope(failure) {
stderr.writefln(
"~ document run failure ~ (%s v%s)\n\t%s",
__VENDOR__, __VERSION__,
- fn_src
+ src_fn
);
}
}
enforce(
- fn_src.match(rgx.src_pth_types),
+ manifest.src_fn.match(rgx.src_pth_types),
"not a sisu markup filename: «" ~
- fn_src ~ "»"
+ manifest.src_fn ~ "»"
);
#+END_SRC
@@ -597,7 +603,7 @@ enforce(
#+NAME: sdp_abstraction
#+BEGIN_SRC d
-auto t = SiSUabstraction!()(fn_src, _opt_action, env);
+auto t = SiSUabstraction!()(manifest, _opt_action, _env);
static assert(!isTypeTuple!(t));
static assert(t.length==2);
auto doc_abstraction = t[dAM.abstraction];
@@ -647,10 +653,10 @@ scope(exit) {
debug(checkdoc) {
writefln(
"processed file: %s",
- fn_src
+ manifest.src_fn
);
}
- destroy(fn_src);
+ destroy(manifest);
}
#+END_SRC
@@ -674,10 +680,10 @@ template SiSUabstraction() {
enum makeMeta { make, meta }
enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images }
static auto rgx = Rgx();
- auto SiSUabstraction(Fn,O,E)(
- Fn fn_src,
+ auto SiSUabstraction(M,O,E)(
+ M _manifest,
O _opt_action,
- E env,
+ E _env,
){
<<sdp_conf_files>>
<<sdp_each_file_do_read_and_split_sisu_markup_file_content_into_header_and_body>>
@@ -694,12 +700,12 @@ template SiSUabstraction() {
** 1. (a) _read in raw file_ (b) split content into: _doc header & doc content_
- [[./meta_read_source_files.org][meta_read_source_files]]
-- read in the source marked up document and
+- read in the _marked up source document_ and
- split the document into:
- document header
- document body
- if a master document make a list of insert files
-- return a tuple of:
+- _return a tuple of_:
- header
- body
- insert file list
@@ -712,7 +718,7 @@ debug(steps) {
writeln(__LINE__, ":", __FILE__, ": step1 commence → (get document header & body & insert files)");
}
auto _header_body_inserts =
- SiSUrawMarkupContent!()(fn_src);
+ SiSUrawMarkupContent!()(_manifest.src_fn);
static assert(!isTypeTuple!(_header_body_inserts));
static assert(_header_body_inserts.length==3);
debug(steps) {
@@ -728,12 +734,12 @@ debug(header_and_body) {
** 2. _document metadata_ & _make instructions_ :doc:header:metadata:make:
- [[./meta_conf_make_meta.org][meta_conf_make_meta]]
-- read document header, split into:
+- read _document header_, split into:
- metadata
- make instructions
- read config files
- consolidate make instructions
-- return tuple of:
+- _return tuple of_:
- document metadata
- make instructions (from configuration files & document header make
instructions)
@@ -756,7 +762,7 @@ debug(steps) {
- prepare the document abstraction used in downstream processing
-- return tuple of:
+- _return tuple of_:
- document abstraction (_the_document_ or doc_abstraction)
- document abstraction keys
- (head, toc, body, endnotes, glossary, bibliography, bookindex, blurb,
@@ -817,25 +823,29 @@ struct DocumentMatters {
return _k;
}
auto source_filename() {
- string _k = fn_src;
+ string _k = _manifest.src_fn;
return _k;
}
auto src_path_info() {
- string _pwd = env["pwd"];
- auto _k = SiSUpathsSRC!()(_pwd, fn_src);
+ string _pwd = _env["pwd"];
+ auto _k = SiSUpathsSRC!()(_pwd, _manifest.src_fn);
return _k;
}
auto opt_action() {
+ /+ getopt options, commandline instructions, raw
+ - processing instructions --epub --html etc.
+ - command line config instructions --output-path
+ +/
auto _k = _opt_action;
return _k;
}
auto environment() {
- auto _k = env;
+ auto _k = _env;
return _k;
}
auto language() {
string _k;
- if (auto m = fn_src.match(rgx.language_code_and_filename)) {
+ if (auto m = (_manifest.src_fn).match(rgx.language_code_and_filename)) {
_k = m.captures[1];
} else {
_k = "en";
@@ -846,6 +856,15 @@ struct DocumentMatters {
string[] _k = _header_body_inserts[headBody.insert_filelist];
return _k;
}
+ auto pod_manifest() {
+ /+ extensive information on
+ - source processing paths
+ - repetition of opt_action with additional processing, including
+ - output path if any
+ +/
+ auto _k = _manifest;
+ return _k;
+ }
auto image_list() {
auto _k = _images;
return _k;