diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2019-10-05 20:45:42 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-10-17 19:07:20 -0400 |
commit | 1083951efc4f8ddbf8de65907cc5aee2ac6be2ed (patch) | |
tree | 0b3f2dd576301a0d15d23c8a0ccc1afff1e86717 /org | |
parent | --show-{config,make,metadata,summary} (diff) |
0.8.1 conf, make, meta: yaml only (toml removed)doc-reform_v0.8.1
- yaml only: config, make & headers
(yaml is converted directly to struct)
- toml removed: preemptively remove confusion of
having multiple config formats
(toml was converted to json & json to struct)
- json removed (intermediate representation):
takes out intermediate conversion to json which
could be attractive to have if there are
multiple formats
Diffstat (limited to 'org')
-rw-r--r-- | org/default_regex.org | 2 | ||||
-rw-r--r-- | org/doc_reform.org | 26 | ||||
-rw-r--r-- | org/dr_build_scaffold.org | 29 | ||||
-rw-r--r-- | org/dr_info.org | 42 | ||||
-rw-r--r-- | org/meta_conf_make_meta.org | 102 | ||||
-rw-r--r-- | org/source_files_read.org | 135 |
6 files changed, 30 insertions, 306 deletions
diff --git a/org/default_regex.org b/org/default_regex.org index 63859f7..08af2ce 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -113,9 +113,7 @@ static make_simple_substitutions_d = ctRegex!(`(?P<substituti static variable_doc_title = ctRegex!(`@title`); static variable_doc_author = ctRegex!(`@author|@creator`); static raw_author_munge = ctRegex!(`(?P<last>\S.+?),\s+(?P<first>.+)`,"i"); -static toml_header_meta_title = ctRegex!(`^\s*(?:title\s*=\s*"|\[title\])`, "m"); static yaml_header_meta_title = ctRegex!(`^\s*(?:title\s*:\s*(?:"?\w|$))`, "m"); -static toml_config = ctRegex!(`^\s*(?:[a-z]+\s*=\s*"|\[\w+?\])`, "m"); static yaml_config = ctRegex!(`^[a-z]+\s*:\s*(?:"?\w|$)`, "m"); #+END_SRC diff --git a/org/doc_reform.org b/org/doc_reform.org index 1d853c1..abba098 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -28,7 +28,7 @@ struct Version { int minor; int patch; } -enum _ver = Version(0, 8, 0); +enum _ver = Version(0, 8, 1); #+END_SRC ** compilation restrictions (supported compilers) @@ -880,7 +880,7 @@ foreach(arg; args[1..$]) { *** config files load & read -#+NAME: doc_reform_conf_files_in_yaml_or_toml +#+NAME: doc_reform_conf_files_in_yaml #+BEGIN_SRC d ConfCompositePlus _make_and_meta_struct; { /+ document config file +/ @@ -888,9 +888,6 @@ ConfCompositePlus _make_and_meta_struct; if (_config_document_struct.filetype == "yaml") { import doc_reform.meta.conf_make_meta_yaml; _make_and_meta_struct = _config_document_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); - } else if (_config_document_struct.filetype == "toml") { - import doc_reform.meta.conf_make_meta_toml; - _make_and_meta_struct = _config_document_struct.configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); } } { /+ local site config +/ @@ -898,9 +895,6 @@ ConfCompositePlus _make_and_meta_struct; if (_config_local_site_struct.filetype == "yaml") { import doc_reform.meta.conf_make_meta_yaml; _make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); - } else if (_config_local_site_struct.filetype == "toml") { - import doc_reform.meta.conf_make_meta_toml; - _make_and_meta_struct = _config_local_site_struct.configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _manifest); } } #+END_SRC @@ -1120,7 +1114,7 @@ template DocReformAbstraction() { O _opt_action, M _manifest ){ - <<doc_reform_conf_files_in_yaml_or_toml>> + <<doc_reform_conf_files_in_yaml>> <<doc_reform_each_file_do_read_and_split_dr_markup_file_content_into_header_and_body>> <<doc_reform_each_file_do_split_dr_markup_file_header_into_make_and_meta_structs>> <<doc_reform_each_file_do_document_abstraction>> @@ -1185,7 +1179,7 @@ debug(header_and_body) { } #+END_SRC -*** 2. _document metadata_ & _make instructions_ (struct from toml) +*** 2. _document metadata_ & _make instructions_ (struct from yaml) - [[./meta_conf_make_meta.org][meta_conf_make_meta]] return tuple: document metadata; make instructions - read _document header_, split into: @@ -1204,17 +1198,9 @@ debug(header_and_body) { if ((_opt_action.debug_do) || (_opt_action.very_verbose) ) { - writeln("step2 commence → (read document header - yaml or toml, return struct)"); + writeln("step2 commence → (read document header (yaml) return struct)"); } -if (_header_body_insertfilelist_imagelist[headBody.header_type] == "toml") { - import doc_reform.meta.conf_make_meta_toml; - _make_and_meta_struct = - docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct!()( - _header_body_insertfilelist_imagelist[headBody.header], - _make_and_meta_struct, - _manifest, - ); -} else if (_header_body_insertfilelist_imagelist[headBody.header_type] == "yaml") { +if (_header_body_insertfilelist_imagelist[headBody.header_type] == "yaml") { import doc_reform.meta.conf_make_meta_yaml; _make_and_meta_struct = docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct!()( diff --git a/org/dr_build_scaffold.org b/org/dr_build_scaffold.org index 815be88..ca6b224 100644 --- a/org/dr_build_scaffold.org +++ b/org/dr_build_scaffold.org @@ -854,8 +854,6 @@ platforms "posix" dependency "d2sqlite3" version="~>0.18.3" # https://code.dlang.org/packages/d2sqlite3 http://biozic.github.io/d2sqlite3/d2sqlite3.html subconfiguration "d2sqlite3" "all-included" dependency "imageformats" version="~>7.0.1" # https://code.dlang.org/packages/imageformats https://github.com/lgvz/imageformats -dependency "toml" version="~>1.0.0-rc.3" # https://code.dlang.org/packages/toml https://github.com/toml-lang/toml/wiki -dependency "toml:json" version="~>1.0.0-rc.3" dependency "dyaml" version="~>0.8.0" dependency "tinyendian" version="~>0.2.0" // for dyaml #+END_SRC @@ -1010,7 +1008,6 @@ doc_reform_sources = [ 'src/doc_reform/conf/compile_time_info.d', 'src/doc_reform/meta/conf_make_meta_json.d', 'src/doc_reform/meta/conf_make_meta_structs.d', - 'src/doc_reform/meta/conf_make_meta_toml.d', 'src/doc_reform/meta/conf_make_meta_yaml.d', 'src/doc_reform/meta/defaults.d', 'src/doc_reform/meta/doc_debugs.d', @@ -1048,7 +1045,6 @@ sources_dir = include_directories('src/') # Dependencies dep_d2sqlite3 = dependency('d2sqlite3', version: '>= 0.16.2', fallback: ['d2sqlite3', 'd2sqlite3_dep']) dep_imageformats = dependency('imageformats-d', version: '>= 7.0.0', fallback: ['imageformats-d', 'imageformats_dep']) -dep_toml = dependency('toml-d', version: '>= 1.0.0', fallback: ['toml-d', 'toml_dep']) # executable doc_reform_exe = executable('rad', [doc_reform_sources], @@ -1057,7 +1053,6 @@ doc_reform_exe = executable('rad', dependencies : [ dep_d2sqlite3, dep_imageformats, - dep_toml ], install : true ) @@ -1081,14 +1076,6 @@ imageformats - https://github.com/lgvz/imageformats - mathias - https://github.com/ximion/imageformats.git - -toml -- dub - - https://code.dlang.org/packages/toml -- upstream - - https://github.com/Kripth/toml -- mathias - - https://github.com/ximion/toml.git #+END_SRC *** d2sqlite3 @@ -1109,15 +1096,6 @@ url = https://github.com/ximion/imageformats.git revision = head #+END_SRC -*** toml-d - -#+BEGIN_SRC sh :tangle ../subprojects/toml-d.wrap -[wrap-git] -directory = toml-d -url = https://github.com/ximion/toml.git -revision = head -#+END_SRC - * .gitignore :gitignore: #+BEGIN_SRC sh :tangle ../.gitignore @@ -1142,19 +1120,14 @@ revision = head !src !src/doc_reform !src/doc_reform/* -!src_toml -!src_toml/doc_reform -!src_toml/doc_reform/* !src_yaml !src_yaml/doc_reform !src_yaml/doc_reform/* !data !data/* !data/src/** -!data/src_toml/** !data/src_yaml/** !data/pod/** -!data/pod_toml/** !data/pod_yaml/** !*.sst !*.ssm @@ -1166,8 +1139,6 @@ revision = head !pod.manifest !sisu_document_make !config_local_site -!sisu_document_make.toml -!config_local_site.toml !sisudoc !views !docs/*.html diff --git a/org/dr_info.org b/org/dr_info.org index 10e0b25..dd5fa12 100644 --- a/org/dr_info.org +++ b/org/dr_info.org @@ -18,27 +18,27 @@ * README #+BEGIN_SRC text :tangle "../README" -- Name: Doc Reform - - Description: documents, structuring, processing, publishing, search - - static content generator - - - Author: Ralph Amissah - [ralph.amissah@gmail.com] - - - Copyright: (C) 2015 - 2019 Ralph Amissah, All Rights - Reserved. - - - Doc Reform (related to SiSU) uses standard: - - docReform markup syntax - - standard SiSU markup syntax with modified headers and minor modifications - - docReform object numbering - - standard SiSU object citation numbering & system - - - License: AGPL 3 or later - - - Hompages: - [http://www.doc_reform.org] - [http://www.sisudoc.org] +project_name: Doc Reform + description: [ + "documents, structuring, processing, publishing", + search, + object numbering, + static content generator, + sisu markup + ] + + author: + name: Ralph Amissah + email: ralph.amissah@gmail.com + + copyright: "(C) 2015 - 2019 Ralph Amissah, All Rights Reserved." + + license: "AGPL 3 or later" + + hompage: [ + "http://www.doc_reform.org", + "http://www.sisudoc.org" + ] #+END_SRC * COPYRIGHT & LICENSE diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index a8a5876..6912a3b 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -1799,37 +1799,7 @@ if ("rights" in _json.object) { } #+END_SRC -* 2. TOML returns DocReformStruct (via JSON) :module:conf_make_meta:struct: -** 0. parse TOML config return JSON - -#+BEGIN_SRC d :tangle "../src/doc_reform/meta/conf_make_meta_toml.d" -/++ - extract native/orig header return associative array<BR> - - the header is passed as text (lopped off top of a sisu markup file until the - required first heading ^A~), determine whether is a yaml header or toml one - with a regex check if whether it contains the "yaml header" required tag/field - title: then process accordingly as a "yaml header" or "toml header" - converting the metadata and make instructions to a common json format used by - program internally. Moved to associative array. -+/ -module doc_reform.meta.conf_make_meta_toml; -static template configParseTOMLreturnJSON() { - import - toml, - toml.json; - auto configParseTOMLreturnJSON(T)( - T _text - ){ - TOMLDocument _doc; - _doc = parseTOML(cast(string)(_text.content)); - auto _doc_json = _doc.toJSON; - return _doc_json; - } -} -#+END_SRC - -** 1. parse TOML config to JSON return DocReformStruct +** 1. parse Yaml config return DocReformStruct #+BEGIN_SRC d :tangle "../src/doc_reform/meta/conf_make_meta_yaml.d" static template configParseYAMLreturnDocReformStruct() { @@ -1851,73 +1821,6 @@ static template configParseYAMLreturnDocReformStruct() { } #+END_SRC -** 1. parse TOML config to JSON return DocReformStruct - -#+BEGIN_SRC d :tangle "../src/doc_reform/meta/conf_make_meta_toml.d" -static template configParseTOMLreturnDocReformStruct() { - import - toml, - toml.json; - import - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.conf_make_meta_json; - mixin contentJSONtoDocReformStruct; - auto configParseTOMLreturnDocReformStruct(T,CCm,M)( - T _document_struct, - CCm _make_and_meta_struct, - M _manifest - ){ - TOMLDocument _doc = parseTOML(cast(string)(_document_struct.content)); - auto _doc_json = _doc.toJSON; - _make_and_meta_struct - = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, _document_struct.filename); // struct from json - return _make_and_meta_struct; - } -} -#+END_SRC - -** 2. parse TOML header to JSON then Struct - -#+BEGIN_SRC d :tangle "../src/doc_reform/meta/conf_make_meta_toml.d" -static template docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct() { - import - std.exception, - std.regex, - std.stdio, - std.traits, - std.typecons, - std.utf, - std.conv : to; - import - toml, - toml.json; - import - doc_reform.meta.conf_make_meta_structs, - doc_reform.meta.conf_make_meta_json, - doc_reform.meta.rgx; - mixin DocReformRgxInit; - mixin contentJSONtoDocReformStruct; - static auto rgx = Rgx(); - auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm,Src,M)( - Src header_src, - CCm _make_and_meta_struct, - M _manifest, - ) { - TOMLDocument _doc_toml; - if (header_src.match(rgx.toml_header_meta_title)) { - debug (json) { - writeln(">>> document header is toml, convert to JSON"); - } - _doc_toml = parseTOML(cast(string)(header_src)); - } - auto _doc_json = _doc_toml.toJSON; - auto _header_and_make_and_meta_struct - = contentJSONtoDocReformStruct!()(_make_and_meta_struct, _doc_json, _manifest, "header"); - return _header_and_make_and_meta_struct; - } -} -#+END_SRC - ** 2. parse YAML header to +(JSON then)+ Struct #+BEGIN_SRC d :tangle "../src/doc_reform/meta/conf_make_meta_yaml.d" @@ -1965,9 +1868,8 @@ static template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() { #+BEGIN_SRC d /+ /+ - unify internal representation of header info for yaml & toml document headers + unify internal representation of header info for yaml document headers represent either using struct, hashes or possibly json - doc_reform internal representation should be identical for yaml & toml variants +/ header. ├── make // make instructions diff --git a/org/source_files_read.org b/org/source_files_read.org index 6106930..ecf6cc7 100644 --- a/org/source_files_read.org +++ b/org/source_files_read.org @@ -38,11 +38,10 @@ import +/ module doc_reform.source.read_config_files; <<meta_config_file_in>> -<<meta_config_file_toml>> <<meta_config_file_hub>> #+END_SRC -*** 0. read config files (config_local_site & dr_document_make) (yaml or toml) +*** 0. read config files (config_local_site & dr_document_make) (yaml) **** 1. site configuration #+name: meta_config_file_hub @@ -88,8 +87,6 @@ static template readConfigSite() { string _ft = ""; if (content.match(rgx.yaml_config)) { _ft = "yaml"; - } else if (content.match(rgx.toml_config)) { - _ft = "toml"; } return _ft; } @@ -150,8 +147,6 @@ static template readConfigDoc() { string _ft = ""; if (content.match(rgx.yaml_config)) { _ft = "yaml"; - } else if (content.match(rgx.toml_config)) { - _ft = "toml"; } return _ft; } @@ -161,82 +156,6 @@ static template readConfigDoc() { } #+END_SRC -** A. TOML :toml: -*** 1. TOML read config files (config_local_site & dr_document_make) :file:config: -**** TOML config_local_site - -#+name: meta_config_file_in -#+BEGIN_SRC d -static template configReadInSiteSTR() { - <<imports_std>> - final string configReadInSiteSTR(M,E)(M manifest, E env) { - auto conf_file_details = ConfigFilePaths!()(manifest, env); - string conf_toml = conf_file_details.config_filename_site; - string[] possible_config_path_locations = conf_file_details.possible_config_path_locations.config_local_site; - string config_file_str; - debug(io) { - writeln("WARNING (io debug) in config filename: ", conf_toml); - writeln("WARNING (io debug) in config possible path locations: ", possible_config_path_locations); - } - foreach(pth; possible_config_path_locations) { - auto conf_file = ((chainPath(pth.to!string, conf_toml)).asNormalizedPath).array; - if (config_file_str.length > 0) { - break; - } - try { - if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); - } - config_file_str = conf_file.readText; - break; - } - } catch (ErrnoException ex) { - } catch (FileException ex) { - } - } - return config_file_str; - } -} -#+END_SRC - -**** TOML dr_document_make - -#+name: meta_config_file_in -#+BEGIN_SRC d -static template configReadInDocSTR() { - <<imports_std>> - final string configReadInDocSTR(M,E)(M manifest, E env) { - auto conf_file_details = ConfigFilePaths!()(manifest, env); - string conf_toml = conf_file_details.config_filename_document; - string[] possible_config_path_locations = conf_file_details.possible_config_path_locations.dr_document_make; - string config_file_str; - debug(io) { - writeln("WARNING (io debug) in config filename: ", conf_toml); - writeln("WARNING (io debug) in config possible path locations: ", possible_config_path_locations); - } - foreach(pth; possible_config_path_locations) { - auto conf_file = ((chainPath(pth.to!string, conf_toml)).asNormalizedPath).array; - if (config_file_str.length > 0) { - break; - } - try { - if (exists(conf_file)) { - debug(io) { - writeln("WARNING (io debug) in config file found: ", conf_file); - } - config_file_str = conf_file.readText; - break; - } - } catch (ErrnoException ex) { - } catch (FileException ex) { - } - } - return config_file_str; - } -} -#+END_SRC - *** 2. YAML config files get #+name: meta_config_file_yaml @@ -285,54 +204,6 @@ static template configReadDocYAML() { } #+END_SRC -*** 2. TOML config files get - -#+name: meta_config_file_toml -#+BEGIN_SRC d -static template configTOML() { - import toml; // - <<imports_std>> - TOMLDocument configTOML(string configuration, string conf_toml_filename) { - TOMLDocument _toml_conf; - try { - _toml_conf = parseTOML(configuration); // parseTOML(cast(string)(configuration)); - } catch(ErrnoException e) { - stderr.writeln("Toml problem with content for ", conf_toml_filename); - stderr.writeln(e.msg); - } - return _toml_conf; - } -} -#+END_SRC - -*** 3. TOML config (config_local_site & dr_document_make) :file:config:hub: - -#+name: meta_config_file_hub -#+BEGIN_SRC d -static template configReadSiteTOML() { - <<imports_std>> - import toml; - final TOMLDocument configReadSiteTOML(M,E)(M _manifest, E _env) { - string _configuration = configReadInSiteSTR!()(_manifest, _env); - auto _conf_file_details = ConfigFilePaths!()(_manifest, _env); - string _conf_toml = _conf_file_details.config_filename_site; - TOMLDocument _toml_conf = configTOML!()(_configuration, _conf_toml); - return _toml_conf; - } -} -static template configReadDocTOML() { - <<imports_std>> - import toml; - final TOMLDocument configReadDocTOML(M,E)(M _manifest, E _env) { - string _configuration = configReadInDocSTR!()(_manifest, _env); - auto _conf_file_details = ConfigFilePaths!()(_manifest, _env); - string _conf_toml = _conf_file_details.config_filename_document; - TOMLDocument _toml_conf = configTOML!()(_configuration, _conf_toml); - return _toml_conf; - } -} -#+END_SRC - * B. get _markup source_, read file :module:source_files: ** 0. module template (includes tuple) @@ -397,8 +268,6 @@ static template DocReformRawMarkupContent() { string header_type = ""; if (header_raw.match(rgx.yaml_config)) { header_type = "yaml"; - } else if (header_raw.match(rgx.toml_config)) { - header_type = "toml"; } t = tuple( header_raw, @@ -552,8 +421,6 @@ auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { string header_type = ""; if (header.match(rgx.yaml_config)) { header_type = "yaml"; - } else if (header.match(rgx.toml_config)) { - header_type = "toml"; } auto t = tuple( header, |