aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/source/read_config_files.d
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/read_config_files.d
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/read_config_files.d')
-rw-r--r--src/doc_reform/source/read_config_files.d84
1 files changed, 67 insertions, 17 deletions
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;
}