aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-11-20 17:26:34 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commitfc3eb717cec28209659beb9de2fd90578348ff6a (patch)
tree3562e16e23074ee9a92013778720490f98b64e88
parentprocess pod dir with sisudoc.txt (or file) (diff)
sdp, select language source to process
-rw-r--r--org/sdp.org24
-rw-r--r--src/sdp/meta/metadoc.d7
-rwxr-xr-xsrc/sdp/sdp.d17
3 files changed, 40 insertions, 8 deletions
diff --git a/org/sdp.org b/org/sdp.org
index d0d7eaf..af7fe98 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -269,6 +269,10 @@ bool[string] opts = [
"backmatter" : true,
"skip-output" : false,
];
+string[string] settings = [
+ "output-dir" : "",
+ "lang" : "all",
+];
auto helpInfo = getopt(args,
std.getopt.config.passThrough,
"assert", "--assert set optional assertions on", &opts["assertions"],
@@ -309,6 +313,8 @@ auto helpInfo = getopt(args,
"section-blurb", "--section-blurb process document blurb (default)", &opts["section_blurb"],
"backmatter", "--section-backmatter process document backmatter (default)", &opts["backmatter"],
"skip-output", "--skip-output", &opts["skip-output"],
+ "output-dir", "--output-dir=[dir path]", &settings["output-dir"],
+ "lang", "--lang=[lang code e.g. =en or =en,es]", &settings["lang"],
);
if (helpInfo.helpWanted) {
defaultGetoptPrinter("Some information about the program.", helpInfo.options);
@@ -345,10 +351,15 @@ foreach(arg; args[1..$]) {
foreach (contents_location; contents_locations_arr) {
assert(contents_location.match(rgx.src_pth),
"not a recognised file: «" ~
- contents_location ~ "»"
+ contents_location ~ "»"
);
auto contents_location_pth_ = (contents_location).to!string;
- fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]);
+ auto lang_rgx_ = regex(r"/(" ~ settings["lang"].split(",").join("|") ~ ")/");
+ if (settings["lang"] == "all"
+ || (contents_location_pth_).match(lang_rgx_)
+ ) {
+ fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]);
+ }
}
} else if (arg.match(rgx.src_pth_zip)) {
// fns_src ~= arg; // gather input markup source file names for processing
@@ -423,7 +434,7 @@ enforce(
#+NAME: sdp_abstraction
#+BEGIN_SRC d
-auto t = SiSUabstraction!()(fn_src, opts, env);
+auto t = SiSUabstraction!()(fn_src, opts, settings, env);
static assert(!isTypeTuple!(t));
static assert(t.length==2);
auto doc_abstraction = t[dAM.abstraction];
@@ -500,9 +511,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)(
+ auto SiSUabstraction(Fn,O,S,E)(
Fn fn_src,
O opts,
+ S settings,
E env,
){
<<sdp_conf_files>>
@@ -655,6 +667,10 @@ struct DocumentMatters {
bool[string] _k = opts;
return _k;
}
+ auto opt_settings() {
+ string[string] _k = settings;
+ return _k;
+ }
auto environment() {
auto _k = env;
return _k;
diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d
index eca4df7..8d83340 100644
--- a/src/sdp/meta/metadoc.d
+++ b/src/sdp/meta/metadoc.d
@@ -31,9 +31,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)(
+ auto SiSUabstraction(Fn,O,S,E)(
Fn fn_src,
O opts,
+ S settings,
E env,
){
auto sdl_root_config_share = configRead!()("config_share", env);
@@ -118,6 +119,10 @@ template SiSUabstraction() {
bool[string] _k = opts;
return _k;
}
+ auto opt_settings() {
+ string[string] _k = settings;
+ return _k;
+ }
auto environment() {
auto _k = env;
return _k;
diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d
index 375f91f..330fe7a 100755
--- a/src/sdp/sdp.d
+++ b/src/sdp/sdp.d
@@ -98,6 +98,10 @@ void main(string[] args) {
"backmatter" : true,
"skip-output" : false,
];
+ string[string] settings = [
+ "output-dir" : "",
+ "lang" : "all",
+ ];
auto helpInfo = getopt(args,
std.getopt.config.passThrough,
"assert", "--assert set optional assertions on", &opts["assertions"],
@@ -138,6 +142,8 @@ void main(string[] args) {
"section-blurb", "--section-blurb process document blurb (default)", &opts["section_blurb"],
"backmatter", "--section-backmatter process document backmatter (default)", &opts["backmatter"],
"skip-output", "--skip-output", &opts["skip-output"],
+ "output-dir", "--output-dir=[dir path]", &settings["output-dir"],
+ "lang", "--lang=[lang code e.g. =en or =en,es]", &settings["lang"],
);
if (helpInfo.helpWanted) {
defaultGetoptPrinter("Some information about the program.", helpInfo.options);
@@ -174,10 +180,15 @@ void main(string[] args) {
foreach (contents_location; contents_locations_arr) {
assert(contents_location.match(rgx.src_pth),
"not a recognised file: «" ~
- contents_location ~ "»"
+ contents_location ~ "»"
);
auto contents_location_pth_ = (contents_location).to!string;
- fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]);
+ auto lang_rgx_ = regex(r"/(" ~ settings["lang"].split(",").join("|") ~ ")/");
+ if (settings["lang"] == "all"
+ || (contents_location_pth_).match(lang_rgx_)
+ ) {
+ fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]);
+ }
}
} else if (arg.match(rgx.src_pth_zip)) {
// fns_src ~= arg; // gather input markup source file names for processing
@@ -218,7 +229,7 @@ void main(string[] args) {
"not a sisu markup filename: «" ~
fn_src ~ "»"
);
- auto t = SiSUabstraction!()(fn_src, opts, env);
+ auto t = SiSUabstraction!()(fn_src, opts, settings, env);
static assert(!isTypeTuple!(t));
static assert(t.length==2);
auto doc_abstraction = t[dAM.abstraction];