diff options
Diffstat (limited to 'src/doc_reform/io_in')
-rw-r--r-- | src/doc_reform/io_in/paths_source.d | 133 | ||||
-rw-r--r-- | src/doc_reform/io_in/read_config_files.d | 12 | ||||
-rw-r--r-- | src/doc_reform/io_in/read_source_files.d | 21 |
3 files changed, 84 insertions, 82 deletions
diff --git a/src/doc_reform/io_in/paths_source.d b/src/doc_reform/io_in/paths_source.d index 2bb5c4d..8d12f98 100644 --- a/src/doc_reform/io_in/paths_source.d +++ b/src/doc_reform/io_in/paths_source.d @@ -53,6 +53,7 @@ meta_config_files.d +/ module doc_reform.io_in.paths_source; +@safe: import std.array, std.file, @@ -66,7 +67,7 @@ import template PodManifest() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); - @safe auto PodManifest(O)( + auto PodManifest(O)( O _opt_action, string _pth="" ) { @@ -74,7 +75,7 @@ template PodManifest() { string pod_manifest_filename() { return "pod.manifest"; } - @safe string pod_manifest_path() { + string pod_manifest_path() { string _manifest_path; if ((isValidPath(_pth) && exists(_pth) != 0 && _pth.isDir) && (exists(_pth.chainPath(pod_manifest_filename).array) != 0 @@ -96,10 +97,10 @@ template PodManifest() { } return _manifest_path; } - @safe string pods_collection_root_path() { + string pods_collection_root_path() { return (pod_manifest_path.length > 0) ? ((chainPath(pod_manifest_path, "..")).asNormalizedPath).array.to!string : ""; } - @safe string pod_manifest_file_with_path() { + string pod_manifest_file_with_path() { string _k; if (exists(pod_manifest_path.chainPath(pod_manifest_filename).array)!=0) { _k = pod_manifest_path.chainPath(pod_manifest_filename).array; @@ -121,14 +122,14 @@ template PathMatters() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); static auto mkup = InlineMarkup(); - @safe auto PathMatters(O,E)( + auto PathMatters(O,E)( O _opt_action, E _env, string _pth, string _fns = "", char[][] _manifest_fn_list = [[]], ) { - @safe auto _manifested = PodManifest!()(_opt_action, _pth); + auto _manifested = PodManifest!()(_opt_action, _pth); struct ManifestMatters_ { auto env() { auto _env = _env; @@ -142,7 +143,7 @@ template PathMatters() { } return Env_(); } - @safe auto opt() { + auto opt() { struct Opt_ { auto action() { return _opt_action; @@ -150,45 +151,45 @@ template PathMatters() { } return Opt_(); } - @safe bool src_is_pod() { + bool src_is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - @safe auto pod() { + auto pod() { struct Pod_ { - @safe bool src_is_pod() { + bool src_is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - @safe string collection_root() { + string collection_root() { return _manifested.pods_collection_root_path; } - @safe string manifest_filename() { + string manifest_filename() { return _manifested.pod_manifest_filename; } - @safe string manifest_path() { + string manifest_path() { return _manifested.pod_manifest_path; } - @safe string pod_name_with_path() { + string pod_name_with_path() { return _manifested.pod_manifest_path.baseName; } - @safe string manifest_file_with_path() { + string manifest_file_with_path() { return _manifested.pod_manifest_file_with_path; } - @safe string[] config_dr_document_make_dirs() { + string[] config_dr_document_make_dirs() { string[] _config_dirs; return _config_dirs; } - @safe string[] config_local_site_dirs() { + string[] config_local_site_dirs() { string[] _config_dirs; return _config_dirs; } - @safe string[] image_dirs() { + string[] image_dirs() { string[] _image_dirs; return _image_dirs; } - @safe auto manifest_list_of_filenames() { + auto manifest_list_of_filenames() { return _manifest_fn_list; } - @safe string[] manifest_list_of_languages() { + string[] manifest_list_of_languages() { string[] _lngs; foreach (filename_; manifest_list_of_filenames) { string _k = "en"; @@ -202,43 +203,43 @@ template PathMatters() { } return Pod_(); } - @safe auto src() { + auto src() { string _fns = _fns; // required here by dmd & not by ldc (for D:2078) auto _opt_action = _opt_action; auto _env = _env; struct SRC_ { - @safe bool is_pod() { + bool is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - @safe string path_and_fn() { + string path_and_fn() { return _fns; } - @safe string pod_name_with_path() { + string pod_name_with_path() { return (is_pod) ? _manifested.pod_manifest_path : ""; } - @safe string pods_collection_root_path() { + string pods_collection_root_path() { return (is_pod) ? _manifested.pods_collection_root_path : ""; } - @safe string pod_name() { + string pod_name() { return pod_name_with_path.baseName; } - @safe string filename() { + string filename() { return path_and_fn.baseName; } - @safe string filename_base() { + string filename_base() { return filename.stripExtension; } - @safe string filename_extension() { + string filename_extension() { return filename.match(rgx_files.src_pth_sst_or_ssm).captures["extension"]; } - @safe string lng() { + string lng() { string _k; if (auto m = path_and_fn.match(rgx_files.language_code_and_filename)) { _k = m.captures[1]; } else {_k = "en"; } return _k; } - @safe string doc_uid() { + string doc_uid() { string _uid; if (is_pod && !(pod_name_with_path.empty)) { if (pod_name_with_path.baseName == filename_base) { @@ -251,7 +252,7 @@ template PathMatters() { } return _uid; } - @safe string doc_uid_out() { + string doc_uid_out() { string _uid; if (is_pod && !(pod_name_with_path.empty)) { if (pod_name_with_path.baseName == filename_base) { @@ -264,7 +265,7 @@ template PathMatters() { } return _uid; } - @safe string docname_composite_unique_per_src_doc() { + string docname_composite_unique_per_src_doc() { string _fn; if (pod_name_with_path.baseName == filename_base) { _fn = filename_base ~ mkup.uid_sep ~ filename_extension ~ mkup.uid_sep ~ lng; @@ -275,7 +276,7 @@ template PathMatters() { } return _fn; } - @safe string docname_composite_unique_per_src_pod() { + string docname_composite_unique_per_src_pod() { /+ z pod name if any + src filename (without lng code) filename ~ mkup.uid_sep ~ lng @@ -294,19 +295,19 @@ template PathMatters() { } return _fn; } - @safe string language() { + string language() { return lng(); } - @safe string file_with_absolute_path() { + string file_with_absolute_path() { return _env["pwd"].chainPath(path_and_fn).array; } - @safe string absolute_path_to_src() { + string absolute_path_to_src() { return (_env["pwd"].chainPath(path_and_fn)).dirName.array; } - @safe string path_to_doc_root_path_to_lang_and_filename() { + string path_to_doc_root_path_to_lang_and_filename() { return _env["pwd"].chainPath(path_and_fn).array; } - @safe string base_dir() { + string base_dir() { string _dir; if ( auto m = (absolute_path_to_src) @@ -324,7 +325,7 @@ template PathMatters() { } return _dir; } - @safe string base_parent_dir_path() { + string base_parent_dir_path() { string _dir; if ( auto m = (absolute_path_to_src) @@ -336,7 +337,7 @@ template PathMatters() { } return _dir; } - @safe string base_dir_path() { + string base_dir_path() { string _dir; if ( auto m = (absolute_path_to_src) @@ -356,11 +357,11 @@ template PathMatters() { } return _dir; } - @safe string media_dir_path() { + string media_dir_path() { string _dir = ((base_dir_path.chainPath("media")).asNormalizedPath).array; return _dir; } - @safe string image_dir_path() { + string image_dir_path() { string _paths; string[] _possible_img_pths = [ "./image", "../image", "../../image" ]; string _img_pth_found = ""; @@ -384,10 +385,10 @@ template PathMatters() { } return _img_pth_found; } - @safe auto conf_dir_path() { + auto conf_dir_path() { return ((base_dir_path.chainPath("conf")).asNormalizedPath).array; } - @safe auto base_parent_dir() { + auto base_parent_dir() { string _dir; if ( auto m = (absolute_path_to_src) @@ -402,13 +403,13 @@ template PathMatters() { } return _dir; } - @safe string[] config_dirs() { + string[] config_dirs() { string[] _config_dirs; if (is_pod) { } else {} return _config_dirs; } - @safe string[] image_dirs() { + string[] image_dirs() { string[] _image_dirs; if (is_pod) { } else {} @@ -417,7 +418,7 @@ template PathMatters() { } return SRC_(); } - @safe auto output() { + auto output() { /+ - command line if output path set - config file if found and set set @@ -431,7 +432,7 @@ template PathMatters() { +/ auto _env = _env; struct Out_ { - @safe auto path() { + auto path() { auto _output_path = _env["pwd"]; if ((_opt_action.output_dir_set.length > 0) && isValidPath(_opt_action.output_dir_set) @@ -459,21 +460,21 @@ template PathMatters() { } } template configFilePaths() { - @safe auto configFilePaths(M,E)( + auto configFilePaths(M,E)( M _manifested, E _env, string _cli_config_path_set = "" ) { struct ConfFilePaths { - @safe string config_filename_document() { + string config_filename_document() { return "dr_document_make"; } - @safe string config_filename_site() { + string config_filename_site() { return "config_local_site"; } - @safe auto possible_config_path_locations() { + auto possible_config_path_locations() { struct _ConfFilePaths { - @safe string[] dr_document_make() { + string[] dr_document_make() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ /+ return paths +/ @@ -521,7 +522,7 @@ template configFilePaths() { +/ return _possible_config_path_locations; } - @safe string[] config_local_site() { + string[] config_local_site() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ string[] _possible_config_path_locations; @@ -580,15 +581,15 @@ template configFilePaths() { template spinePathsSRC() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); - @safe auto spinePathsSRC(D,Fn)( + auto spinePathsSRC(D,Fn)( D _pwd, Fn _fn_src_and_path, ) { struct drSrcPaths { - @safe auto pwd() { + auto pwd() { return _pwd; } - @safe string language() { + string language() { // use command line info as well? string _k; if (auto m = _fn_src_and_path.match(rgx_files.language_code_and_filename)) { @@ -598,28 +599,28 @@ template spinePathsSRC() { } return _k; } - @safe string doc_root() { + string doc_root() { return "dr_doc"; } - @safe auto media_root() { + auto media_root() { return ((doc_root.chainPath("media")).asNormalizedPath).array; } - @safe auto conf_root() { + auto conf_root() { return ((doc_root.chainPath("conf")).asNormalizedPath).array; } - @safe auto text_root() { + auto text_root() { return ((media_root.chainPath("text")).asNormalizedPath).array; } - @safe auto image_root() { + auto image_root() { return ((media_root.chainPath("image")).asNormalizedPath).array; } - @safe auto doc_src_fn_with_path_for_text_root_and_lng() { + auto doc_src_fn_with_path_for_text_root_and_lng() { return ((text_root.chainPath(language)).asNormalizedPath).array; } - @safe auto doc_src_fn() { + auto doc_src_fn() { return ((_fn_src_and_path.baseName).asNormalizedPath).array; } - @safe auto doc_src_with_path() { + auto doc_src_with_path() { return ((pwd.chainPath(_fn_src_and_path)).asNormalizedPath).array; } } diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d index 29dce0a..ac34074 100644 --- a/src/doc_reform/io_in/read_config_files.d +++ b/src/doc_reform/io_in/read_config_files.d @@ -53,6 +53,7 @@ meta_config_files.d +/ module doc_reform.io_in.read_config_files; +@safe: import std.file, std.path; @@ -61,7 +62,6 @@ import doc_reform.io_in.paths_source, doc_reform.meta.rgx_files, doc_reform.meta.rgx; - template readConfigSite() { @system final auto readConfigSite(Cf,O,Cfg)(Cf _conf_file_details, O _opt_action, Cfg _cfg) { mixin spineRgxIn; @@ -228,13 +228,13 @@ static template readConfigDoc() { if (config_file_str.length > 0) { break; } } struct _ConfContent { - @safe string filename() { + string filename() { return conf_filename; } - @safe string content() { + string content() { return config_file_str; } - @safe string filetype() { + string filetype() { string _ft = ""; if (content.match(rgx.yaml_config)) { _ft = "yaml"; @@ -254,7 +254,7 @@ static template configReadSiteYAML() { 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) { + final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); auto _conf_file_details = configFilePaths!()(_manifested, _env); string _conf_yaml_fn = _conf_file_details.config_filename_site; @@ -269,7 +269,7 @@ static template configReadDocYAML() { import doc_reform.meta, doc_reform.io_in.paths_source; - @safe final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) { + final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInDocYAML!()(_manifested, _env); auto _conf_file_details = configFilePaths!()(_manifested, _env); string _conf_yaml_fn = _conf_file_details.config_filename_document; diff --git a/src/doc_reform/io_in/read_source_files.d b/src/doc_reform/io_in/read_source_files.d index 36de9f3..73785c0 100644 --- a/src/doc_reform/io_in/read_source_files.d +++ b/src/doc_reform/io_in/read_source_files.d @@ -53,6 +53,7 @@ - if master file scan for addional files to import/insert +/ module doc_reform.io_in.read_source_files; +@safe: template spineRawMarkupContent() { import std.file, @@ -67,7 +68,7 @@ template spineRawMarkupContent() { mixin spineRgxFiles; static auto rgx_files = RgxFiles(); string[] _images=[]; - @safe string[] _extract_images(S)(S content_block) { + string[] _extract_images(S)(S content_block) { string[] images_; string _content_block = content_block.to!string; if (auto m = _content_block.matchAll(rgx.image)) { @@ -87,19 +88,19 @@ template spineRawMarkupContent() { string[], "insert_files", string[], "images" ); - @safe auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) { + auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) { auto _0_header_1_body_content_2_insert_filelist_tuple = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src); return _0_header_1_body_content_2_insert_filelist_tuple; } struct RawMarkupContent { - @safe final sourceContent(in string fn_src) { + final sourceContent(in string fn_src) { auto raw = MarkupRawUnit(); string source_txt_str = raw.markupSourceReadIn(fn_src); return source_txt_str; } - @safe final auto sourceContentSplitIntoHeaderAndBody(O)( + final auto sourceContentSplitIntoHeaderAndBody(O)( O _opt_action, in string source_txt_str, in string fn_src="" @@ -136,7 +137,7 @@ template spineRawMarkupContent() { } struct MarkupRawUnit { import std.file; - @safe final private string readInMarkupSource(in char[] fn_src) { + final private string readInMarkupSource(in char[] fn_src) { enforce( exists(fn_src) != 0, "file not found: «" ~ @@ -177,7 +178,7 @@ template spineRawMarkupContent() { = (cast(char[]) src_text).split(rgx.newline_eol_strip_preceding); return source_line_arr; } - @safe string markupSourceReadIn(in string fn_src) { + string markupSourceReadIn(in string fn_src) { static auto rgx_files = RgxFiles(); enforce( fn_src.match(rgx_files.src_pth_sst_or_ssm), @@ -187,7 +188,7 @@ template spineRawMarkupContent() { string source_txt_str = readInMarkupSource(fn_src); return source_txt_str; } - @safe HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { + HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { string[] file_insert_list = []; string[] images_list = []; char[][] hc = header0Content1(source_txt_str); @@ -202,7 +203,7 @@ template spineRawMarkupContent() { ); return t; } - @safe final char[][] getInsertMarkupSourceContentRawLineArray( + final char[][] getInsertMarkupSourceContentRawLineArray( in char[] fn_src_insert, Regex!(char) rgx_file ) { @@ -221,7 +222,7 @@ template spineRawMarkupContent() { char[][], "insert_contents", string[], "images" ); - @safe ContentsAndImages scan_subdoc_source(O)( + ContentsAndImages scan_subdoc_source(O)( O _opt_action, char[][] markup_sourcefile_insert_content, string fn_src @@ -294,7 +295,7 @@ template spineRawMarkupContent() { ); return t; } - @safe ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)( + ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)( O _opt_action, char[][] sourcefile_body_content, string fn_src |