From 1083951efc4f8ddbf8de65907cc5aee2ac6be2ed Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph.amissah@gmail.com>
Date: Sat, 5 Oct 2019 20:45:42 -0400
Subject: 0.8.1 conf, make, meta: yaml only (toml removed)

- 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
---
 src/doc_reform/meta/conf_make_meta_toml.d |  81 --------------------
 src/doc_reform/meta/metadoc.d             |  18 +----
 src/doc_reform/meta/metadoc_summary.d     | 113 ---------------------------
 src/doc_reform/meta/rgx.d                 |   2 -
 src/doc_reform/source/read_config_files.d | 123 +-----------------------------
 src/doc_reform/source/read_source_files.d |   4 -
 6 files changed, 3 insertions(+), 338 deletions(-)
 delete mode 100644 src/doc_reform/meta/conf_make_meta_toml.d
 delete mode 100644 src/doc_reform/meta/metadoc_summary.d

(limited to 'src')

diff --git a/src/doc_reform/meta/conf_make_meta_toml.d b/src/doc_reform/meta/conf_make_meta_toml.d
deleted file mode 100644
index 0df63d3..0000000
--- a/src/doc_reform/meta/conf_make_meta_toml.d
+++ /dev/null
@@ -1,81 +0,0 @@
-/++
-  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;
-  }
-}
-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;
-  }
-}
-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;
-  }
-}
diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d
index a4ff476..115ab9f 100644
--- a/src/doc_reform/meta/metadoc.d
+++ b/src/doc_reform/meta/metadoc.d
@@ -42,9 +42,6 @@ template DocReformAbstraction() {
       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 +/
@@ -52,9 +49,6 @@ template DocReformAbstraction() {
       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);
       }
     }
     /+ ↓ read file (filename with path) +/
