diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-11-25 22:06:40 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-12-23 18:17:41 -0500 |
commit | f6d28b62f0e02b8a88a1832589e203c7a613f45b (patch) | |
tree | b5d6462e45bae998190194784e02b143a83f79a3 /src/doc_reform/io_in | |
parent | gitignore & things nix (diff) |
regex review, match speed & compile time, ctregex
- improve match time
- add interim fontface identifier marker
- improve compile time
- remove unused regexs
- separate out some specialized output matches
Diffstat (limited to 'src/doc_reform/io_in')
-rw-r--r-- | src/doc_reform/io_in/paths_source.d | 38 | ||||
-rw-r--r-- | src/doc_reform/io_in/read_config_files.d | 20 | ||||
-rw-r--r-- | src/doc_reform/io_in/read_source_files.d | 24 |
3 files changed, 46 insertions, 36 deletions
diff --git a/src/doc_reform/io_in/paths_source.d b/src/doc_reform/io_in/paths_source.d index c34ac43..24f12b9 100644 --- a/src/doc_reform/io_in/paths_source.d +++ b/src/doc_reform/io_in/paths_source.d @@ -63,10 +63,10 @@ import std.conv : to; import doc_reform.meta.defaults, - doc_reform.meta.rgx; + doc_reform.meta.rgx_files; template PodManifest() { - mixin spineRgxIn; - static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); @safe auto PodManifest(O)( O _opt_action, string _pth="" @@ -81,12 +81,12 @@ template PodManifest() { && (exists(_pth.chainPath(pod_manifest_filename).array) != 0 && (_pth.chainPath(pod_manifest_filename).array).isFile)) { _manifest_path = _pth; - } else if (_pth.match(rgx.src_pth_contents) + } else if (_pth.match(rgx_files.src_pth_contents) && exists(_pth) != 0 && _pth.isFile) { _manifest_path = _pth.dirName; - } else if (_pth.match(rgx.src_pth_pod_sst_or_ssm) + } else if (_pth.match(rgx_files.src_pth_pod_sst_or_ssm) && exists(_pth) != 0 && (_pth.isFile)) { - if (auto m = _pth.match(rgx.src_pth_pod_sst_or_ssm)) { + if (auto m = _pth.match(rgx_files.src_pth_pod_sst_or_ssm)) { _manifest_path = m.captures["podpath"]; } } else { @@ -118,9 +118,9 @@ template PodManifest() { } } template PathMatters() { - mixin spineRgxIn; mixin InternalMarkup; - static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); static auto mkup = InlineMarkup(); @safe auto PathMatters(O,E)( O _opt_action, @@ -193,7 +193,7 @@ template PathMatters() { string[] _lngs; foreach (filename_; manifest_list_of_filenames) { string _k = "en"; - if (auto m = (filename_).match(rgx.language_code_and_filename)) { + if (auto m = (filename_).match(rgx_files.language_code_and_filename)) { _k = m.captures[1].to!string; } _lngs ~= _k; // all the languages from the manifest list of filenames with paths @@ -230,11 +230,11 @@ template PathMatters() { return filename.stripExtension; } @safe string filename_extension() { - return filename.match(rgx.src_pth_sst_or_ssm).captures["extension"]; + return filename.match(rgx_files.src_pth_sst_or_ssm).captures["extension"]; } @safe string lng() { string _k; - if (auto m = path_and_fn.match(rgx.language_code_and_filename)) { + if (auto m = path_and_fn.match(rgx_files.language_code_and_filename)) { _k = m.captures[1]; } else {_k = "en"; } return _k; @@ -318,7 +318,7 @@ template PathMatters() { } else { _dir = ((path_and_fn.chainPath("../../../")).asNormalizedPath).array; assert(_dir == absolute_path_to_src - .match(rgx.src_base_parent_dir_name).captures["dir"]); + .match(rgx_files.src_base_parent_dir_name).captures["dir"]); } if (_opt_action.debug_do) { writeln("--> (base_dir) ", _dir); @@ -341,7 +341,7 @@ template PathMatters() { string _dir; if ( auto m = (absolute_path_to_src) - .match(rgx.src_formalised_file_path_parts) + .match(rgx_files.src_formalised_file_path_parts) ) { _dir = ((m.captures["pth"]).asNormalizedPath).array; } else if ( @@ -396,7 +396,7 @@ template PathMatters() { ) { _dir = m.captures["dir"]; } else { - _dir = (absolute_path_to_src).match(rgx.src_base_parent_dir_name).captures["dir"]; + _dir = (absolute_path_to_src).match(rgx_files.src_base_parent_dir_name).captures["dir"]; } if (_opt_action.debug_do) { writeln("--> (base_parent_dir) ", _dir); @@ -460,8 +460,6 @@ template PathMatters() { } } template configFilePaths() { - mixin spineRgxIn; - static auto rgx = RgxI(); @safe auto configFilePaths(M,E)( M _manifested, E _env, @@ -581,8 +579,8 @@ template configFilePaths() { } } template spinePathsSRC() { - mixin spineRgxIn; - static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); @safe auto spinePathsSRC(D,Fn)( D _pwd, Fn _fn_src_and_path, @@ -594,7 +592,7 @@ template spinePathsSRC() { @safe string language() { // use command line info as well? string _k; - if (auto m = _fn_src_and_path.match(rgx.language_code_and_filename)) { + if (auto m = _fn_src_and_path.match(rgx_files.language_code_and_filename)) { _k = m.captures[1]; } else { /+ unknown until doc_meta read, (could provide & use command line info?) +/ _k = "xx"; // original default was "en" but is not known @@ -632,8 +630,6 @@ template spinePathsSRC() { template spinePathsPods() { - mixin spineRgxIn; - static auto rgx = RgxI(); string _suffix = ".zip"; auto spinePathsPods(M)(M doc_matters) { string _base_dir_pod = (doc_matters.output_path.length > 0) diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d index 64d548b..a1aa425 100644 --- a/src/doc_reform/io_in/read_config_files.d +++ b/src/doc_reform/io_in/read_config_files.d @@ -56,9 +56,11 @@ module doc_reform.io_in.read_config_files; import std.file, - std.path, + std.path; +import doc_reform.meta, doc_reform.io_in.paths_source, + doc_reform.meta.rgx_files, doc_reform.meta.rgx; template readConfigSite() { @@ -191,13 +193,17 @@ webserv: static template readConfigDoc() { import std.file, - std.path, + std.path; + import doc_reform.meta, doc_reform.io_in.paths_source, + doc_reform.meta.rgx_files, doc_reform.meta.rgx; @system final auto readConfigDoc(M,E)(M _manifested, E _env) { mixin spineRgxIn; static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); string config_file_str; string conf_filename = "NONE"; auto _conf_file_details = configFilePaths!()(_manifested, _env); @@ -243,9 +249,12 @@ static template readConfigDoc() { static template configReadSiteYAML() { import std.file, - std.path, + std.path; + import doc_reform.meta, - doc_reform.io_in.paths_source; + doc_reform.io_in.paths_source, + doc_reform.meta.rgx_files, + doc_reform.meta.rgx; @safe final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); auto _conf_file_details = configFilePaths!()(_manifested, _env); @@ -257,7 +266,8 @@ static template configReadSiteYAML() { static template configReadDocYAML() { import std.file, - std.path, + std.path; + import doc_reform.meta, doc_reform.io_in.paths_source; @safe final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) { diff --git a/src/doc_reform/io_in/read_source_files.d b/src/doc_reform/io_in/read_source_files.d index 4c8cf77..0a187f8 100644 --- a/src/doc_reform/io_in/read_source_files.d +++ b/src/doc_reform/io_in/read_source_files.d @@ -57,12 +57,16 @@ module doc_reform.io_in.read_source_files; template spineRawMarkupContent() { import std.file, - std.path, + std.path; + import doc_reform.meta, doc_reform.io_in.paths_source, + doc_reform.meta.rgx_files, doc_reform.meta.rgx; mixin spineRgxIn; static auto rgx = RgxI(); + mixin spineRgxFiles; + static auto rgx_files = RgxFiles(); string[] _images=[]; @safe string[] _extract_images(S)(S content_block) { string[] images_; @@ -108,7 +112,7 @@ template spineRawMarkupContent() { = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str); char[] header_raw = t.header; char[][] sourcefile_body_content = t.src_txt; - if (fn_src.match(rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise + if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise auto ins = Inserts(); ContentsInsertsImages tu = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src); @@ -175,9 +179,9 @@ template spineRawMarkupContent() { return source_line_arr; } @safe string markupSourceReadIn(in string fn_src) { - static auto rgx = RgxI(); + static auto rgx_files = RgxFiles(); enforce( - fn_src.match(rgx.src_pth_sst_or_ssm), + fn_src.match(rgx_files.src_pth_sst_or_ssm), "not a dr markup filename: «" ~ fn_src ~ "»" ); @@ -226,7 +230,7 @@ template spineRawMarkupContent() { char[][] contents_insert; int code_block_status = 0; enum codeBlock { off, curly, tic, } - auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); + auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; foreach (line; markup_sourcefile_insert_content) { if (code_block_status == codeBlock.curly) { @@ -245,14 +249,14 @@ template spineRawMarkupContent() { } else if (line.matchFirst(rgx.block_tic_code_open)) { code_block_status = codeBlock.tic; contents_insert ~= line; - } else if (auto m = line.match(rgx.insert_src_fn_ssi_or_sst)) { + } else if (auto m = line.match(rgx_files.insert_src_fn_ssi_or_sst)) { auto insert_fn = m.captures[2]; auto insert_sub_pth = m.captures[1]; auto fn_src_insert = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array; auto raw = MarkupRawUnit(); auto markup_sourcesubfile_insert_content - = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); + = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx_files.src_fn_find_inserts); debug(insert_file) { writeln(line); writeln(fn_src_insert); @@ -300,7 +304,7 @@ template spineRawMarkupContent() { char[][] contents; int code_block_status = 0; enum codeBlock { off, curly, tic, } - auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); + auto fn_pth_full = fn_src.match(rgx_files.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; char[][] contents_insert; string[] _images =[]; @@ -322,7 +326,7 @@ template spineRawMarkupContent() { } else if (line.matchFirst(rgx.block_tic_code_open)) { code_block_status = codeBlock.tic; contents ~= line; - } else if (auto m = line.match(rgx.insert_src_fn_ssi_or_sst)) { + } else if (auto m = line.match(rgx_files.insert_src_fn_ssi_or_sst)) { auto insert_fn = m.captures[2]; auto insert_sub_pth = m.captures[1]; auto fn_src_insert @@ -331,7 +335,7 @@ template spineRawMarkupContent() { auto raw = MarkupRawUnit(); /+ TODO +/ auto markup_sourcefile_insert_content - = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); + = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx_files.src_fn_find_inserts); debug(insert_file) { writeln(line); writeln(fn_src_insert); |