aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/meta/conf_make_meta_toml.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2018-09-10 18:15:02 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-04-10 15:14:15 -0400
commite95c49b76f4ac7bf72c383ee43a0567dfcbf1603 (patch)
treeb3aec9058f69be0047bb526052f8deefb5d97463 /src/doc_reform/meta/conf_make_meta_toml.d
parentmaker, subprojects arrange, minor (diff)
0.1.0 renamed doc-reform, doc_reform (& rad)
- from sdp
Diffstat (limited to 'src/doc_reform/meta/conf_make_meta_toml.d')
-rw-r--r--src/doc_reform/meta/conf_make_meta_toml.d77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/doc_reform/meta/conf_make_meta_toml.d b/src/doc_reform/meta/conf_make_meta_toml.d
new file mode 100644
index 0000000..d308ae4
--- /dev/null
+++ b/src/doc_reform/meta/conf_make_meta_toml.d
@@ -0,0 +1,77 @@
+/++
+ 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 native header or sdlang one
+ with a regex check if whether it contains the "native header" required tag/field
+ @title: then process accordingly as a "native header" or "sdlang 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 = toJSON(_doc);
+ return _doc_json;
+ }
+}
+static template configParseTOMLreturnSiSUstruct() {
+ import
+ toml,
+ toml.json;
+ import
+ doc_reform.meta.conf_make_meta_structs,
+ doc_reform.meta.conf_make_meta_json;
+ mixin contentJSONtoSiSUstruct;
+ auto configParseTOMLreturnSiSUstruct(CCm, T)(
+ CCm _make_and_meta_struct,
+ T _document_struct
+ ){
+ TOMLDocument _doc = parseTOML(cast(string)(_document_struct.content));
+ auto _doc_json = toJSON(_doc);
+ _make_and_meta_struct = contentJSONtoSiSUstruct!()(_make_and_meta_struct, _doc_json, _document_struct.filename); // struct from json
+ return _make_and_meta_struct;
+ }
+}
+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 SiSUrgxInit;
+ mixin contentJSONtoSiSUstruct;
+ static auto rgx = Rgx();
+ auto docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct(CCm, Src)(
+ CCm _make_and_meta_struct,
+ Src header_src,
+ ) {
+ TOMLDocument _doc;
+ if (header_src.match(rgx.toml_header_meta_title)) {
+ debug (json) {
+ writeln(">>> document header is toml, convert to JSON");
+ }
+ _doc = parseTOML(cast(string)(header_src));
+ }
+ auto _doc_json = toJSON(_doc);
+ auto _header_and_make_and_meta_struct = contentJSONtoSiSUstruct!()(_make_and_meta_struct, _doc_json, "header");
+ return _header_and_make_and_meta_struct;
+ }
+}