diff options
Diffstat (limited to 'org/sdp.org')
-rw-r--r-- | org/sdp.org | 107 |
1 files changed, 63 insertions, 44 deletions
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; |