@@ -83,17 +77,9 @@ template DocReformAbstraction() {
     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/src/doc_reform/meta/metadoc_summary.d b/src/doc_reform/meta/metadoc_summary.d
deleted file mode 100644
index 7395e81..0000000
--- a/src/doc_reform/meta/metadoc_summary.d
+++ /dev/null
@@ -1,113 +0,0 @@
-module doc_reform.meta.metadoc_summary;
-template DocReformMetaDocSummary() {
-  void DocReformMetaDocSummary(S,T)(
-    const S  doc_abstraction,
-          T  doc_matters,
-  ) {
-    import
-      doc_reform.meta.defaults,
-      doc_reform.meta.rgx;
-    import
-      std.array,
-      std.exception,
-      std.regex,
-      std.stdio,
-      std.string,
-      std.traits,
-      std.typecons,
-      std.uni,
-      std.utf,
-      std.conv : to;
-    mixin InternalMarkup;
-    auto markup = InlineMarkup();
-    if (doc_matters.opt.action.verbose
-      || doc_matters.opt.action.show_summary
-    ) {
-      string[string] check = [
-        "last_object_number" : "NA [debug \"checkdoc\" not run]",
-        "last_object_number_body"  : "0",
-        "last_object_number_book_index" : "0",
-      ];
-      foreach (k; doc_matters.has.keys_seq.seg) {
-        foreach (obj; doc_abstraction[k]) {
-          if (obj.metainfo.is_of_part != "empty") {
-            if (!empty(obj.metainfo.object_number)) {
-              if (k == "body") {
-                check["last_object_number_body"] = obj.metainfo.object_number;
-              }
-              if (!(obj.metainfo.object_number.empty)) {
-                check["last_object_number"] = obj.metainfo.object_number;
-              }
-            }
-            if (k == "bookindex") {
-              if (obj.metainfo.object_number_type == 2) {
-                check["last_object_number_book_index"] = obj.metainfo.object_number_book_index;
-              }
-            }
-          }
-        }
-      }
-      auto min_repeat_number = 66;
-      auto char_repeat_number = (doc_matters.conf_make_meta.meta.title_full.length
-        + doc_matters.conf_make_meta.meta.creator_author.length + 4);
-      char_repeat_number = (char_repeat_number > min_repeat_number)
-      ? char_repeat_number
-      : min_repeat_number;
-      writefln(
-        "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%s",
-        markup.repeat_character_by_number_provided("-", char_repeat_number),
-        doc_matters.conf_make_meta.meta.title_full,
-        doc_matters.conf_make_meta.meta.creator_author,
-        doc_matters.src.filename,
-        markup.repeat_character_by_number_provided("-", char_repeat_number),
-        "- toc arr length:",
-        to!int(doc_abstraction["toc"].length),
-        "- doc_abstraction arr length:",
-        to!int(doc_abstraction["body"].length),
-        "  doc body last obj on.#:",
-        to!int(check["last_object_number_body"]),
-        "  - number of tables:",
-        doc_matters.has.tables,
-        "  - number of codeblocks:",
-        doc_matters.has.codeblocks,
-        "  - number of poems:",
-        doc_matters.has.poems,
-        "  - number of blocks:",
-        doc_matters.has.blocks,
-        "  - number of groups:",
-        doc_matters.has.groups,
-        "  - number of images:",
-        doc_matters.has.images,
-        "- endnotes length:",                                // subtract headings
-        (doc_abstraction["endnotes"].length > 2)
-        ? (to!int(doc_abstraction["endnotes"].length - 2))
-        : 0,
-        "- glossary length:",
-        (doc_abstraction["glossary"].length > 1)
-        ? (to!int(doc_abstraction["glossary"].length))
-        : 0,
-        "- biblio length:",
-        (doc_abstraction["bibliography"].length > 1)
-        ? (to!int(doc_abstraction["bibliography"].length))
-        : 0,
-        "- bookindex length:",
-        (doc_abstraction["bookindex"].length > 1)
-        ? (to!int(doc_abstraction["bookindex"].length))
-        : 0,
-        "  book idx last obj on.#:",
-        to!int(check["last_object_number_book_index"]),
-        "- blurb length:",
-        (doc_abstraction["blurb"].length > 1)
-        ? (to!int(doc_abstraction["blurb"].length))
-        : 0,
-        "* last obj on.#:",
-        to!int(check["last_object_number"]),
-        "number of segments:",
-        (doc_matters.has.segnames_lv4.length > 1)
-        ? (to!int(doc_matters.has.segnames_lv4.length))
-        : 0,
-        markup.repeat_character_by_number_provided("-", min_repeat_number),
-      );
-    }
-  }
-}
diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d
index 0168a08..11f4aa5 100644
--- a/src/doc_reform/meta/rgx.d
+++ b/src/doc_reform/meta/rgx.d
@@ -49,9 +49,7 @@ static template DocReformRgxInit() {
     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");
     /+ heading & paragraph operators +/
     static heading_a                                      = ctRegex!(`^:?[A][~] `, "m");
diff --git a/src/doc_reform/source/read_config_files.d b/src/doc_reform/source/read_config_files.d
index 93f8a35..787f6e0 100644
--- a/src/doc_reform/source/read_config_files.d
+++ b/src/doc_reform/source/read_config_files.d
@@ -4,94 +4,7 @@
   meta_config_files.d
 +/
 module doc_reform.source.read_config_files;
-static template configReadInSiteSTR() {
-  import
-    doc_reform.meta,
-    doc_reform.source.paths_source,
-    std.file,
-    std.path;
-  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;
-  }
-}
-static template configReadInDocSTR() {
-  import
-    doc_reform.meta,
-    doc_reform.source.paths_source,
-    std.file,
-    std.path;
-  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;
-  }
-}
-static template configTOML() {
-  import toml; //
-  import
-    doc_reform.meta,
-    doc_reform.source.paths_source,
-    std.file,
-    std.path;
-  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;
-  }
-}
+
 static template readConfigSite() {
   import
     doc_reform.meta.rgx;
@@ -137,8 +50,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;
       }
@@ -197,8 +108,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;
       }
@@ -236,33 +145,3 @@ static template configReadDocYAML() {
     return _yaml_conf;
   }
 }
-static template configReadSiteTOML() {
-  import
-    doc_reform.meta,
-    doc_reform.source.paths_source,
-    std.file,
-    std.path;
-  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() {
-  import
-    doc_reform.meta,
-    doc_reform.source.paths_source,
-    std.file,
-    std.path;
-  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;
-  }
-}
diff --git a/src/doc_reform/source/read_source_files.d b/src/doc_reform/source/read_source_files.d
index 753612e..05f6630 100644
--- a/src/doc_reform/source/read_source_files.d
+++ b/src/doc_reform/source/read_source_files.d
@@ -62,8 +62,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,
@@ -139,8 +137,6 @@ static template DocReformRawMarkupContent() {
       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,
-- 
cgit v1.2.3