From de02319cfa7b4bbff8c111bda02be1a7c6591555 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 5 Jan 2020 20:17:17 -0500 Subject: dlang safe default imminent, look ahead - @safe @trusted & @system, reconsider @trusted --- src/doc_reform/io_in/paths_source.d | 132 +++++++------- src/doc_reform/io_in/read_config_files.d | 14 +- src/doc_reform/io_in/read_source_files.d | 24 +-- src/doc_reform/io_out/create_zip_file.d | 2 +- src/doc_reform/io_out/defaults.d | 8 +- src/doc_reform/io_out/epub3.d | 18 +- src/doc_reform/io_out/html.d | 22 +-- src/doc_reform/io_out/hub.d | 7 +- src/doc_reform/io_out/latex.d | 58 +++---- src/doc_reform/io_out/metadata.d | 4 +- src/doc_reform/io_out/odt.d | 102 +++++------ src/doc_reform/io_out/source_pod.d | 2 +- src/doc_reform/io_out/xmls.d | 150 ++++++++-------- src/doc_reform/io_out/xmls_css.d | 4 +- src/doc_reform/meta/conf_make_meta_json.d | 2 +- src/doc_reform/meta/conf_make_meta_structs.d | 2 +- src/doc_reform/meta/conf_make_meta_yaml.d | 6 +- src/doc_reform/meta/defaults.d | 22 +-- src/doc_reform/meta/metadoc.d | 50 +++--- src/doc_reform/meta/metadoc_from_src.d | 246 +++++++++++++-------------- src/doc_reform/meta/metadoc_harvest.d | 4 +- src/doc_reform/meta/metadoc_object_setter.d | 16 +- src/doc_reform/meta/metadoc_show_config.d | 2 +- src/doc_reform/meta/metadoc_show_make.d | 2 +- src/doc_reform/meta/metadoc_show_metadata.d | 2 +- src/doc_reform/meta/metadoc_show_summary.d | 2 +- src/doc_reform/share/defaults.d | 2 +- src/doc_reform/spine.d | 116 ++++++------- 28 files changed, 512 insertions(+), 509 deletions(-) (limited to 'src/doc_reform') diff --git a/src/doc_reform/io_in/paths_source.d b/src/doc_reform/io_in/paths_source.d index 05ceda4..f3b1e8a 100644 --- a/src/doc_reform/io_in/paths_source.d +++ b/src/doc_reform/io_in/paths_source.d @@ -16,7 +16,7 @@ import template PodManifest() { mixin spineRgxInit; static auto rgx = Rgx(); - auto PodManifest(O)( + @safe auto PodManifest(O)( O _opt_actions, string _pth="" ) { @@ -24,7 +24,7 @@ template PodManifest() { string pod_manifest_filename() { return "pod.manifest"; } - string pod_manifest_path() { + @safe string pod_manifest_path() { string _manifest_path; if ((isValidPath(_pth) && exists(_pth) != 0 && _pth.isDir) && (exists(_pth.chainPath(pod_manifest_filename).array) != 0 @@ -46,10 +46,10 @@ template PodManifest() { } return _manifest_path; } - string pods_collection_root_path() { + @safe string pods_collection_root_path() { return (pod_manifest_path.length > 0) ? ((chainPath(pod_manifest_path, "..")).asNormalizedPath).array.to!string : ""; } - string pod_manifest_file_with_path() { + @safe 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; @@ -71,14 +71,14 @@ template PathMatters() { mixin InternalMarkup; static auto rgx = Rgx(); static auto mkup = InlineMarkup(); - auto PathMatters(O,E)( + @safe auto PathMatters(O,E)( O _opt_actions, E _env, string _pth, string _fns = "", char[][] _manifest_fn_list = [[]], ) { - auto _manifested = PodManifest!()(_opt_actions, _pth); + @safe auto _manifested = PodManifest!()(_opt_actions, _pth); struct ManifestMatters_ { auto env() { auto _env = _env; @@ -92,7 +92,7 @@ template PathMatters() { } return Env_(); } - auto opt() { + @safe auto opt() { struct Opt_ { auto action() { return _opt_actions; @@ -100,45 +100,45 @@ template PathMatters() { } return Opt_(); } - bool src_is_pod() { + @safe bool src_is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - auto pod() { + @safe auto pod() { struct Pod_ { - bool src_is_pod() { + @safe bool src_is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - string collection_root() { + @safe string collection_root() { return _manifested.pods_collection_root_path; } - string manifest_filename() { + @safe string manifest_filename() { return _manifested.pod_manifest_filename; } - string manifest_path() { + @safe string manifest_path() { return _manifested.pod_manifest_path; } - string pod_name_with_path() { + @safe string pod_name_with_path() { return _manifested.pod_manifest_path.baseName; } - string manifest_file_with_path() { + @safe string manifest_file_with_path() { return _manifested.pod_manifest_file_with_path; } - string[] config_dr_document_make_dirs() { + @safe string[] config_dr_document_make_dirs() { string[] _config_dirs; return _config_dirs; } - string[] config_local_site_dirs() { + @safe string[] config_local_site_dirs() { string[] _config_dirs; return _config_dirs; } - string[] image_dirs() { + @safe string[] image_dirs() { string[] _image_dirs; return _image_dirs; } - auto manifest_list_of_filenames() { + @safe auto manifest_list_of_filenames() { return _manifest_fn_list; } - string[] manifest_list_of_languages() { + @safe string[] manifest_list_of_languages() { string[] _lngs; foreach (filename_; manifest_list_of_filenames) { string _k = "en"; @@ -152,43 +152,43 @@ template PathMatters() { } return Pod_(); } - auto src() { + @safe auto src() { string _fns = _fns; // required here by dmd & not by ldc (for D:2078) auto _opt_actions = _opt_actions; auto _env = _env; struct SRC_ { - bool is_pod() { + @safe bool is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - string path_and_fn() { + @safe string path_and_fn() { return _fns; } - string pod_name_with_path() { + @safe string pod_name_with_path() { return (is_pod) ? _manifested.pod_manifest_path : ""; } - string pods_collection_root_path() { + @safe string pods_collection_root_path() { return (is_pod) ? _manifested.pods_collection_root_path : ""; } - string pod_name() { + @safe string pod_name() { return pod_name_with_path.baseName; } - string filename() { + @safe string filename() { return path_and_fn.baseName; } - string filename_base() { + @safe string filename_base() { return filename.stripExtension; } - string filename_extension() { + @safe string filename_extension() { return filename.match(rgx.src_pth_sst_or_ssm).captures["extension"]; } - string lng() { + @safe string lng() { string _k; if (auto m = path_and_fn.match(rgx.language_code_and_filename)) { _k = m.captures[1]; } else {_k = "en"; } return _k; } - string doc_uid() { + @safe string doc_uid() { string _uid; if (is_pod && !(pod_name_with_path.empty)) { if (pod_name_with_path.baseName == filename_base) { @@ -201,7 +201,7 @@ template PathMatters() { } return _uid; } - string doc_uid_out() { + @safe string doc_uid_out() { string _uid; if (is_pod && !(pod_name_with_path.empty)) { if (pod_name_with_path.baseName == filename_base) { @@ -214,7 +214,7 @@ template PathMatters() { } return _uid; } - string docname_composite_unique_per_src_doc() { + @safe string docname_composite_unique_per_src_doc() { string _fn; if (pod_name_with_path.baseName == filename_base) { _fn = filename_base ~ mkup.sep ~ filename_extension ~ mkup.sep ~ lng; @@ -225,7 +225,7 @@ template PathMatters() { } return _fn; } - string docname_composite_unique_per_src_pod() { + @safe string docname_composite_unique_per_src_pod() { /+ z pod name if any + src filename (without lng code) filename ~ mkup.sep ~ lng @@ -244,19 +244,19 @@ template PathMatters() { } return _fn; } - string language() { + @safe string language() { return lng(); } - string file_with_absolute_path() { + @safe string file_with_absolute_path() { return _env["pwd"].chainPath(path_and_fn).array; } - string absolute_path_to_src() { + @safe string absolute_path_to_src() { return (_env["pwd"].chainPath(path_and_fn)).dirName.array; } - string path_to_doc_root_path_to_lang_and_filename() { + @safe string path_to_doc_root_path_to_lang_and_filename() { return _env["pwd"].chainPath(path_and_fn).array; } - string base_dir() { + @safe string base_dir() { string _dir; if ( auto m = (absolute_path_to_src) @@ -274,7 +274,7 @@ template PathMatters() { } return _dir; } - string base_parent_dir_path() { + @safe string base_parent_dir_path() { string _dir; if ( auto m = (absolute_path_to_src) @@ -286,7 +286,7 @@ template PathMatters() { } return _dir; } - string base_dir_path() { + @safe string base_dir_path() { string _dir; if ( auto m = (absolute_path_to_src) @@ -306,11 +306,11 @@ template PathMatters() { } return _dir; } - string media_dir_path() { + @safe string media_dir_path() { string _dir = ((base_dir_path.chainPath("media")).asNormalizedPath).array; return _dir; } - string image_dir_path() { + @safe string image_dir_path() { string _paths; string[] _possible_img_pths = [ "./image", "../image", "../../image" ]; string _img_pth_found = ""; @@ -334,10 +334,10 @@ template PathMatters() { } return _img_pth_found; } - auto conf_dir_path() { + @safe auto conf_dir_path() { return ((base_dir_path.chainPath("conf")).asNormalizedPath).array; } - auto base_parent_dir() { + @safe auto base_parent_dir() { string _dir; if ( auto m = (absolute_path_to_src) @@ -352,13 +352,13 @@ template PathMatters() { } return _dir; } - string[] config_dirs() { + @safe string[] config_dirs() { string[] _config_dirs; if (is_pod) { } else {} return _config_dirs; } - string[] image_dirs() { + @safe string[] image_dirs() { string[] _image_dirs; if (is_pod) { } else {} @@ -367,7 +367,7 @@ template PathMatters() { } return SRC_(); } - auto output() { + @safe auto output() { /+ - command line if output path set - config file if found and set set @@ -381,7 +381,7 @@ template PathMatters() { +/ auto _env = _env; struct Out_ { - auto path() { + @safe auto path() { auto _output_path = _env["pwd"]; if ((_opt_actions.output_dir_set.length > 0) && isValidPath(_opt_actions.output_dir_set) @@ -411,21 +411,21 @@ template PathMatters() { template ConfigFilePaths() { mixin spineRgxInit; static auto rgx = Rgx(); - auto ConfigFilePaths(M,E)( + @safe auto ConfigFilePaths(M,E)( M _manifested, E _env, string _cli_config_path_set = "" ) { struct ConfFilePaths { - string config_filename_document() { + @safe string config_filename_document() { return "dr_document_make"; } - string config_filename_site() { + @safe string config_filename_site() { return "config_local_site"; } - auto possible_config_path_locations() { + @safe auto possible_config_path_locations() { struct _ConfFilePaths { - string[] dr_document_make() { + @safe string[] dr_document_make() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ /+ return paths +/ @@ -474,7 +474,7 @@ template ConfigFilePaths() { +/ return _possible_config_path_locations; } - string[] config_local_site() { + @safe string[] config_local_site() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ string[] _possible_config_path_locations; @@ -533,15 +533,15 @@ template ConfigFilePaths() { template spinePathsSRC() { mixin spineRgxInit; static auto rgx = Rgx(); - auto spinePathsSRC(D,Fn)( + @safe auto spinePathsSRC(D,Fn)( D _pwd, Fn _fn_src_and_path, ) { struct drSrcPaths { - auto pwd() { + @safe auto pwd() { return _pwd; } - string language() { + @safe string language() { // use command line info as well? string _k; if (auto m = _fn_src_and_path.match(rgx.language_code_and_filename)) { @@ -551,28 +551,28 @@ template spinePathsSRC() { } return _k; } - string doc_root() { + @safe string doc_root() { return "dr_doc"; } - auto media_root() { + @safe auto media_root() { return ((doc_root.chainPath("media")).asNormalizedPath).array; } - auto conf_root() { + @safe auto conf_root() { return ((doc_root.chainPath("conf")).asNormalizedPath).array; } - auto text_root() { + @safe auto text_root() { return ((media_root.chainPath("text")).asNormalizedPath).array; } - auto image_root() { + @safe auto image_root() { return ((media_root.chainPath("image")).asNormalizedPath).array; } - auto doc_src_fn_with_path_for_text_root_and_lng() { + @safe auto doc_src_fn_with_path_for_text_root_and_lng() { return ((text_root.chainPath(language)).asNormalizedPath).array; } - auto doc_src_fn() { + @safe auto doc_src_fn() { return ((_fn_src_and_path.baseName).asNormalizedPath).array; } - auto doc_src_with_path() { + @safe 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 1f6faa3..ce16f24 100644 --- a/src/doc_reform/io_in/read_config_files.d +++ b/src/doc_reform/io_in/read_config_files.d @@ -14,7 +14,7 @@ static template readConfigSite() { std.file, std.path; mixin spineRgxInit; - final auto readConfigSite(C)(C _conf_file_details) { + @system final auto readConfigSite(C)(C _conf_file_details) { static auto rgx = Rgx(); string conf_filename = "NONE"; string config_file_str; @@ -119,7 +119,7 @@ static template readConfigDoc() { std.file, std.path; mixin spineRgxInit; - final auto readConfigDoc(M,E)(M _manifested, E _env) { + @system final auto readConfigDoc(M,E)(M _manifested, E _env) { static auto rgx = Rgx(); string config_file_str; string conf_filename = "NONE"; @@ -146,13 +146,13 @@ static template readConfigDoc() { if (config_file_str.length > 0) { break; } } struct _ConfContent { - string filename() { + @safe string filename() { return conf_filename; } - string content() { + @safe string content() { return config_file_str; } - string filetype() { + @safe string filetype() { string _ft = ""; if (content.match(rgx.yaml_config)) { _ft = "yaml"; @@ -169,7 +169,7 @@ static template configReadSiteYAML() { doc_reform.io_in.paths_source, std.file, std.path; - final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { + @safe 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; @@ -183,7 +183,7 @@ static template configReadDocYAML() { doc_reform.io_in.paths_source, std.file, std.path; - final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) { + @safe 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 ba3e145..fcbd075 100644 --- a/src/doc_reform/io_in/read_source_files.d +++ b/src/doc_reform/io_in/read_source_files.d @@ -15,7 +15,7 @@ static template spineRawMarkupContent() { mixin spineRgxInit; static auto rgx = Rgx(); string[] _images=[]; - string[] _extract_images(S)(S content_block) @safe { + @safe string[] _extract_images(S)(S content_block) { string[] images_; string _content_block = content_block.to!string; if (auto m = _content_block.matchAll(rgx.image)) { @@ -35,19 +35,19 @@ static template spineRawMarkupContent() { string[], "insert_files", string[], "images" ); - auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) @safe { + @safe 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 { - final sourceContent(in string fn_src) { + @safe final sourceContent(in string fn_src) { auto raw = MarkupRawUnit(); string source_txt_str = raw.markupSourceReadIn(fn_src); return source_txt_str; } - final auto sourceContentSplitIntoHeaderAndBody(O)( + @safe final auto sourceContentSplitIntoHeaderAndBody(O)( O _opt_action, in string source_txt_str, in string fn_src="" @@ -84,7 +84,7 @@ static template spineRawMarkupContent() { } struct MarkupRawUnit { import std.file; - final private string readInMarkupSource(in char[] fn_src) { + @safe final private string readInMarkupSource(in char[] fn_src) { enforce( exists(fn_src) != 0, "file not found: «" ~ @@ -107,7 +107,7 @@ static template spineRawMarkupContent() { std.utf.validate(source_txt_str); return source_txt_str; } - final private char[][] header0Content1(in string src_text) @trusted { // cast(char[]) + @trusted final private char[][] header0Content1(in string src_text) { // cast(char[]) /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/ char[][] header_and_content; auto m = (cast(char[]) src_text).matchFirst(rgx.heading_a); @@ -120,12 +120,12 @@ static template spineRawMarkupContent() { ); return header_and_content; } - final private char[][] markupSourceLineArray(in char[] src_text) @trusted { // cast(char[]) + @trusted final private char[][] markupSourceLineArray(in char[] src_text) { // cast(char[]) char[][] source_line_arr = (cast(char[]) src_text).split(rgx.newline_eol_strip_preceding); return source_line_arr; } - string markupSourceReadIn(in string fn_src) { + @safe string markupSourceReadIn(in string fn_src) { static auto rgx = Rgx(); enforce( fn_src.match(rgx.src_pth_sst_or_ssm), @@ -135,7 +135,7 @@ static template spineRawMarkupContent() { string source_txt_str = readInMarkupSource(fn_src); return source_txt_str; } - HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) @safe { + @safe HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { string[] file_insert_list = []; string[] images_list = []; char[][] hc = header0Content1(source_txt_str); @@ -150,7 +150,7 @@ static template spineRawMarkupContent() { ); return t; } - final char[][] getInsertMarkupSourceContentRawLineArray( + @safe final char[][] getInsertMarkupSourceContentRawLineArray( in char[] fn_src_insert, Regex!(char) rgx_file ) { @@ -169,7 +169,7 @@ static template spineRawMarkupContent() { char[][], "insert_contents", string[], "images" ); - ContentsAndImages scan_subdoc_source(O)( + @safe ContentsAndImages scan_subdoc_source(O)( O _opt_action, char[][] markup_sourcefile_insert_content, string fn_src @@ -254,7 +254,7 @@ static template spineRawMarkupContent() { ); return t; } - ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)( + @safe ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)( O _opt_action, char[][] sourcefile_body_content, string fn_src diff --git a/src/doc_reform/io_out/create_zip_file.d b/src/doc_reform/io_out/create_zip_file.d index 09b481a..0ad8ada 100644 --- a/src/doc_reform/io_out/create_zip_file.d +++ b/src/doc_reform/io_out/create_zip_file.d @@ -4,7 +4,7 @@ template createZipFile() { import std.outbuffer; import std.string; import std.zip; - void createZipFile( + @safe void createZipFile( string zip_file_name, void[] compressed_zip_data, ) { diff --git a/src/doc_reform/io_out/defaults.d b/src/doc_reform/io_out/defaults.d index 4dd8021..84bac73 100644 --- a/src/doc_reform/io_out/defaults.d +++ b/src/doc_reform/io_out/defaults.d @@ -50,7 +50,7 @@ template InternalMarkup() { template spineLanguageCodes() { /+ language codes +/ struct Lang { - static string[string][string] codes() { + @safe static string[string][string] codes() { auto _lang_codes = [ "am": [ "c": "am", "n": "Amharic", "t": "Amharic", "xlp": "amharic" ], "bg": [ "c": "bg", "n": "Bulgarian", "t": "Български (Bəlgarski)", "xlp": "bulgarian" ], @@ -117,15 +117,15 @@ template spineLanguageCodes() { ]; return _lang_codes; } - static string[] code_arr_ptr() { + @safe static string[] code_arr_ptr() { string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; return _lang_codes; } - static string[] code_arr() { + @safe static string[] code_arr() { string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; return _lang_codes; } - static auto codes_() { + @safe static auto codes_() { return "(" ~ join(code_arr,"|") ~ ")"; } static auto codes_regex() { diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index 4de98a1..f8f5ba4 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -14,12 +14,12 @@ template outputEPub3() { doc_reform.io_out.xmls_css; mixin InternalMarkup; mixin outputXHTMLs; - string epub3_mimetypes() @safe { + @safe string epub3_mimetypes() { string o; o = format(q"┃application/epub+zip┃") ~ "\n"; return o; } - string epub3_container_xml() @safe { + @safe string epub3_container_xml() { string o; o = format(q"┃┃") ~ "\n"; o ~= format(q"┃┃") ~ "\n\n"; return o; } - string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) @safe { + @safe string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { auto xhtml_format = outputXHTMLs(); auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! @@ -128,7 +128,7 @@ template outputEPub3() { } return content; } - string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) @safe { + @safe string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); static auto rgx = Rgx(); @@ -207,7 +207,7 @@ template outputEPub3() { \n"; return toc; } - string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) @safe { + @safe string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { int counter = 0; string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere auto markup = InlineMarkup(); @@ -297,10 +297,10 @@ template outputEPub3() { return toc; } - void outputEPub3(D,I)( + @system void outputEPub3(D,I)( const D doc_abstraction, I doc_matters, - ) { // @trusted + ) { mixin spineOutputRgxInit; auto xhtml_format = outputXHTMLs(); static auto rgx = Rgx(); @@ -606,10 +606,10 @@ template outputEPub3() { epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts); epubWrite.epub3_write_output_files(doc_matters); } - void epub3_write_output_files(W,M)( + @system void epub3_write_output_files(W,M)( W epub_write, M doc_matters, - ) { // @trusted + ) { debug(asserts) { static assert(is(typeof(epub_write.doc_epub3) == string[][string])); static assert(is(typeof(epub_write.mimetypes) == string)); diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d index 8598ca5..637b007 100644 --- a/src/doc_reform/io_out/html.d +++ b/src/doc_reform/io_out/html.d @@ -13,10 +13,10 @@ template outputHTML() { doc_reform.io_out.xmls, doc_reform.io_out.xmls_css; mixin outputXHTMLs; - void scroll(D,M)( + @safe void scroll(D,M)( const D doc_abstraction, M doc_matters, - ) @safe { + ) { mixin spineOutputRgxInit; auto xhtml_format = outputXHTMLs(); static auto rgx = Rgx(); @@ -183,10 +183,10 @@ template outputHTML() { doc = xhtml_format.html_head(doc_matters, "scroll") ~ doc_html ~ xhtml_format.tail; scroll_write_output(doc, doc_matters); } - void scroll_write_output(D,M)( + @trusted void scroll_write_output(D,M)( D doc, M doc_matters, - ) @trusted { + ) { debug(asserts) { static assert(is(typeof(doc) == string[])); } @@ -206,10 +206,10 @@ template outputHTML() { writeln(" ", pth_html.fn_scroll(doc_matters.src.filename)); } } - void seg(D,M)( + @safe void seg(D,M)( const D doc_abstraction, M doc_matters, - ) @safe { + ) { mixin spineOutputRgxInit; static auto rgx = Rgx(); auto xhtml_format = outputXHTMLs(); @@ -459,11 +459,11 @@ template outputHTML() { } seg_write_output(doc_html, doc_html_endnotes, doc_matters); } - void seg_write_output(D,E,M)( + @trusted void seg_write_output(D,E,M)( // @system? D doc_html, E doc_html_endnotes, M doc_matters, - ) @trusted { // @system? + ) { debug(asserts) { static assert(is(typeof(doc_html) == string[][string])); } @@ -493,7 +493,7 @@ template outputHTML() { writeln(" ", pth_html.fn_seg(doc_matters.src.filename, "toc")); } } - void css(M)(M doc_matters) @safe { + @safe void css(M)(M doc_matters) { auto css = spineCss(doc_matters); auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { @@ -508,9 +508,9 @@ template outputHTML() { // Handle error } } - void images_cp(M)( + @trusted void images_cp(M)( // @system M doc_matters, - ) @trusted { // @system + ) { { /+ (copy html images) +/ auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d index a43c28a..df3d28c 100644 --- a/src/doc_reform/io_out/hub.d +++ b/src/doc_reform/io_out/hub.d @@ -11,7 +11,10 @@ template outputHub() { doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; import std.parallelism; - void outputHub(D,I)(const D doc_abstraction, I doc_matters) { + @system void outputHub(D,I)( + const D doc_abstraction, + I doc_matters + ) { mixin spineOutputRgxInit; mixin Msg; auto msg = Msg!()(doc_matters); @@ -114,7 +117,7 @@ template outputHubOp() { doc_reform.io_out.odt, doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; - void outputHubOp(E,O)(E env, O opt_action) { + @system void outputHubOp(E,O)(E env, O opt_action) { mixin spineOutputRgxInit; static auto rgx = Rgx(); if ((opt_action.sqlite_db_drop)) { diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d index cfa347c..b8e33f4 100644 --- a/src/doc_reform/io_out/latex.d +++ b/src/doc_reform/io_out/latex.d @@ -14,7 +14,7 @@ template outputLaTeX() { auto lang = Lang(); auto paper() { struct PaperType { - auto a4() @safe { + @safe auto a4() { struct A4 { auto portrait() { struct V { @@ -35,7 +35,7 @@ template outputLaTeX() { } return A4(); } - auto a5() @safe { + @safe auto a5() { struct A5 { auto portrait() { struct V { @@ -56,7 +56,7 @@ template outputLaTeX() { } return A5(); } - auto b4() @safe { + @safe auto b4() { struct B4 { auto portrait() { struct V { @@ -77,7 +77,7 @@ template outputLaTeX() { } return B4(); } - auto letter() @safe { + @safe auto letter() { struct Letter { auto portrait() { struct V { @@ -98,7 +98,7 @@ template outputLaTeX() { } return Letter(); } - auto legal() @safe { + @safe auto legal() { struct Legal { auto portrait() { struct V { @@ -122,10 +122,10 @@ template outputLaTeX() { } return PaperType(); } - string sp_char_esc(O)( + @safe string sp_char_esc(O)( string _txt, const O obj, - ) @safe { + ) { string _unescape_sp_char_esc()(string _txt) { _txt = _txt .replaceAll(rgx.latex_special_char_escaped, @@ -147,9 +147,9 @@ template outputLaTeX() { } return _txt; } - string sp_char_esc_txt()( + @safe string sp_char_esc_txt()( string _txt, - ) @safe { + ) { string _unescape_sp_char_esc()(string _txt) { _txt = _txt .replaceAll(rgx.latex_special_char_escaped, @@ -169,9 +169,9 @@ template outputLaTeX() { _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx.latex_identify_inline_fontface); return _txt; } - string fontface()( + @safe string fontface()( string _txt, - ) @safe { + ) { _txt = _txt .replaceAll(rgx.inline_emphasis, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1")) .replaceAll(rgx.inline_bold, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1")) @@ -185,9 +185,9 @@ template outputLaTeX() { .replaceAll(rgx.inline_italics, format(q"┃``%s''┃", "$1")); return _txt; } - string leading_hardspaces()( + @safe string leading_hardspaces()( string _txt, - ) @safe { + ) { string hardspaces(string _spaces) { _spaces = _spaces .replaceAll(rgx.space, "\\hardspace "); @@ -196,23 +196,23 @@ template outputLaTeX() { _txt = replaceAll!(m => hardspaces(m[0]))(_txt, rgx.spaces_line_start); return _txt; } - string nbsp_char()(string _txt) @safe { + @safe string nbsp_char()(string _txt) { if (_txt.match(rgx.nbsp_char)) { _txt = _txt.replaceAll(rgx.nbsp_char, "\\hardspace "); } return _txt; } - string nbsp_char_to_space()(string _txt) @safe { + @safe string nbsp_char_to_space()(string _txt) { if (_txt.match(rgx.nbsp_char)) { _txt = _txt.replaceAll(rgx.nbsp_char, " "); } return _txt; } - string links_and_images(O,M)( + @safe string links_and_images(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { if (obj.has.inline_links) { // TODO some images do not have inline links ... image without link string _width_adjust(string _width) { if (_width.to!int > 300) { _width = "300"; } // will need to vary max with papersize & orientation @@ -253,9 +253,9 @@ template outputLaTeX() { } return _txt; } - string footnotes()( + @safe string footnotes()( string _txt, - ) @safe { + ) { if (_txt.match(rgx.inline_notes_al_gen)) { string _tex_note = q"┃\hypertarget{noteref_%s}{}\footnote[%s]{%% \label{note_%s}%s}┃"; @@ -268,18 +268,18 @@ template outputLaTeX() { } return _txt; } - string remove_footnotes()( + @safe string remove_footnotes()( string _txt, - ) @safe { + ) { if (_txt.match(rgx.inline_notes_al_gen)) { _txt = replaceAll!(m => "")(_txt, rgx.inline_notes_al_gen); } return _txt; } - string para(O)( + @safe string para(O)( string _txt, O obj, - ) @safe { + ) { if (obj.metainfo.is_of_type == "para") { string _tex_para; _tex_para = q"┃\begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{%s}{%s}\end{tiny}}}%s┃"; @@ -291,10 +291,10 @@ template outputLaTeX() { } return _txt; } - string bookindex(O)( + @safe string bookindex(O)( string _txt, O obj, - ) @safe { + ) { if (obj.metainfo.is_of_type == "para" && obj.metainfo.is_a == "bookindex" ) { @@ -306,12 +306,12 @@ template outputLaTeX() { } return _txt; } - string heading(O,M)( + @safe string heading(O,M)( string _txt, O obj, M doc_matters, string _part = "" - ) @safe { + ) { if (obj.metainfo.is_a == "heading") { string _tex_para; string _pg_break; @@ -641,10 +641,10 @@ string table(O,M)( } return _txt; } - string bullets_and_indentation(O)( + @safe string bullets_and_indentation(O)( string _txt, O obj, - ) @safe { + ) { string _tex_para; string _hang; string _indent; int _paper_margin = -10; diff --git a/src/doc_reform/io_out/metadata.d b/src/doc_reform/io_out/metadata.d index 8201926..5dfdfe2 100644 --- a/src/doc_reform/io_out/metadata.d +++ b/src/doc_reform/io_out/metadata.d @@ -1,6 +1,6 @@ module doc_reform.io_out.metadata; template outputMetadata() { - void outputMetadata(T)( T doc_matters) @safe { + @safe void outputMetadata(T)( T doc_matters) { import std.file; import std.format; import doc_reform.io_out; @@ -185,7 +185,7 @@ string theme_light_1 = format(q"┃ doc_matters.opt.action.css_theme_default ? theme_light_0 : theme_dark_0, doc_matters.opt.action.css_theme_default ? theme_light_1 : theme_dark_1, ) ~ "\n"; - void metadata_write_output(M)(M doc_matters, string[] metadata_) @trusted { + @safe void metadata_write_output(M)(M doc_matters, string[] metadata_) { auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { if (!exists(pth_html.base)) { diff --git a/src/doc_reform/io_out/odt.d b/src/doc_reform/io_out/odt.d index 23eb947..67b34ba 100644 --- a/src/doc_reform/io_out/odt.d +++ b/src/doc_reform/io_out/odt.d @@ -15,7 +15,7 @@ template formatODT() { mixin spineOutputRgxInit; struct formatODT { static auto rgx = Rgx(); - string _tags(O)(const O obj) @safe { + @safe string _tags(O)(const O obj) { string _tags = ""; if (obj.tags.anchor_tags.length > 0) { foreach (tag_; obj.tags.anchor_tags) { @@ -33,7 +33,7 @@ template formatODT() { } return _tags; } - string _xhtml_anchor_tags(O)(O obj) @safe { + @safe string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { @@ -45,7 +45,7 @@ template formatODT() { } return tags; } - string obj_num(O)(const O obj) @safe { // TODO + @safe string obj_num(O)(const O obj) { // TODO string _on; _on = (obj.metainfo.object_number.empty) ? "" @@ -55,7 +55,7 @@ template formatODT() { )); return _on; } - string _footnotes()(string _txt) @safe { + @safe string _footnotes()(string _txt) { static auto rgx = Rgx(); _txt = _txt.replaceAll( rgx.inline_notes_al_regular_number_note, @@ -74,14 +74,14 @@ template formatODT() { ); return _txt; } - string _bullet(O)(const O obj) @safe { + @safe string _bullet(O)(const O obj) { string _b = ""; if (obj.attrib.bullet) { _b = format(q"┃● ┃",); } return _b; } - string _indent(O)(string _txt, const O obj) @safe { // TODO + @safe string _indent(O)(string _txt, const O obj) { // TODO // if (obj.attrib.indent_base > 0 || // obj.attrib.indent_hang > 0 // ) { @@ -189,7 +189,7 @@ template formatODT() { } return _txt; } - string _block_type_delimiters(O)(string[] _block_lines, const O obj) @safe { // TODO + @safe string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO string _block = ""; foreach (i, _line; _block_lines) { _line = _footnotes(_line); @@ -222,7 +222,7 @@ template formatODT() { obj_num(obj)); return _block; } - string _special_characters(O)(string _txt, const O obj) @safe { + @safe string _special_characters(O)(string _txt, const O obj) { _txt = _txt .replaceAll(rgx.xhtml_ampersand, "&") .replaceAll(rgx.xhtml_quotation, """) @@ -231,7 +231,7 @@ template formatODT() { .replaceAll(rgx.nbsp_char, " "); return _txt; } - string _preserve_white_spaces(O)(string _txt, const O obj) @safe { + @safe string _preserve_white_spaces(O)(string _txt, const O obj) { if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { _txt = _txt .replaceAll(rgx.space, " "); @@ -252,9 +252,9 @@ template formatODT() { .replaceAll(rgx.inline_mono, format(q"┃%s┃", "$1")); return _txt; } - auto _obj_num(O)(O obj) @safe { // NOT USED YET + @safe auto _obj_num(O)(O obj) { // NOT USED YET struct objNum { - string reference() @safe { + @safe string reference() { return format(q"┃ @@ -263,7 +263,7 @@ template formatODT() { obj.object_number, ); } - string display() @safe { + @safe string display() { return format(q"┃ %s%s%s ┃", @@ -275,20 +275,20 @@ template formatODT() { } return objNum(); } - string _break_page()() @safe { + @safe string _break_page()() { return format(q"┃ ┃", ); } - string _empty_line_break(O)(string _txt, const O obj) @safe { + @safe string _empty_line_break(O)(string _txt, const O obj) { if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") { _txt = _txt .replaceAll(rgx.br_empty_line, "
"); } return _txt; } - string _links(O)(string _txt, const O obj) @safe { + @safe string _links(O)(string _txt, const O obj) { if (obj.metainfo.is_a != "code") { if (obj.metainfo.is_a == "toc") { _txt = replaceAll!(m => @@ -328,7 +328,7 @@ template formatODT() { } return _txt; } - string _images(O)(string _txt, const O obj) @safe { + @safe string _images(O)(string _txt, const O obj) { if (_txt.match(rgx.inline_image)) { _txt = _txt .replaceAll(rgx.inline_image, @@ -339,7 +339,7 @@ template formatODT() { } return _txt; } - string markup(O)(const O obj) @safe { + @safe string markup(O)(const O obj) { /+ markup TODO +/ string _txt = obj.text; _txt = _special_characters(_txt, obj); // TODO & why both obj & obj.text, consider also in output_xmls.org @@ -353,10 +353,10 @@ template formatODT() { _txt = _empty_line_break(_txt, obj); // (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") return _txt; } - string heading(O,M)( + @safe string heading(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -397,10 +397,10 @@ template formatODT() { } return _o_txt_odt; } - string para(O,M)( + @safe string para(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -416,10 +416,10 @@ template formatODT() { } return _o_txt_odt; } - string quote(O,M)( + @safe string quote(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -428,10 +428,10 @@ template formatODT() { _o_txt_odt = _footnotes(_o_txt_odt); // decide return _o_txt_odt; } - string group(O,M)( + @safe string group(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -446,10 +446,10 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - string block(O,M)( + @safe string block(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -459,10 +459,10 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - string verse(O,M)( + @safe string verse(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -472,10 +472,10 @@ template formatODT() { _o_txt_odt = _block_type_delimiters(_block_lines, obj); return _o_txt_odt; } - string code(O,M)( + @safe string code(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -519,10 +519,10 @@ template formatODT() { _o_txt_odt = _block; return _o_txt_odt; } - Tuple!(string, string) tablarize(O)( + @safe Tuple!(string, string) tablarize(O)( const O obj, string _txt, - ) @safe { + ) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; string _table; @@ -554,10 +554,10 @@ template formatODT() { return t; } int _table_number = 0; - string table(O,M)( + @safe string table(O,M)( const O obj, const M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -606,7 +606,7 @@ template outputODT() { mixin spineOutputRgxInit; static auto rgx = Rgx(); // mixin outputXmlODT; - string odt_head(I)(I doc_matters) @safe { + @safe string odt_head(I)(I doc_matters) { string _has_tables = format(q"┃ @@ -714,10 +714,10 @@ template outputODT() { ); return _odt_head; } - string odt_body(D,I)( + @safe string odt_body(D,I)( const D doc_abstraction, I doc_matters, - ) @safe { + ) { mixin formatODT; auto odt_format = formatODT(); string delimit = ""; @@ -840,15 +840,15 @@ template outputODT() { return doc_odt; } - string odt_tail() @safe { + @safe string odt_tail() { string _odt_tail = format(q"┃spine: <www.doc_reform.org> and <www.sisudoc.org> ┃",); return _odt_tail; } - string content_xml(D,I)( + @safe string content_xml(D,I)( const D doc_abstraction, I doc_matters, - ) @safe { + ) { string _content_xml; string break_line = (doc_matters.opt.action.debug_do) ? "\n" : ""; string odt_break_page = format(q"┃┃",); @@ -858,9 +858,9 @@ template outputODT() { _content_xml ~= odt_tail; return _content_xml; } - string manifest_xml(M)( + @safe string manifest_xml(M)( auto ref M doc_matters, - ) @safe { + ) { string _bullet = format(q"┃┃"); string[] _images = [ _bullet ]; foreach (image; doc_matters.srcs.image_list) { @@ -882,9 +882,9 @@ template outputODT() { ); return _manifest_xml; } - void images_cp(M)( + @safe void images_cp(M)( auto ref M doc_matters, - ) @safe { + ) { { /+ (copy odt images) +/ auto pth_odt = spinePathsODT!()(doc_matters); foreach (image; doc_matters.srcs.image_list) { @@ -902,9 +902,9 @@ template outputODT() { } // return 0; } - string meta_xml(M)( + @safe string meta_xml(M)( auto ref M doc_matters, - ) @safe { + ) { /+ (meta_xml includes output time-stamp) +/ string _meta_xml = format(q"┃ @@ -939,11 +939,11 @@ template outputODT() { } // return 0; } - string mimetype() @safe { + @safe string mimetype() { string mimetype_ = format(q"┃application/vnd.oasis.opendocument.text┃"); return mimetype_; } - string manifest_rdf() @safe { + @safe string manifest_rdf() { string _manifest_rdf = format(q"┃ @@ -965,7 +965,7 @@ template outputODT() { ┃"); return _manifest_rdf; } - string settings_xml() @safe { + @safe string settings_xml() { string _settings_xml = format(q"┃ @@ -1065,7 +1065,7 @@ template outputODT() { ┃"); return _settings_xml; } - string styles_xml() @safe { + @safe string styles_xml() { string _styles_xml = format(q"┃ diff --git a/src/doc_reform/io_out/source_pod.d b/src/doc_reform/io_out/source_pod.d index 31c0b45..59746de 100644 --- a/src/doc_reform/io_out/source_pod.d +++ b/src/doc_reform/io_out/source_pod.d @@ -23,7 +23,7 @@ template spinePod() { auto lang = Lang(); static auto rgx = Rgx(); assert (doc_matters.src.filename.match(rgx.src_fn)); - auto pod_archive(Z)( + @system auto pod_archive(Z)( string _source_type, string _data_in, string _pth_out, diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 1d58e27..1b038a9 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -15,10 +15,10 @@ template outputXHTMLs() { mixin spineOutputRgxInit; struct outputXHTMLs { static auto rgx = Rgx(); - string div_delimit( + @safe string div_delimit( string part, return ref string previous_part - ) @safe { + ) { string delimit = ""; string delimit_ = ""; if (part != previous_part) { @@ -45,7 +45,7 @@ template outputXHTMLs() { // you also need to close the last div, introduce a footer? return delimit; } - string special_characters_text(string _txt) @safe { + @safe string special_characters_text(string _txt) { _txt = _txt .replaceAll(rgx.xhtml_ampersand, "&") .replaceAll(rgx.xhtml_quotation, """) @@ -54,9 +54,9 @@ template outputXHTMLs() { .replaceAll(rgx.nbsp_char, " "); return _txt; } - string special_characters(O)( + @safe string special_characters(O)( const O obj, - ) @safe { + ) { string _txt = special_characters_text(obj.text); if (!(obj.metainfo.is_a == "code")) { _txt = (_txt) @@ -64,7 +64,7 @@ template outputXHTMLs() { } return _txt; } - string font_face(string _txt) @safe { + @safe string font_face(string _txt) { _txt = _txt .replaceAll(rgx.inline_emphasis, ("$1")) .replaceAll(rgx.inline_bold, ("$1")) @@ -78,7 +78,7 @@ template outputXHTMLs() { .replaceAll(rgx.inline_cite, ("$1")); return _txt; } - string _xhtml_anchor_tags(O)(O obj) @safe { + @safe string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { @@ -90,9 +90,9 @@ template outputXHTMLs() { } return tags; } - string header_metadata(M)( + @safe string header_metadata(M)( M doc_matters, - ) @safe { + ) { string _publisher="Publisher"; // TODO string o; o = format(q"┃ @@ -127,9 +127,9 @@ template outputXHTMLs() { ); return o; } - string site_info_button(M)( + @safe string site_info_button(M)( M doc_matters, - ) @safe { + ) { string _locations; if (doc_matters.conf_make_meta.make.home_button_text.length > 0) { _locations = (doc_matters.conf_make_meta.make.home_button_text) @@ -151,9 +151,9 @@ template outputXHTMLs() { ); return o; } - string inline_search_form(M)( + @safe string inline_search_form(M)( M doc_matters, - ) @safe { + ) { string _action="http://www.sisudoc.org/cgi-bin/search.cgi"; string _db="spine.7a.manual"; string o; @@ -182,7 +182,7 @@ template outputXHTMLs() { } return o; } - string html_head(M)( + @safe string html_head(M)( M doc_matters, string type, ) { @@ -232,9 +232,9 @@ template outputXHTMLs() { ); return o; } - string epub3_seg_head(M)( + @safe string epub3_seg_head(M)( M doc_matters, - ) @safe { + ) { string html_base = format(q"┃ ┃", ); @@ -300,7 +300,7 @@ template outputXHTMLs() { ); return o; } - string tail() @safe { + @safe string tail() { string o; o = format(q"┃ @@ -309,13 +309,13 @@ template outputXHTMLs() { ┃"); return o; } - string inline_images(O,M)( + @safe string inline_images(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", - ) @safe { + ) { string _img_pth; switch (_xml_type) { case "epub": _img_pth = "image/"; break; @@ -335,13 +335,13 @@ template outputXHTMLs() { } return _txt; } - string inline_links(O,M)( + @safe string inline_links(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", - ) @safe { + ) { string seg_lvs; if (obj.has.inline_links) { if (obj.metainfo.is_a != "code") { @@ -426,11 +426,11 @@ template outputXHTMLs() { } return _txt; } - string inline_notes_scroll(O,M)( + @safe string inline_notes_scroll(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); _txt = _txt.replaceAll( @@ -457,11 +457,11 @@ template outputXHTMLs() { } return _txt; } - Tuple!(string, string[]) inline_notes_seg(O,M)( + @safe Tuple!(string, string[]) inline_notes_seg(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { string[] _endnotes; if (obj.has.inline_notes_star) { _txt = font_face(_txt); @@ -521,12 +521,12 @@ template outputXHTMLs() { ); return t; } - string inline_markup_scroll(O,M)( + @safe string inline_markup_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { if (obj.metainfo.dummy_heading && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { _txt = ""; @@ -537,13 +537,13 @@ template outputXHTMLs() { } return _txt; } - auto inline_markup_seg(O,M)( + @safe auto inline_markup_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", - ) @safe { + ) { if (obj.metainfo.dummy_heading && ((_xml_type == "epub" && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) @@ -557,10 +557,10 @@ template outputXHTMLs() { Tuple!(string, string[]) t = inline_notes_seg(_txt, obj, doc_matters); return t; } - string lev4_heading_subtoc(O,M)( + @safe string lev4_heading_subtoc(O,M)( const O obj, M doc_matters, - ) @safe { + ) { char[] lev4_subtoc; lev4_subtoc ~= "
\n"; foreach (subtoc; obj.tags.lev4_subtoc) { @@ -584,10 +584,10 @@ template outputXHTMLs() { lev4_subtoc ~= "
\n"; return lev4_subtoc.to!string; } - auto nav_pre_next_svg(O,M)( + @safe auto nav_pre_next_svg(O,M)( const O obj, M doc_matters, - ) @safe { + ) { string prev, next, toc; if (obj.tags.segment_anchor_tag_epub == "toc") { toc = ""; @@ -660,12 +660,12 @@ template outputXHTMLs() { } return bar(); } - string heading(O,M)( + @safe string heading(O,M)( string _txt, const O obj, M doc_matters, string _xml_type = "html", - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -725,23 +725,23 @@ template outputXHTMLs() { } return o; } - string heading_scroll(O,M)( + @safe string heading_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = heading(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) heading_seg(O,M)( + @safe Tuple!(string, string[]) heading_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; @@ -752,11 +752,11 @@ template outputXHTMLs() { ); return u; } - string para(O,M)( + @safe string para(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -802,12 +802,12 @@ template outputXHTMLs() { } return o; } - string para_scroll(O,M)( + @safe string para_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { if (obj.metainfo.is_a == "toc" && _txt.match(rgx.inline_link_toc_to_backmatter)) { _txt = _txt.replaceAll(rgx.inline_link_toc_to_backmatter, "┤#section_$1├"); } @@ -815,13 +815,13 @@ template outputXHTMLs() { string o = para(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) para_seg(O,M)( + @safe Tuple!(string, string[]) para_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -832,11 +832,11 @@ template outputXHTMLs() { ); return u; } - string quote(O,M)( + @safe string quote(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -868,23 +868,23 @@ template outputXHTMLs() { } return o; } - string quote_scroll(O,M)( + @safe string quote_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = quote(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) quote_seg(O,M)( + @safe Tuple!(string, string[]) quote_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -895,11 +895,11 @@ template outputXHTMLs() { ); return u; } - string group(O,M)( + @safe string group(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -931,24 +931,24 @@ template outputXHTMLs() { } return o; } - string group_scroll(O,M)( + @safe string group_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = group(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) group_seg(O,M)( + @safe Tuple!(string, string[]) group_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -959,11 +959,11 @@ template outputXHTMLs() { ); return u; } - string block(O,M)( + @safe string block(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -991,24 +991,24 @@ template outputXHTMLs() { } return o; } - string block_scroll(O,M)( + @safe string block_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = block(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) block_seg(O,M)( + @safe Tuple!(string, string[]) block_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1019,11 +1019,11 @@ template outputXHTMLs() { ); return u; } - string verse(O,M)( + @safe string verse(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -1051,24 +1051,24 @@ template outputXHTMLs() { } return o; } - string verse_scroll(O,M)( + @safe string verse_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = verse(_txt, obj, doc_matters); return o; } - Tuple!(string, string[]) verse_seg(O,M)( + @safe Tuple!(string, string[]) verse_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", - ) @safe { + ) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1079,10 +1079,10 @@ template outputXHTMLs() { ); return u; } - Tuple!(string, string) tablarize(O)( + @safe Tuple!(string, string) tablarize(O)( string _txt, const O obj, - ) @safe { + ) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; string _table; @@ -1112,11 +1112,11 @@ template outputXHTMLs() { ); return t; } - string table(O,M)( + @safe string table(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -1146,11 +1146,11 @@ template outputXHTMLs() { ); return o; } - string code(O,M)( + @safe string code(O,M)( string _txt, const O obj, M doc_matters, - ) @safe { + ) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); diff --git a/src/doc_reform/io_out/xmls_css.d b/src/doc_reform/io_out/xmls_css.d index 0974637..88af237 100644 --- a/src/doc_reform/io_out/xmls_css.d +++ b/src/doc_reform/io_out/xmls_css.d @@ -4,7 +4,7 @@ module doc_reform.io_out.xmls_css; template spineCss() { import std.format; - auto spineCss(M)(M doc_matters) @safe { + @safe auto spineCss(M)(M doc_matters) { string _css_indent = format(q"┃ /* indent */ p.norm { } @@ -4162,7 +4162,7 @@ template spineCss() { _css_indent, _color_ocn_dark, ); - auto css_() @safe { + @safe auto css_() { struct _CSS { string html_seg = "/* spine css html seg stylesheet */\n"; string html_scroll = "/* spine css html scroll stylesheet */\n"; diff --git a/src/doc_reform/meta/conf_make_meta_json.d b/src/doc_reform/meta/conf_make_meta_json.d index 4f33108..4fc3bc4 100644 --- a/src/doc_reform/meta/conf_make_meta_json.d +++ b/src/doc_reform/meta/conf_make_meta_json.d @@ -20,7 +20,7 @@ static template contentJSONtoSpineStruct() { doc_reform.meta.defaults, doc_reform.meta.rgx; ConfComposite _struct_composite; - auto contentJSONtoSpineStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) @safe { + @safe auto contentJSONtoSpineStruct(C,J,M)(C _struct_composite, J _json, M _manifested, string _identifier) { mixin spineRgxInit; static auto rgx = Rgx(); debug (json) { diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d index 121605a..683d355 100644 --- a/src/doc_reform/meta/conf_make_meta_structs.d +++ b/src/doc_reform/meta/conf_make_meta_structs.d @@ -16,7 +16,7 @@ mixin spineRgxInit; static auto rgx = Rgx(); mixin InternalMarkup; static auto mkup = InlineMarkup(); -string url_markup(string line) @safe { +@safe string url_markup(string line) { string line_ = line .replaceAll( rgx.smid_inline_link_markup_regular, diff --git a/src/doc_reform/meta/conf_make_meta_yaml.d b/src/doc_reform/meta/conf_make_meta_yaml.d index 69ec567..e55a24f 100644 --- a/src/doc_reform/meta/conf_make_meta_yaml.d +++ b/src/doc_reform/meta/conf_make_meta_yaml.d @@ -20,7 +20,7 @@ static template contentYAMLtoSpineStruct() { doc_reform.meta.defaults, doc_reform.meta.rgx; ConfComposite _struct_composite; - auto contentYAMLtoSpineStruct(C,Y,M)( + @system auto contentYAMLtoSpineStruct(C,Y,M)( C _struct_composite, Y _yaml, M _manifested, @@ -794,7 +794,7 @@ static template configParseYAMLreturnSpineStruct() { doc_reform.meta.conf_make_meta_structs, doc_reform.meta.conf_make_meta_json; mixin contentYAMLtoSpineStruct; - auto configParseYAMLreturnSpineStruct(T,CCm,M)( + @system auto configParseYAMLreturnSpineStruct(T,CCm,M)( T _document_struct, CCm _make_and_meta_struct, M _manifested @@ -832,7 +832,7 @@ static template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() { mixin spineRgxInit; mixin contentJSONtoSpineStruct; static auto rgx = Rgx(); - auto docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(CCm,Src,M)( + @system auto docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(CCm,Src,M)( Src header_src, CCm _make_and_meta_struct, M _manifested, diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d index 0b6388b..eff632e 100644 --- a/src/doc_reform/meta/defaults.d +++ b/src/doc_reform/meta/defaults.d @@ -4,7 +4,7 @@ module doc_reform.meta.defaults; template spineRgxInitFlags() { /+ regex flags +/ - static int[string] flags_type_init() { + @safe static int[string] flags_type_init() { int[string] flags_type_init = [ "make_headings" : 0, "header_make" : 0, @@ -45,7 +45,7 @@ template spineRgxInitFlags() { } } template spineNode() { - static string[string] node_metadata_heading_str() { + @safe static string[string] node_metadata_heading_str() { string[string] _node = [ "is" : "", "ocn" : "", @@ -56,7 +56,7 @@ template spineNode() { ]; return _node; } - static int[string] node_metadata_heading_int() { + @safe static int[string] node_metadata_heading_int() { int[string] _node = [ "ocn" : 0, // decide whether to use or keep? "ptr_doc_object" : 0, @@ -69,7 +69,7 @@ template spineNode() { ]; return _node; } - static string[string] node_metadata_para_str() { + @safe static string[string] node_metadata_para_str() { string[string] _node = [ "is" : "", "ocn" : "", @@ -77,7 +77,7 @@ template spineNode() { ]; return _node; } - static int[string] node_metadata_para_int() { + @safe static int[string] node_metadata_para_int() { int[string] _node = [ "ocn" : 0, "indent_base" : 0, @@ -88,7 +88,7 @@ template spineNode() { } } template spineHarvest() { - auto spineHarvest() { + @safe auto spineHarvest() { struct _Harvest { struct Harvest { string title = ""; @@ -122,7 +122,7 @@ template spineHarvest() { template spineBiblio() { // required: deemed_author (author || editor); year; fulltitle; struct BibJsnStr { - static auto biblio_entry_tags_jsonstr() { + @safe static auto biblio_entry_tags_jsonstr() { string x = `{ "is" : "", "sortby_deemed_author_year_title" : "", @@ -203,7 +203,7 @@ template InternalMarkup() { template spineLanguageCodes() { /+ language codes +/ struct Lang { - static string[string][string] codes() { + @safe static string[string][string] codes() { auto _lang_codes = [ "am": [ "c": "am", "n": "Amharic", "t": "Amharic", "xlp": "amharic" ], "bg": [ "c": "bg", "n": "Bulgarian", "t": "Български (Bəlgarski)", "xlp": "bulgarian" ], @@ -270,15 +270,15 @@ template spineLanguageCodes() { ]; return _lang_codes; } - static string[] code_arr_ptr() { + @safe static string[] code_arr_ptr() { string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "us", "vi", "zh", "en", "xx",]; return _lang_codes; } - static string[] code_arr() { + @safe static string[] code_arr() { string[] _lang_codes = ["am", "bg", "bn", "br", "ca", "cs", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "ga", "gl", "he", "hi", "hr", "hy", "ia", "is", "it", "ja", "ko", "la", "lo", "lt", "lv", "ml", "mr", "nl", "no", "nn", "oc", "pl", "pt", "pt_BR", "ro", "ru", "sa", "se", "sk", "sl", "sq", "sr", "sv", "ta", "te", "th", "tk", "tr", "uk", "ur", "vi", "zh"]; return _lang_codes; } - static auto codes_() { + @safe static auto codes_() { return "(" ~ join(code_arr,"|") ~ ")"; } static auto codes_regex() { diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index 03cb098..e18a19e 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -30,7 +30,7 @@ template spineAbstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstract_obj, doc_has } static auto rgx = Rgx(); - auto spineAbstraction(E,P,O,M,S)( + @system auto spineAbstraction(E,P,O,M,S)( E _env, P program_info, O _opt_action, @@ -108,39 +108,39 @@ template spineAbstraction() { writeln("step4 commence → (doc_matters)"); } struct DocumentMatters { - auto generator_program() { + @safe auto generator_program() { struct Prog_ { - string project_name() { + @safe string project_name() { return "spine"; } - string name() { + @safe string name() { return program_info.name; } - string ver() { + @safe string ver() { return program_info.ver; } - string name_and_version() @trusted { + @trusted string name_and_version() { return format("%s-%s", name, ver, ); } - string url_home() { + @safe string url_home() { return "http://sisudoc.org"; } - string url_git() { + @safe string url_git() { return "https://git.sisudoc.org/software/sisu"; } - auto compiler() { + @safe auto compiler() { return program_info.compiler; } - auto stime() { + @safe auto stime() { return Clock.currTime(UTC()).toSimpleString(); } } return Prog_(); } - auto generated_time() { + @safe auto generated_time() { auto _st = Clock.currTime(UTC()); auto _time = _st.year.to!string ~ "-" ~ _st.month.to!int.to!string // prefer as month number @@ -151,26 +151,26 @@ template spineAbstraction() { ~ ":" ~ _st.second.to!string; return _time; } - auto conf_make_meta() { + @safe auto conf_make_meta() { return _make_and_meta_struct; } - auto has() { + @safe auto has() { return _doc_has_struct; } - auto env() { + @safe auto env() { struct Env_ { - auto pwd() { + @safe auto pwd() { return _manifest.env.pwd; } - auto home() { + @safe auto home() { return _manifest.env.home; } } return Env_(); } - auto opt() { + @safe auto opt() { struct Opt_ { - auto action() { + @safe auto action() { /+ getopt options, commandline instructions, raw - processing instructions --epub --html etc. - command line config instructions --output-path @@ -180,27 +180,27 @@ template spineAbstraction() { } return Opt_(); } - auto src() { + @safe auto src() { return _manifest.src; } - auto src_path_info() { + @safe auto src_path_info() { return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path } - auto pod() { + @safe auto pod() { return _manifest.pod; } - auto sqlite() { + @safe auto sqlite() { struct SQLite_ { - string filename() { + @safe string filename() { return _opt_action.sqlite_filename; } } return SQLite_(); } - auto output_path() { + @safe auto output_path() { return _make_and_meta_struct.conf.output_path; } - auto srcs() { + @safe auto srcs() { struct SRC_ { auto file_insert_list() { return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 6dbbb22..3c58212 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -112,7 +112,7 @@ template docAbstraction() { bool, "has_images_without_dimensions", ); enum DomTags { none, open, close, close_and_open, open_still, } - pure ObjGenericComposite obj_heading_ancestors()( + @safe pure ObjGenericComposite obj_heading_ancestors()( ObjGenericComposite obj, string[] lv_ancestors_txt, ) { @@ -165,7 +165,7 @@ template docAbstraction() { } return obj; } - pure ObjGenericComposite obj_dom_structure_set_markup_tags()( + @safe pure ObjGenericComposite obj_dom_structure_set_markup_tags()( ObjGenericComposite obj, int[] dom, int lev @@ -209,7 +209,7 @@ template docAbstraction() { obj.metainfo.dom_structure_markedup_tags_status = dom.dup; return obj; } - pure ObjGenericComposite obj_dom_set_collapsed_tags()( + @safe pure ObjGenericComposite obj_dom_set_collapsed_tags()( ObjGenericComposite obj, int[] dom, int lev @@ -253,10 +253,10 @@ template docAbstraction() { obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; return obj; } - static auto ocn_emit(int ocn_status_flag) { + @safe static auto ocn_emit(int ocn_status_flag) { return object_citation_number.ocn_emitter(ocn_status_flag); } - static auto inline_markup_faces(L)(L line) { + @safe static auto inline_markup_faces(L)(L line) { static auto rgx = Rgx(); static auto mkup = InlineMarkup(); line = replaceAll!(m => mkup.quote_o ~ m[1] ~ mkup.quote_c)(line, rgx.within_quotes); @@ -267,7 +267,7 @@ template docAbstraction() { } return line; } - static string links_and_images()(string obj_txt) { + @safe static string links_and_images()(string obj_txt) { static auto rgx = Rgx(); static auto mkup = InlineMarkup(); if (obj_txt.match(rgx.smid_inline_url_generic)) { @@ -314,7 +314,7 @@ template docAbstraction() { ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment; auto node_construct = NodeStructureMetadata(); enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensions } - string[string][string] inline_para_link_anchor()( + @safe string[string][string] inline_para_link_anchor()( string[string] an_object, string[string] tag_in_seg, string[string][string] tag_assoc @@ -331,7 +331,7 @@ template docAbstraction() { return tag_assoc; } /+ ↓ abstract marked up document +/ - auto docAbstraction(CMM,Opt,Mf) ( + @system auto docAbstraction(CMM,Opt,Mf) ( char[][] markup_sourcefile_content, CMM conf_make_meta, Opt opt_action, @@ -1487,7 +1487,7 @@ template docAbstraction() { } the_document_head_section ~= the_document_body_section[0]; the_document_body_section=the_document_body_section[1..$]; - int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) { + @safe int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) { if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -1574,7 +1574,7 @@ template docAbstraction() { } return _ancestors_markup; } - int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) { + @safe int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_collapsed == 1) { _ancestors_collapsed = [ @@ -1755,7 +1755,7 @@ template docAbstraction() { } html_segnames_ptr_cntr++; } - auto get_decendants()(ObjGenericComposite[] document_sections) { + @safe auto get_decendants()(ObjGenericComposite[] document_sections) { int[string] _heading_ocn_decendants; string[] _ocn_open_key = ["","","","","","","",""]; auto _doc_sect_length = document_sections.length - 1; @@ -1803,7 +1803,7 @@ template docAbstraction() { return pairs.sort; } string[] _images; - string[] extract_images()(string content_block) { + @safe string[] extract_images()(string content_block) { string[] images_; if (auto m = content_block.matchAll(rgx.image)) { images_ ~= m.captures[1]; @@ -1811,7 +1811,7 @@ template docAbstraction() { return images_; } string[] segnames_0_to_4; - auto _image_dimensions(O,M)(O obj, M manifested) { + @system auto _image_dimensions(O,M)(O obj, M manifested) { if (obj.has.image_without_dimensions) { import std.math; import imageformats; @@ -1852,7 +1852,7 @@ template docAbstraction() { } return obj; } - auto _links(O)(O obj) { + @safe auto _links(O)(O obj) { if (auto m = obj.text.match(rgx.inline_link_stow_uri)) { debug(links) { writeln("number of link matches to stow: ", (obj.text.match(rgx.inline_link_stow_uri)).count); @@ -2358,7 +2358,7 @@ template docAbstraction() { dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - auto doc_has() { + @safe auto doc_has() { struct DocHas_ { uint inline_links() { return dochas["inline_links"]; @@ -2416,7 +2416,7 @@ template docAbstraction() { /+ post loop markup document/text ↑ +/ } /+ ← closed: abstract doc source +/ /+ ↓ abstraction functions +/ - static string[string] object_reset()(string[string] an_object) @safe { + @safe static string[string] object_reset()(string[string] an_object) { an_object.remove("body_nugget"); an_object.remove("substantive"); an_object.remove("is"); @@ -2424,7 +2424,7 @@ template docAbstraction() { an_object.remove("bookindex_nugget"); return an_object; } - void flow_common_reset_()( + @system void flow_common_reset_()( return ref int[string] line_occur, return ref string[string] an_object, return ref int[string] obj_type_status, @@ -2435,10 +2435,10 @@ template docAbstraction() { obj_type_status["para"] = State.off; an_object = an_object.object_reset; } - static int[string] _check_ocn_status_()( + @safe static int[string] _check_ocn_status_()( char[] line, int[string] obj_type_status, - ) @safe { + ) { static auto rgx = Rgx(); if (!(line.empty) && (obj_type_status["ocn_status_off_for_multiple_objects"] == OCN_off_block_status.off) @@ -2494,10 +2494,10 @@ template docAbstraction() { } return obj_type_status; } - char[] _doc_header_and_make_substitutions_(CMM)( + @safe char[] _doc_header_and_make_substitutions_(CMM)( char[] line, CMM conf_make_meta, - ) @safe { + ) { enum Substitute { match, markup, } if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { @@ -2509,10 +2509,10 @@ template docAbstraction() { } return line; } - char[] _doc_header_and_make_substitutions_fontface_(CMM)( + @safe char[] _doc_header_and_make_substitutions_fontface_(CMM)( char[] line, CMM conf_make_meta, - ) @safe { + ) { enum Substitute { match, markup, } if ( conf_make_meta.make.bold) { line = line.replaceAll( @@ -2534,12 +2534,12 @@ template docAbstraction() { } return line; } - void flow_txt_block_start()( + @safe void flow_txt_block_start()( char[] line, return ref int[string] obj_type_status, return ref uint[string] dochas, return ref string[string] object_number_poem - ) @safe { + ) { static auto rgx = Rgx(); if (auto m = line.matchFirst(rgx.block_curly_code_open)) { dochas["codeblock"]++; @@ -2720,11 +2720,11 @@ template docAbstraction() { obj_type_status["tic_table"] = TriState.on; } } - string[string] flow_txt_block_quote()( + @safe string[string] flow_txt_block_quote()( char[] line, string[string] an_object, return ref int[string] obj_type_status - ) @safe { + ) { static auto rgx = Rgx(); if (obj_type_status["curly_quote"] == TriState.on) { if (line.matchFirst(rgx.block_curly_quote_close)) { @@ -2759,11 +2759,11 @@ template docAbstraction() { } return an_object; } - string[string] flow_txt_block_group()( + @safe string[string] flow_txt_block_group()( char[] line, string[string] an_object, return ref int[string] obj_type_status - ) @safe { + ) { static auto rgx = Rgx(); if (obj_type_status["curly_group"] == State.on) { if (line.matchFirst(rgx.block_curly_group_close)) { @@ -2798,11 +2798,11 @@ template docAbstraction() { } return an_object; } - string[string] flow_txt_block_block()( + @safe string[string] flow_txt_block_block()( char[] line, string[string] an_object, return ref int[string] obj_type_status - ) @safe { + ) { static auto rgx = Rgx(); if (obj_type_status["curly_block"] == TriState.on) { if (line.matchFirst(rgx.block_curly_block_close)) { @@ -2837,7 +2837,7 @@ template docAbstraction() { } return an_object; } - string[string] flow_txt_block_poem(CMM)( + @safe string[string] flow_txt_block_poem(CMM)( char[] line, string[string] an_object, return ref int[string] obj_type_status, @@ -2845,7 +2845,7 @@ template docAbstraction() { string[string] object_number_poem, CMM conf_make_meta, string[string] tag_in_seg, - ) @safe { + ) { static auto rgx = Rgx(); if (obj_type_status["curly_poem"] == TriState.on) { if (line.matchFirst(rgx.block_curly_poem_close)) { @@ -3079,11 +3079,11 @@ template docAbstraction() { } return an_object; } - void flow_txt_block_code()( + @safe void flow_txt_block_code()( char[] line, return ref string[string] an_object, return ref int[string] obj_type_status - ) @safe { + ) { static auto rgx = Rgx(); if (obj_type_status["curly_code"] == TriState.on) { if (line.matchFirst(rgx.block_curly_code_close)) { @@ -3121,7 +3121,7 @@ template docAbstraction() { } } } - string[string] flow_txt_block_table(CMM)( + @system string[string] flow_txt_block_table(CMM)( char[] line, string[string] an_object, return ref int[string] obj_type_status, @@ -3179,7 +3179,7 @@ template docAbstraction() { } return an_object; } - final string biblio_tag_map()(string abr) { + @safe final string biblio_tag_map()(string abr) { auto btm = [ "au" : "author_raw", "ed" : "editor_raw", @@ -3198,7 +3198,7 @@ template docAbstraction() { ]; return btm[abr]; } - void flow_txt_block_biblio( + @system void flow_txt_block_biblio( char[] line, return ref int[string] obj_type_status, return ref int bib_entry, @@ -3327,7 +3327,7 @@ template docAbstraction() { header_tag_value=""; } } - void flow_table_closed_make_special_notation_table_(N,CMM)( + @system void flow_table_closed_make_special_notation_table_(N,CMM)( char[] line, return ref string[string] an_object, return ref ObjGenericComposite[] the_document_body_section, @@ -3368,7 +3368,7 @@ template docAbstraction() { processing.remove("verse"); ++cntr; } - string[string] flow_block_flag_line_empty_(B,N,CMM,Ts)( + @system string[string] flow_block_flag_line_empty_(B,N,CMM,Ts)( char[] line, string[string] an_object, B bookindex_extract_hash, @@ -3678,7 +3678,7 @@ template docAbstraction() { } return an_object; } - string[string] flow_book_index_(B)( + @system string[string] flow_book_index_(B)( char[] line, string[string] an_object, return ref string book_idx_tmp, @@ -3728,13 +3728,13 @@ template docAbstraction() { } return an_object; } - string[string] flow_heading_found_()( + @safe string[string] flow_heading_found_()( char[] line, string[string] heading_match_str, string[] _make_unmarked_headings, return ref Regex!(char)[string] heading_match_rgx, return ref int[string] obj_type_status - ) @safe { + ) { static auto rgx = Rgx(); if ((_make_unmarked_headings.length > 2) && (obj_type_status["make_headings"] == State.off)) { /+ headings found +/ @@ -3809,12 +3809,12 @@ template docAbstraction() { } return heading_match_str; } - char[] flow_heading_make_set_()( + @safe char[] flow_heading_make_set_()( char[] line, int[string] line_occur, return ref Regex!(char)[string] heading_match_rgx, return ref int[string] obj_type_status - ) @safe { + ) { if ((obj_type_status["make_headings"] == State.on) && ((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) @@ -3865,7 +3865,7 @@ template docAbstraction() { } return line; } - string[string] flow_heading_matched_(CMM)( + @safe string[string] flow_heading_matched_(CMM)( char[] line, string[string] an_object, return ref int[string] line_occur, @@ -3874,7 +3874,7 @@ template docAbstraction() { return ref int[string] collapsed_lev, return ref int[string] obj_type_status, return ref CMM conf_make_meta, - ) @safe { + ) { static auto rgx = Rgx(); if (auto m = line.match(rgx.heading)) { /+ heading match +/ ++line_occur["heading"]; @@ -4018,7 +4018,7 @@ template docAbstraction() { } return an_object; } - string[string] flow_para_match_()( + @safe string[string] flow_para_match_()( char[] line, string[string] an_object, return ref string an_object_key, @@ -4026,7 +4026,7 @@ template docAbstraction() { return ref bool bullet, return ref int[string] obj_type_status, return ref int[string] line_occur, - ) @safe { + ) { static auto rgx = Rgx(); if (line_occur["para"] == State.off) { line = font_faces_line(line); @@ -4071,9 +4071,9 @@ template docAbstraction() { } return an_object; } - char[] font_faces_line()( + @safe char[] font_faces_line()( char[] textline, - ) @safe { + ) { static auto rgx = Rgx(); static auto mkup = InlineMarkup(); if (textline.match(rgx.inline_faces_line)) { @@ -4093,10 +4093,10 @@ template docAbstraction() { } return textline; } - ObjGenericComposite flow_table_instructions(H)( + @safe ObjGenericComposite flow_table_instructions(H)( return ref ObjGenericComposite table_object, H table_head, - ) @safe { + ) { static auto rgx = Rgx(); table_object.metainfo.is_of_part = "body"; table_object.metainfo.is_of_section = "body"; @@ -4118,10 +4118,10 @@ template docAbstraction() { } return table_object; } - ObjGenericComposite flow_table_array_munge(T)( + @safe ObjGenericComposite flow_table_array_munge(T)( return ref ObjGenericComposite table_object, return ref T table_array, - ) @safe { + ) { static auto rgx = Rgx(); static auto mng = InlineMarkup(); string _table_substantive; @@ -4242,7 +4242,7 @@ template docAbstraction() { comp_obj_block.text = _table_substantive; return table_object; } - ObjGenericComposite flow_table_substantive_munge(T)( + @system ObjGenericComposite flow_table_substantive_munge(T)( return ref ObjGenericComposite table_object, return ref T table_substantive, ) { @@ -4258,7 +4258,7 @@ template docAbstraction() { table_object = table_object.flow_table_array_munge(_table); return table_object; } - ObjGenericComposite flow_table_substantive_munge_special(T)( + @system ObjGenericComposite flow_table_substantive_munge_special(T)( return ref ObjGenericComposite table_object, return ref T table_substantive, ) { @@ -4276,11 +4276,11 @@ template docAbstraction() { } /+ abstraction functions ↑ +/ /+ ↓ abstraction function emitters +/ - pure struct OCNemitter { + @safe pure struct OCNemitter { int ocn_digit, ocn_object_number, ocn_on_, ocn_off_, ocn_bkidx, ocn_bkidx_; string object_identifier; bool ocn_is_off; - auto ocn_emitter(int ocn_status_flag) @safe { + @safe auto ocn_emitter(int ocn_status_flag) { OCNset ocn; assert(ocn_status_flag <= OCNstatus.reset); ocn_object_number = ocn_bkidx = 0; @@ -4325,7 +4325,7 @@ template docAbstraction() { } } /+ +/ - static struct ObjInlineMarkupMunge { + @safe static struct ObjInlineMarkupMunge { string[string] obj_txt; int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; string asterisks_, plus_; @@ -4333,13 +4333,13 @@ template docAbstraction() { static auto rgx = Rgx(); static auto mkup = InlineMarkup(); int stage_reset_note_numbers = true; - private auto initialize_note_numbers() @safe { + private auto initialize_note_numbers() { n_foot = 0; n_foot_reg = 0; n_foot_sp_asterisk = 0; n_foot_sp_plus = 0; } - static auto images()(string obj_txt_in) @safe { + @safe static auto images()(string obj_txt_in) { static auto mng = InlineMarkup(); /+ url matched +/ obj_txt_in = obj_txt_in.replaceAll(rgx.inline_notes_al_special, ""); // TODO reinstate when special footnotes are implemented @@ -4369,7 +4369,7 @@ template docAbstraction() { } return obj_txt_in; } - TxtPlusHasFootnotes footnotes_endnotes_markup_and_number_or_stars()(string obj_txt_in, bool reset_note_numbers) @safe { + @safe TxtPlusHasFootnotes footnotes_endnotes_markup_and_number_or_stars()(string obj_txt_in, bool reset_note_numbers) { /+ endnotes (regular) +/ bool flg_notes_reg = false; bool flg_notes_star = false; @@ -4433,10 +4433,10 @@ template docAbstraction() { ); return t; } - private TxtPlusHasFootnotesUrlsImages object_notes_and_links_()( + @safe private TxtPlusHasFootnotesUrlsImages object_notes_and_links_()( string obj_txt_in, bool reset_note_numbers=false - ) @safe { + ) { obj_txt_out = ""; bool urls = false; bool images_without_dimensions = false; @@ -4496,10 +4496,10 @@ template docAbstraction() { } invariant() { } - auto munge_heading()( + @safe auto munge_heading()( string obj_txt_in, bool reset_note_numbers=false - ) @safe { + ) { obj_txt["munge"] = obj_txt_in .replaceFirst(rgx.heading, "") .replaceFirst(rgx.object_number_off_all, "") @@ -4515,7 +4515,7 @@ template docAbstraction() { } invariant() { } - auto munge_para()(string obj_txt_in) @safe { + @safe auto munge_para()(string obj_txt_in) { obj_txt["munge"]=(obj_txt_in) .replaceFirst(rgx.para_attribs, "") .replaceFirst(rgx.object_number_off_all, ""); @@ -4528,47 +4528,47 @@ template docAbstraction() { } return t; } - string munge_quote()(string obj_txt_in) @safe { + @safe string munge_quote()(string obj_txt_in) { obj_txt["munge"]=obj_txt_in; return obj_txt["munge"]; } invariant() { } - auto munge_group(string obj_txt_in) @safe { + @safe auto munge_group(string obj_txt_in) { obj_txt["munge"]=obj_txt_in; TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); return t; } invariant() { } - auto munge_block()(string obj_txt_in) @safe { + @safe auto munge_block()(string obj_txt_in) { obj_txt["munge"]=obj_txt_in; TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); return t; } invariant() { } - auto munge_verse()(string obj_txt_in) @safe { + @safe auto munge_verse()(string obj_txt_in) { obj_txt["munge"]=obj_txt_in; TxtPlusHasFootnotesUrlsImages t = object_notes_and_links_(obj_txt["munge"]); return t; } invariant() { } - string munge_code()(string obj_txt_in) @safe { + @safe string munge_code()(string obj_txt_in) { obj_txt_in = obj_txt_in.replaceAll(rgx.space, mkup.nbsp); obj_txt["munge"] = obj_txt_in; return obj_txt["munge"]; } invariant() { } - string munge_table()(string obj_txt_in) @safe { + @safe string munge_table()(string obj_txt_in) { obj_txt["munge"]=obj_txt_in; return obj_txt["munge"]; } invariant() { } - string munge_comment()(string obj_txt_in) @safe { + @safe string munge_comment()(string obj_txt_in) { obj_txt["munge"]=obj_txt_in; return obj_txt["munge"]; } @@ -4580,12 +4580,12 @@ template docAbstraction() { static auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; static string anchor_tag = ""; - TxtAndAnchorTagPlusHasFootnotesUrlsImages obj_inline_markup_and_anchor_tags_and_misc(CMM)( + @safe TxtAndAnchorTagPlusHasFootnotesUrlsImages obj_inline_markup_and_anchor_tags_and_misc(CMM)( string[string] obj_, string obj_key_, CMM conf_make_meta, Flag!"_new_doc" _new_doc - ) @safe { + ) { obj_txt["munge"] = obj_[obj_key_].dup; obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`))) ? obj_txt["munge"] @@ -4673,23 +4673,23 @@ template docAbstraction() { } invariant() { } - auto _clean_heading_toc_()( + @safe auto _clean_heading_toc_()( char[] heading_toc_, - ) @safe { + ) { auto m = (cast(char[]) heading_toc_).matchFirst(rgx.heading); heading_toc_ = (m.post).replaceAll( rgx.inline_notes_curly_gen, ""); return heading_toc_; }; - ObjGenericComposite[] flow_table_of_contents_gather_headings(CMM)( + @safe ObjGenericComposite[] flow_table_of_contents_gather_headings(CMM)( string[string] obj_, CMM conf_make_meta, string[string] tag_in_seg, string _anchor_tag, return ref string[][string] lev4_subtoc, ObjGenericComposite[] the_table_of_contents_section, - ) @safe { + ) { ObjGenericComposite comp_obj_toc; mixin InternalMarkup; static auto mkup = InlineMarkup(); @@ -4773,12 +4773,12 @@ template docAbstraction() { static string heading_number_auto_composite = ""; static string heading_number_auto_composite_segname = ""; static bool[] auto_heading_numbering = [ true, true, true, true]; - static string _configured_auto_heading_numbering_and_segment_anchor_tags(CMM)( + @safe static string _configured_auto_heading_numbering_and_segment_anchor_tags(CMM)( string munge_, string[string] obj_, CMM conf_make_meta, bool _new_doc, - ) @safe { + ) { if (_new_doc) { heading_num = [ 0, 0, 0, 0 ]; heading_number_auto_composite = ""; @@ -4917,11 +4917,11 @@ template docAbstraction() { return munge_; } static int heading_num_lev1 = 0; - static string _make_segment_anchor_tags_if_none_provided()( + @safe static string _make_segment_anchor_tags_if_none_provided()( string munge_, string lev_, bool _new_doc - ) @safe { + ) { if (!(munge_.match(rgx.heading_anchor_tag))) { if (munge_.match(rgx.heading_identify_anchor_tag)) { if (auto m = munge_.match(rgx.heading_extract_named_anchor_tag)) { @@ -4954,11 +4954,11 @@ template docAbstraction() { /+ +/ struct ObjAttributes { string[string] _obj_attrib; - string obj_attributes()( + @safe string obj_attributes()( string obj_is_, string obj_raw, ObjGenericComposite _comp_obj_heading, - ) @safe { + ) { scope(exit) { destroy(obj_is_); destroy(obj_raw); @@ -5017,7 +5017,7 @@ template docAbstraction() { } private: string _obj_attributes; - string txt_para_and_blocks()(string obj_txt_in) { + @safe string txt_para_and_blocks()(string obj_txt_in) { if (obj_txt_in.matchFirst(rgx.para_bullet)) { _obj_attributes =" \"bullet\": \"true\"," ~ " \"indent_hang\": 0," @@ -5041,7 +5041,7 @@ template docAbstraction() { } return _obj_attributes; } - string txt_heading()(string obj_txt_in) @safe { + @safe string txt_heading()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"para\"," ~ " \"is\": \"heading\""; @@ -5049,7 +5049,7 @@ template docAbstraction() { } invariant() { } - string txt_para()(string obj_txt_in) @safe { + @safe string txt_para()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"para\"," ~ " \"is\": \"para\""; @@ -5057,7 +5057,7 @@ template docAbstraction() { } invariant() { } - string txt_quote()(string obj_txt_in) @safe { + @safe string txt_quote()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," ~ " \"is\": \"quote\""; @@ -5065,7 +5065,7 @@ template docAbstraction() { } invariant() { } - string txt_group()(string obj_txt_in) @safe { + @safe string txt_group()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," ~ " \"is\": \"group\""; @@ -5073,7 +5073,7 @@ template docAbstraction() { } invariant() { } - string txt_block()(string obj_txt_in) @safe { + @safe string txt_block()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," ~ " \"is\": \"block\""; @@ -5081,7 +5081,7 @@ template docAbstraction() { } invariant() { } - string txt_verse()(string obj_txt_in) @safe { + @safe string txt_verse()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," ~ " \"is\": \"verse\""; @@ -5089,7 +5089,7 @@ template docAbstraction() { } invariant() { } - string txt_code()(string obj_txt_in) @safe { + @safe string txt_code()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," ~ " \"is\": \"code\""; @@ -5097,7 +5097,7 @@ template docAbstraction() { } invariant() { } - string txt_table()(string obj_txt_in) @safe { + @safe string txt_table()(string obj_txt_in) { _obj_attributes = " \"use\": \"content\"," ~ " \"of\": \"block\"," ~ " \"is\": \"table\""; @@ -5105,7 +5105,7 @@ template docAbstraction() { } invariant() { } - string txt_comment()(string obj_txt_in) @safe { + @safe string txt_comment()(string obj_txt_in) { _obj_attributes = " \"use\": \"comment\"," ~ " \"of\": \"comment\"," ~ " \"is\": \"comment\""; @@ -5113,11 +5113,11 @@ template docAbstraction() { } invariant() { } - string _set_additional_values_parse_as_json()( + @safe string _set_additional_values_parse_as_json()( string _obj_attrib, string obj_is_, ObjGenericComposite _comp_obj_heading, - ) @safe { + ) { JSONValue oa_j = parseJSON(_obj_attrib); assert( (oa_j.type == JSON_TYPE.OBJECT) @@ -5144,11 +5144,11 @@ template docAbstraction() { string[] object_numbers; string[][string][string] bi_hash_nugget; string[] bi_main_terms_split_arr; - string[][string][string] bookindex_nugget_hash(N,S)( + @safe string[][string][string] bookindex_nugget_hash(N,S)( string bookindex_section, N obj_cite_digits, S tag_in_seg, - ) @safe { + ) { debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } @@ -5214,9 +5214,9 @@ template docAbstraction() { } struct BookIndexReportIndent { int mkn, skn; - void bookindex_report_indented()( + @safe void bookindex_report_indented()( string[][string][string] bookindex_unordered_hashes - ) @safe { + ) { auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; foreach (mainkey; mainkeys) { @@ -5242,9 +5242,9 @@ template docAbstraction() { int mkn, skn; static auto rgx = Rgx(); static auto munge = ObjInlineMarkupMunge(); - void bookindex_write_section()( + @safe void bookindex_write_section()( string[][string][string] bookindex_unordered_hashes - ) @safe { + ) { auto mainkeys = bookindex_unordered_hashes.byKey.array .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release; @@ -5271,7 +5271,7 @@ template docAbstraction() { ++mkn; } } - auto bookindex_build_abstraction_section(N,B)( + @system auto bookindex_build_abstraction_section(N,B)( string[][string][string] bookindex_unordered_hashes, N obj_cite_digits, B opt_action, @@ -5435,11 +5435,11 @@ template docAbstraction() { int previous_count; int mkn; static auto rgx = Rgx(); - private auto gather_notes_for_endnote_section( + @safe private auto gather_notes_for_endnote_section( ObjGenericComposite[] contents_am, string[string] tag_in_seg, int cntr, - ) @safe { + ) { assert((contents_am[cntr].metainfo.is_a == "para") || (contents_am[cntr].metainfo.is_a == "heading") || (contents_am[cntr].metainfo.is_a == "quote") @@ -5515,7 +5515,7 @@ template docAbstraction() { } return object_notes; } - private auto gathered_notes() @safe { + @safe private auto gathered_notes() { string[][string] endnotes_; if (object_notes.length > 1) { endnotes_["notes"] = (object_notes["notes"].split(rgx.break_string))[0..$-1]; @@ -5526,10 +5526,10 @@ template docAbstraction() { } return endnotes_; } - private auto endnote_objects(N,O)( + @safe private auto endnote_objects(N,O)( N obj_cite_digits, O opt_action, - ) @safe { + ) { mixin spineNode; ObjGenericComposite[] the_endnotes_section; auto endnotes_ = gathered_notes(); @@ -5639,7 +5639,7 @@ template docAbstraction() { } /+ +/ struct Bibliography { - public JSONValue[] flow_bibliography_()( + @system public JSONValue[] flow_bibliography_()( return ref string[] biblio_unsorted_incomplete, return ref JSONValue[] bib_arr_json ) { @@ -5664,7 +5664,7 @@ template docAbstraction() { } return biblio_sorted__; } - final private JSONValue[] biblio_make_unsorted_array_of_json_objects()( + @system final private JSONValue[] biblio_make_unsorted_array_of_json_objects()( string[] biblio_unordered, JSONValue[] bib_arr_json ) { @@ -5692,7 +5692,7 @@ template docAbstraction() { } return bib_arr_json.dup; } - final private JSONValue[] biblio_sort()(JSONValue[] biblio_unordered) { + @system final private JSONValue[] biblio_sort()(JSONValue[] biblio_unordered) { JSONValue[] biblio_sorted_; biblio_sorted_ = sort!((a, b){ @@ -5707,7 +5707,7 @@ template docAbstraction() { } return biblio_sorted_; } - void biblio_debug()(JSONValue[] biblio_sorted) { + @system void biblio_debug()(JSONValue[] biblio_sorted) { debug(biblio0) { foreach (j; biblio_sorted) { if (!empty(j["fulltitle"].str)) { @@ -5723,7 +5723,7 @@ template docAbstraction() { int obj_cite_digit; int[string] p_; // p_ parent_ static auto rgx = Rgx(); - ObjGenericComposite node_location_emitter(La,Ta,N)( + @safe ObjGenericComposite node_location_emitter(La,Ta,N)( string lev_markup_number, string[string] tag_in_seg, La lev_anchor_tag, @@ -5732,7 +5732,7 @@ template docAbstraction() { int cntr_, int ptr_, string is_ - ) @safe { + ) { debug(asserts) { static assert(is(typeof(obj_cite_digits.object_number) == int)); } @@ -5777,7 +5777,7 @@ template docAbstraction() { } invariant() { } - ObjGenericComposite node_emitter_heading(Hd,TaL,TA,N,fNr,fNs,fL)( + @safe ObjGenericComposite node_emitter_heading(Hd,TaL,TA,N,fNr,fNs,fL)( string _text, string lev_markup_number, string lev_collapsed_number, @@ -5794,7 +5794,7 @@ template docAbstraction() { fNr flag_notes_reg, fNs flag_notes_star, fL flag_links, - ) @safe { + ) { debug(asserts) { static assert(is(typeof(lev) == string)); static assert(is(typeof(obj_cite_digits.object_number) == int)); @@ -5976,10 +5976,10 @@ template docAbstraction() { } /+ abstraction functions emitters ↑ +/ /+ ↓ abstraction functions assertions +/ - pure void assertions_doc_structure()( + @safe pure void assertions_doc_structure()( string[string] an_object, int[string] lv - ) @safe { + ) { if (lv["h3"] > State.off) { assert(lv["h0"] > State.off); assert(lv["h1"] > State.off); @@ -6151,7 +6151,7 @@ template docAbstraction() { break; } } - pure void assertions_flag_types_block_status_none_or_closed()(int[string] obj_type_status) @safe { + @safe pure void assertions_flag_types_block_status_none_or_closed()(int[string] obj_type_status) { assert( (obj_type_status["code"] == TriState.off) || (obj_type_status["code"] == TriState.closing), @@ -6176,7 +6176,7 @@ template docAbstraction() { /+ abstraction functions assertions ↑ +/ } /+ ← closed: template docAbstraction +/ template docSectKeysSeq() { - auto docSectKeysSeq(string[][string] document_section_keys_sequenced) @safe { + @safe auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { struct doc_sect_keys_seq { string[] scroll() { return document_section_keys_sequenced["scroll"]; diff --git a/src/doc_reform/meta/metadoc_harvest.d b/src/doc_reform/meta/metadoc_harvest.d index eb050e4..81f0ef4 100644 --- a/src/doc_reform/meta/metadoc_harvest.d +++ b/src/doc_reform/meta/metadoc_harvest.d @@ -1,9 +1,9 @@ module doc_reform.meta.metadoc_harvest; template spineMetaDocHarvest() { - auto spineMetaDocHarvest(T,H)( + @safe auto spineMetaDocHarvest(T,H)( T doc_matters, H hvst, - ) @safe { + ) { import doc_reform.meta.defaults, doc_reform.meta.rgx; diff --git a/src/doc_reform/meta/metadoc_object_setter.d b/src/doc_reform/meta/metadoc_object_setter.d index 908d168..e916a90 100644 --- a/src/doc_reform/meta/metadoc_object_setter.d +++ b/src/doc_reform/meta/metadoc_object_setter.d @@ -24,22 +24,22 @@ template ObjectSetter() { int o_n_bibliography = 0; int o_n_book_index = 0; int o_n_blurb = 0; - string object_number_substantive() const @property { + @safe string object_number_substantive() const @property { return (o_n_substantive==0) ? "" : o_n_substantive.to!string; } - string object_number_non_substantive() const @property { + @safe string object_number_non_substantive() const @property { return (o_n_non_substantive==0) ? "" : o_n_non_substantive.to!string; } - string object_number_glossary() const @property { + @safe string object_number_glossary() const @property { return (o_n_glossary==0) ? "" : o_n_glossary.to!string; } - string object_number_bibliography() const @property { + @safe string object_number_bibliography() const @property { return (o_n_bibliography==0) ? "" : o_n_bibliography.to!string; } - string object_number_book_index() const @property { + @safe string object_number_book_index() const @property { return (o_n_book_index==0) ? "" : o_n_book_index.to!string; } - string object_number_blurb() const @property { + @safe string object_number_blurb() const @property { return (o_n_blurb==0) ? "" : o_n_blurb.to!string; } bool object_number_off = false; @@ -49,13 +49,13 @@ template ObjectSetter() { string[string][string] node; int ocn = 0; string identifier = ""; - string object_number() const @property { + @safe string object_number() const @property { return (ocn==0) ? "" : ocn.to!string; } int o_n_type = 0; int heading_lev_markup = 9; int heading_lev_collapsed = 9; - string marked_up_level() const @property { + @safe string marked_up_level() const @property { string _out; switch (heading_lev_markup) { case 0 : _out = "A"; break; diff --git a/src/doc_reform/meta/metadoc_show_config.d b/src/doc_reform/meta/metadoc_show_config.d index b71fbab..a432c3b 100644 --- a/src/doc_reform/meta/metadoc_show_config.d +++ b/src/doc_reform/meta/metadoc_show_config.d @@ -1,6 +1,6 @@ module doc_reform.meta.metadoc_show_config; template spineShowConfig() { - void spineShowConfig(T)( + @safe void spineShowConfig(T)( T doc_matters, ) { import diff --git a/src/doc_reform/meta/metadoc_show_make.d b/src/doc_reform/meta/metadoc_show_make.d index e656a29..854552a 100644 --- a/src/doc_reform/meta/metadoc_show_make.d +++ b/src/doc_reform/meta/metadoc_show_make.d @@ -1,6 +1,6 @@ module doc_reform.meta.metadoc_show_make; template spineShowMake() { - void spineShowMake(T)( + @safe void spineShowMake(T)( T doc_matters, ) { import diff --git a/src/doc_reform/meta/metadoc_show_metadata.d b/src/doc_reform/meta/metadoc_show_metadata.d index 0bd6854..05758b6 100644 --- a/src/doc_reform/meta/metadoc_show_metadata.d +++ b/src/doc_reform/meta/metadoc_show_metadata.d @@ -1,6 +1,6 @@ module doc_reform.meta.metadoc_show_metadata; template spineShowMetaData() { - void spineShowMetaData(T)( + @safe void spineShowMetaData(T)( T doc_matters, ) { import diff --git a/src/doc_reform/meta/metadoc_show_summary.d b/src/doc_reform/meta/metadoc_show_summary.d index 9f2e34b..f774a6d 100644 --- a/src/doc_reform/meta/metadoc_show_summary.d +++ b/src/doc_reform/meta/metadoc_show_summary.d @@ -1,6 +1,6 @@ module doc_reform.meta.metadoc_show_summary; template spineMetaDocSummary() { - void spineMetaDocSummary(S,T)( + @safe void spineMetaDocSummary(S,T)( const S doc_abstraction, T doc_matters, ) { diff --git a/src/doc_reform/share/defaults.d b/src/doc_reform/share/defaults.d index ee0dbcb..2c3a098 100644 --- a/src/doc_reform/share/defaults.d +++ b/src/doc_reform/share/defaults.d @@ -4,7 +4,7 @@ module doc_reform.share.defaults; template Msg() { import std.stdio; - auto Msg(I)(I doc_matters) { + @safe auto Msg(I)(I doc_matters) { struct Msg_ { void v()(string message) { if (!(doc_matters.opt.action.quiet) && doc_matters.opt.action.verbose) { diff --git a/src/doc_reform/spine.d b/src/doc_reform/spine.d index 8108acb..39ea058 100755 --- a/src/doc_reform/spine.d +++ b/src/doc_reform/spine.d @@ -86,7 +86,7 @@ name "spine" description "A SiSU inspired document parser writen in D." homepage "http://sisudoc.org" +/ -void main(string[] args) { +@system void main(string[] args) { mixin spineRgxInit; mixin contentJSONtoSpineStruct; mixin spineBiblio; @@ -244,16 +244,16 @@ void main(string[] args) { } enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff } struct OptActions { - bool assertions() @trusted { + @trusted bool assertions() { return opts["assertions"]; } - bool concordance() @trusted { + @trusted bool concordance() { return opts["concordance"]; } auto config_path_set() { return settings["config"]; } - bool css_theme_default() @trusted { + @trusted bool css_theme_default() { bool _is_light; if (opts["light"] || opts["theme-light"]) { _is_light = true; @@ -264,94 +264,94 @@ void main(string[] args) { } return _is_light; } - bool debug_do() @trusted { + @trusted bool debug_do() { return opts["debug"]; } - bool digest() @trusted { + @trusted bool digest() { return opts["digest"]; } - bool epub() @trusted { + @trusted bool epub() { return opts["epub"]; } - bool harvest_link() @trusted { + @trusted bool harvest_link() { return (opts["harvest-link"]) ? true : false; } - bool harvest() @trusted { + @trusted bool harvest() { return (opts["harvest"] || opts["harvest-authors"] || opts["harvest-topics"]) ? true : false; } - bool harvest_authors() @trusted { + @trusted bool harvest_authors() { return (opts["harvest"] || opts["harvest-authors"]) ? true : false; } - bool harvest_topics() @trusted { + @trusted bool harvest_topics() { return (opts["harvest"] || opts["harvest-topics"]) ? true : false; } - bool html() @trusted { + @trusted bool html() { return (opts["html"] || opts["html-seg"] || opts["html-scroll"]) ? true : false; } - bool html_seg() @trusted { + @trusted bool html_seg() { return (opts["html"] || opts["html-seg"]) ? true : false; } - bool html_scroll() @trusted { + @trusted bool html_scroll() { return (opts["html"] || opts["html-scroll"]) ? true : false; } - bool html_stuff() @trusted { + @trusted bool html_stuff() { return (opts["html"] || opts["html-scroll"] || opts["html-seg"]) ? true : false; } - bool latex() @trusted { + @trusted bool latex() { return (opts["latex"] || opts["pdf"]) ? true : false; } - bool odt() @trusted { + @trusted bool odt() { return (opts["odf"] || opts["odt"]) ? true : false; } - bool manifest() @trusted { + @trusted bool manifest() { return opts["manifest"]; } - bool ocn_hidden() @trusted { + @trusted bool ocn_hidden() { return opts["hide-ocn"]; } - bool ocn_off() @trusted { + @trusted bool ocn_off() { return opts["ocn-off"]; } - bool quiet() @trusted { + @trusted bool quiet() { return opts["quiet"]; } - bool pod() @trusted { + @trusted bool pod() { return opts["pod"]; } - bool show_summary() @trusted { + @trusted bool show_summary() { return opts["show-summary"]; } - bool show_make() @trusted { + @trusted bool show_make() { return opts["show-make"]; } - bool show_metadata() @trusted { + @trusted bool show_metadata() { return opts["show-metadata"]; } - bool show_config() @trusted { + @trusted bool show_config() { return opts["show-config"]; } - bool source() @trusted { + @trusted bool source() { return opts["source"]; } - bool source_or_pod() @trusted { + @trusted bool source_or_pod() { return (opts["pod"] || opts["source"]) ? true : false; } - bool sqlite_discrete() @trusted { + @trusted bool sqlite_discrete() { return opts["sqlite-discrete"]; } - bool sqlite_db_drop() @trusted { + @trusted bool sqlite_db_drop() { return (opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) ? true : false; } - bool sqlite_db_create() @trusted { + @trusted bool sqlite_db_create() { return (opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) ? true : false; } - bool sqlite_delete() @trusted { + @trusted bool sqlite_delete() { return opts["sqlite-delete"]; } - bool sqlite_update() @trusted { + @trusted bool sqlite_update() { return (opts["sqlite-update"] || opts["sqlite-insert"]) ? true : false; } - bool sqlite_shared_db_action() @trusted { + @trusted bool sqlite_shared_db_action() { return ( opts["sqlite-db-recreate"] || opts["sqlite-db-create"] @@ -360,46 +360,46 @@ void main(string[] args) { || opts["sqlite-update"] ) ? true : false; } - bool text() @trusted { + @trusted bool text() { return opts["text"]; } - bool verbose() @trusted { + @trusted bool verbose() { return (opts["verbose"] || opts["very-verbose"]) ? true : false; } - bool very_verbose() @trusted { + @trusted bool very_verbose() { return opts["very-verbose"]; } - bool xhtml() @trusted { + @trusted bool xhtml() { return opts["xhtml"]; } - bool section_toc() @trusted { + @trusted bool section_toc() { return opts["section_toc"]; } - bool section_body() @trusted { + @trusted bool section_body() { return opts["section_body"]; } - bool section_endnotes() @trusted { + @trusted bool section_endnotes() { return opts["section_endnotes"]; } - bool section_glossary() @trusted { + @trusted bool section_glossary() { return opts["section_glossary"]; } - bool section_biblio() @trusted { + @trusted bool section_biblio() { return opts["section_biblio"]; } - bool section_bookindex() @trusted { + @trusted bool section_bookindex() { return opts["section_bookindex"]; } - bool section_blurb() @trusted { + @trusted bool section_blurb() { return opts["section_blurb"]; } - bool backmatter() @trusted { + @trusted bool backmatter() { return opts["backmatter"]; } - bool skip_output() @trusted { + @trusted bool skip_output() { return opts["skip-output"]; } - bool workon() @trusted { + @trusted bool workon() { return opts["workon"]; } auto languages_set() { @@ -411,7 +411,7 @@ void main(string[] args) { auto sqlite_filename() { return settings["sqlite-filename"]; } - bool parallelise() @trusted { + @trusted bool parallelise() { bool _is; if (opts["parallel"] == true) { _is = true; @@ -435,7 +435,7 @@ void main(string[] args) { } else { _is = false; } return _is; } - bool parallelise_subprocesses() @trusted { + @trusted bool parallelise_subprocesses() { return opts["parallel-subprocesses"]; } auto output_task_scheduler() { @@ -466,7 +466,7 @@ void main(string[] args) { } return schedule.sort().uniq; } - bool abstraction() @trusted { + @trusted bool abstraction() { return ( opts["abstraction"] || concordance @@ -482,7 +482,7 @@ void main(string[] args) { || sqlite_update ) ? true : false; } - bool meta_processing_general() @trusted { + @trusted bool meta_processing_general() { return ( opts["abstraction"] || html @@ -493,7 +493,7 @@ void main(string[] args) { || sqlite_update ) ? true :false; } - bool meta_processing_xml_dom() @trusted { + @trusted bool meta_processing_xml_dom() { return ( opts["abstraction"] || html @@ -505,20 +505,20 @@ void main(string[] args) { } } auto _opt_action = OptActions(); - auto program_info() { + @safe auto program_info() { struct ProgramInfo { - string project() { + @safe string project() { return project_name; } - string name() { + @safe string name() { return program_name; } - string ver() { + @safe string ver() { return format("%s.%s.%s", _ver.major, _ver.minor, _ver.patch, ); } - string compiler() { + @safe string compiler() { return format ("%s D:%s, %s %s", __VENDOR__, __VERSION__, bits, os, -- cgit v1.2.3