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/meta_conf_make_meta.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/meta_conf_make_meta.org')
-rw-r--r-- | org/meta_conf_make_meta.org | 102 |
1 files changed, 2 insertions, 100 deletions
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 |