aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/source
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2019-09-24 11:13:42 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-10-17 19:07:20 -0400
commitd43281245f1732941228d79663c8e8d3280a972c (patch)
tree0d0c814b11130e87768791a793204cc3588d8941 /src/doc_reform/source
parentflag --show-summary (diff)
document headers & config: yaml introduced
- as toml alternative - both toml & yaml (meta, conf, make) work
Diffstat (limited to 'src/doc_reform/source')
-rw-r--r--src/doc_reform/source/paths_source.d4
-rw-r--r--src/doc_reform/source/read_config_files.d84
-rw-r--r--src/doc_reform/source/read_source_files.d20
3 files changed, 86 insertions, 22 deletions
diff --git a/src/doc_reform/source/paths_source.d b/src/doc_reform/source/paths_source.d
index d02eae2..1bf3af1 100644
--- a/src/doc_reform/source/paths_source.d
+++ b/src/doc_reform/source/paths_source.d
@@ -397,10 +397,10 @@ template ConfigFilePaths() {
E _env,
) {
struct ConfFilePaths {
- string config_filename_document_toml() {
+ string config_filename_document() {
return "dr_document_make";
}
- string config_filename_site_toml() {
+ string config_filename_site() {
return "config_local_site";
}
auto possible_config_path_locations() {
diff --git a/src/doc_reform/source/read_config_files.d b/src/doc_reform/source/read_config_files.d
index 0855eab..96f604b 100644
--- a/src/doc_reform/source/read_config_files.d
+++ b/src/doc_reform/source/read_config_files.d
@@ -4,15 +4,15 @@
meta_config_files.d
+/
module doc_reform.source.read_config_files;
-static template configReadInSiteTOML() {
+static template configReadInSiteSTR() {
import
doc_reform.meta,
doc_reform.source.paths_source,
std.file,
std.path;
- final string configReadInSiteTOML(M,E)(M manifest, E env) {
+ 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_toml;
+ 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) {
@@ -39,15 +39,15 @@ static template configReadInSiteTOML() {
return config_file_str;
}
}
-static template configReadInDocTOML() {
+static template configReadInDocSTR() {
import
doc_reform.meta,
doc_reform.source.paths_source,
std.file,
std.path;
- final string configReadInDocTOML(M,E)(M manifest, E env) {
+ 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_toml;
+ 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) {
@@ -94,16 +94,20 @@ static template configTOML() {
}
static template readConfigSite() {
import
+ doc_reform.meta.rgx;
+ import
doc_reform.meta,
doc_reform.source.paths_source,
std.file,
std.path;
+ mixin DocReformRgxInit;
final auto readConfigSite(M,E)(M _manifest, E _env) {
+ static auto rgx = Rgx();
string config_file_str;
string conf_filename = "NONE";
auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.config_local_site;
- foreach(conf_fn; [_conf_file_details.config_filename_site_toml]) {
+ foreach(conf_fn; [_conf_file_details.config_filename_site]) {
foreach(pth; possible_config_path_locations) {
char[] conf_file = asNormalizedPath(chainPath(pth.to!string, conf_fn)).array;
conf_filename = conf_fn;
@@ -130,7 +134,13 @@ static template readConfigSite() {
return conf_filename;
}
string filetype() {
- return conf_filename.extension.chompPrefix(".");
+ string _ft = "";
+ if (content.match(rgx.yaml_config)) {
+ _ft = "yaml";
+ } else if (content.match(rgx.toml_config)) {
+ _ft = "toml";
+ }
+ return _ft;
}
string content() {
return config_file_str;
@@ -141,16 +151,20 @@ static template readConfigSite() {
}
static template readConfigDoc() {
import
+ doc_reform.meta.rgx;
+ import
doc_reform.meta,
doc_reform.source.paths_source,
std.file,
std.path;
+ mixin DocReformRgxInit;
final auto readConfigDoc(M,E)(M _manifest, E _env) {
+ static auto rgx = Rgx();
string config_file_str;
string conf_filename = "NONE";
auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.dr_document_make;
- foreach(conf_fn; [_conf_file_details.config_filename_document_toml]) {
+ foreach(conf_fn; [_conf_file_details.config_filename_document]) {
foreach(pth; possible_config_path_locations) {
auto conf_file = asNormalizedPath(chainPath(pth.to!string, conf_fn)).array;
conf_filename = conf_fn;
@@ -176,16 +190,52 @@ static template readConfigDoc() {
string filename() {
return conf_filename;
}
- string filetype() {
- return conf_filename.extension.chompPrefix(".");
- }
- auto content() {
+ string content() {
return config_file_str;
}
+ string filetype() {
+ string _ft = "";
+ if (content.match(rgx.yaml_config)) {
+ _ft = "yaml";
+ } else if (content.match(rgx.toml_config)) {
+ _ft = "toml";
+ }
+ return _ft;
+ }
}
return _ConfContent();
}
}
+static template configReadSiteYAML() {
+ import
+ doc_reform.meta,
+ doc_reform.source.paths_source,
+ std.file,
+ std.path;
+ import dyaml;
+ final YAMLDocument configReadSiteYAML(M,E)(M _manifest, E _env) {
+ string _configuration = configReadInSiteYAML!()(_manifest, _env);
+ auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
+ string _conf_yaml = _conf_file_details.config_filename_site;
+ YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml);
+ return _yaml_conf;
+ }
+}
+static template configReadDocYAML() {
+ import
+ doc_reform.meta,
+ doc_reform.source.paths_source,
+ std.file,
+ std.path;
+ import yaml;
+ final YAMLDocument configReadDocYAML(M,E)(M _manifest, E _env) {
+ string _configuration = configReadInDocYAML!()(_manifest, _env);
+ auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
+ string _conf_yaml = _conf_file_details.config_filename_document;
+ YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml);
+ return _yaml_conf;
+ }
+}
static template configReadSiteTOML() {
import
doc_reform.meta,
@@ -194,9 +244,9 @@ static template configReadSiteTOML() {
std.path;
import toml;
final TOMLDocument configReadSiteTOML(M,E)(M _manifest, E _env) {
- string _configuration = configReadInSiteTOML!()(_manifest, _env);
+ string _configuration = configReadInSiteSTR!()(_manifest, _env);
auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
- string _conf_toml = _conf_file_details.config_filename_site_toml;
+ string _conf_toml = _conf_file_details.config_filename_site;
TOMLDocument _toml_conf = configTOML!()(_configuration, _conf_toml);
return _toml_conf;
}
@@ -209,9 +259,9 @@ static template configReadDocTOML() {
std.path;
import toml;
final TOMLDocument configReadDocTOML(M,E)(M _manifest, E _env) {
- string _configuration = configReadInDocTOML!()(_manifest, _env);
+ string _configuration = configReadInDocSTR!()(_manifest, _env);
auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
- string _conf_toml = _conf_file_details.config_filename_document_toml;
+ 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 b19582d..753612e 100644
--- a/src/doc_reform/source/read_source_files.d
+++ b/src/doc_reform/source/read_source_files.d
@@ -59,13 +59,20 @@ static template DocReformRawMarkupContent() {
static assert(!isTypeTuple!(tu));
images_list = tu[2].dup;
}
+ 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,
sourcefile_body_content,
+ header_type,
insert_file_list,
images_list
);
- static assert(t.length==4);
+ static assert(t.length==5);
return t;
}
}
@@ -125,13 +132,20 @@ static template DocReformRawMarkupContent() {
auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) {
string[] file_insert_list = [];
string[] images_list = [];
- auto hc = header0Content1(source_txt_str);
- auto header = hc[0];
+ char[][] hc = header0Content1(source_txt_str);
+ char[] header = hc[0];
char[] source_txt = hc[1];
auto source_line_arr = markupSourceLineArray(source_txt);
+ 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,
source_line_arr,
+ header_type,
file_insert_list,
images_list
);