aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/sdp.d
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 /src/sdp/sdp.d
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 'src/sdp/sdp.d')
-rwxr-xr-xsrc/sdp/sdp.d51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d
index af3a0a0..34f11d9 100755
--- a/src/sdp/sdp.d
+++ b/src/sdp/sdp.d
@@ -39,7 +39,6 @@ void main(string[] args) {
mixin SiSUbiblio;
mixin SiSUrgxInitFlags;
mixin outputHub;
- string[] fns_src;
string flag_action;
string arg_unrecognized;
enum dAM { abstraction, matters }
@@ -299,13 +298,21 @@ void main(string[] args) {
}
}
auto _opt_action = OptActions();
+ 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(
@@ -315,7 +322,7 @@ void main(string[] args) {
);
try {
if (exists(sisudoc_txt_)) {
- contents_location_ = sisudoc_txt_.readText;
+ contents_location_raw_ = sisudoc_txt_.readText;
}
}
catch (ErrnoException ex) {
@@ -323,6 +330,15 @@ void main(string[] args) {
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;
@@ -336,7 +352,9 @@ void main(string[] args) {
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)) {
@@ -345,16 +363,13 @@ void main(string[] args) {
arg_unrecognized ~= " " ~ arg;
}
}
- auto env = [
- "pwd" : environment["PWD"],
- "home" : environment["HOME"],
- ];
+
if (!(_opt_action.skip_output)) {
outputHubOp!()(_opt_action);
}
- 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)) {
scope(success) {
debug(checkdoc) {
writefln(
@@ -369,16 +384,16 @@ void main(string[] args) {
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 ~ "»"
);
- 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];
@@ -401,10 +416,10 @@ void main(string[] args) {
debug(checkdoc) {
writefln(
"processed file: %s",
- fn_src
+ manifest.src_fn
);
}
- destroy(fn_src);
+ destroy(manifest);
}
} else {
/+ no recognized filename provided +/