aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/meta
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2018-07-07 13:55:43 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:15 -0400
commitae23669169b32d4986af06c1ae9483cc9c52d39d (patch)
tree7fc84b06846bf9b09b44ca13ed969901acb717c1 /src/sdp/meta
parentparent ocn (diff)
0.26.4 file renames, cleaning, reorganisation
Diffstat (limited to 'src/sdp/meta')
-rw-r--r--src/sdp/meta/conf_make_meta_sdlang.d474
-rw-r--r--src/sdp/meta/doc_debugs.d14
-rw-r--r--src/sdp/meta/metadoc.d8
-rw-r--r--src/sdp/meta/read_config_files.d226
-rw-r--r--src/sdp/meta/read_source_files.d354
5 files changed, 11 insertions, 1065 deletions
diff --git a/src/sdp/meta/conf_make_meta_sdlang.d b/src/sdp/meta/conf_make_meta_sdlang.d
deleted file mode 100644
index 4ebe960..0000000
--- a/src/sdp/meta/conf_make_meta_sdlang.d
+++ /dev/null
@@ -1,474 +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 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 sdp.meta.conf_make_meta_sdlang;
-static template docHeaderMakeAndMetaTupSDLangExtractAndConvertToStruct() {
- import
- std.exception,
- std.regex,
- std.stdio,
- std.traits,
- std.typecons,
- std.utf,
- std.conv : to;
- import sdlang;
- import
- sdp.meta.conf_make_meta_sdlang,
- sdp.meta.rgx;
- mixin SiSUrgxInit;
- mixin SiSUextractSDLang;
- static auto rgx = Rgx();
- auto docHeaderMakeAndMetaTupSDLangExtractAndConvertToStruct(CCm, Src)(
- CCm conf_composite_make,
- Src header_src,
- ) {
- auto header_sdlang_tag = (header_src.match(rgx.sdlang_header_meta_title))
- ? extractSDL().docHeaderSDLtagGet(header_src) // sdlang.ast.Tag
- : null;
- auto header_make_and_meta_struct = extractSDL().docSDLtoStruct(conf_composite_make, header_sdlang_tag);
- return header_make_and_meta_struct;
- }
-}
-/++
- sdlang headers<BR>
- extract sdlang header return sdlang
-+/
-static template SiSUextractSDLang() {
- import
- std.exception,
- std.regex,
- std.stdio,
- std.string,
- std.traits,
- std.typecons,
- std.utf,
- std.conv : to;
- import
- sdp.meta.conf_make_meta_structs,
- sdp.meta.rgx;
- struct extractSDL {
- mixin SiSUmakeMetaStructsSDLang;
- mixin SiSUrgxInit;
- static auto rgx = Rgx();
- private auto docHeaderSDLtagGet(Hs)(Hs src_header) {
- debug(asserts){
- static assert(is(typeof(src_header) == char[]));
- }
- char[][] source_header_arr
- = (cast(char[]) src_header).split(rgx.newline_eol_delimiter);
- char[] _src_header;
- foreach(header_line; source_header_arr) {
- if (!match(header_line, rgx.comments)) {
- _src_header ~= header_line ~ "\n";
- }
- }
- scope(failure) {
- stderr.writefln(
- "%s\n%s\n%s:%s failed here:\n _src_header: %s",
- __MODULE__, __FUNCTION__,
- __FILE__, __LINE__,
- _src_header,
- );
- }
- Tag sdl_root_header;
- try {
- sdl_root_header = parseSource(_src_header.to!string);
- }
- catch(ParseException e) {
- stderr.writeln("SDLang problem with this document header:");
- stderr.writeln(_src_header);
- // Error messages of the form:
- // myFile.sdl(5:28): Error: Invalid integer suffix.
- stderr.writeln(e.msg);
- }
- debug(sdlang) {
- writeln("header SDL:");
- writeln(__LINE__, ": ", sdl_root_header.toSDLDocument());
- writeln(__LINE__, ": ", sdl_root_header.maybe.namespaces);
- writeln("header make sdlang: ", sdl_root_header.toSDLDocument());
- writeln(__LINE__, ": ", sdl_root_header.getTagValues("title"));
- writeln(__LINE__, ": ", sdl_root_header.getTagValues("creator"));
- Tag creator = sdl_root_header.getTag("creator");
- if (creator !is null) {
- if ("author" in creator.maybe.tags) {
- writeln(__LINE__, ": ", creator.getTagValues("author"));
- } else if ("author" in creator.maybe.attributes) {
- writeln(__LINE__, ": ", creator.maybe.attributes["author"][0].value);
- }
- }
- }
- return sdl_root_header; // sdlang.ast.Tag
- }
- private auto docSDLtoStruct(C,Tag)(C _conf_composite, Tag header_sdlang) { // work on
- /+ make ------------------------------------------------------------------- +/
- if ("make" in header_sdlang.maybe.tags) {
- confCompositeMakeBuild _mk;
- _conf_composite.make_str.bold = extractSDLangTabOrAttrib(header_sdlang, "make", "bold"); // TODO
- _conf_composite.make_str.breaks = extractSDLangTabOrAttrib(header_sdlang, "make", "breaks");
- _conf_composite.make_str.cover_image = extractSDLangTabOrAttrib(header_sdlang, "make", "cover_image");
- _conf_composite.make_str.css = extractSDLangTabOrAttrib(header_sdlang, "make", "css");
- _conf_composite.make_str.emphasis = extractSDLangTabOrAttrib(header_sdlang, "make", "emphasis"); // TODO
- _conf_composite.make_str.footer = extractSDLangTabOrAttrib(header_sdlang, "make", "footer");
- _conf_composite.make_str.headings = extractSDLangTabOrAttrib(header_sdlang, "make", "headings");
- _conf_composite.make_str.home_button_image = extractSDLangTabOrAttrib(header_sdlang, "make", "home_button_image");
- _conf_composite.make_str.home_button_text = extractSDLangTabOrAttrib(header_sdlang, "make", "home_button_text");
- _conf_composite.make_str.italics = extractSDLangTabOrAttrib(header_sdlang, "make", "italics"); // TODO
- _conf_composite.make_str.num_top = extractSDLangTabOrAttrib(header_sdlang, "make", "num_top");
- _conf_composite.make_str.num_depth = extractSDLangTabOrAttrib(header_sdlang, "make", "num_depth");
- _conf_composite.make_str.substitute = extractSDLangTabOrAttrib(header_sdlang, "make", "substitute"); // TODO
- _conf_composite.make_str.texpdf_font = extractSDLangTabOrAttrib(header_sdlang, "make", "texpdf_font");
- _conf_composite.make.bold_rgxmatch = _mk.bold_rgxmatch(_conf_composite.make_str.bold);
- _conf_composite.make.breaks = _mk.breaks(_conf_composite.make_str.breaks);
- _conf_composite.make.cover_image = _mk.cover_image(_conf_composite.make_str.cover_image);
- _conf_composite.make.css = _mk.css(_conf_composite.make_str.css);
- _conf_composite.make.emphasis_rgxmatch = _mk.emphasis_rgxmatch(_conf_composite.make_str.emphasis);
- _conf_composite.make.footer = _mk.footer(_conf_composite.make_str.footer);
- _conf_composite.make.headings = _mk.headings(_conf_composite.make_str.headings);
- _conf_composite.make.home_button_image = _mk.home_button_image(_conf_composite.make_str.home_button_image);
- _conf_composite.make.home_button_text = _mk.home_button_text(_conf_composite.make_str.home_button_text);
- _conf_composite.make.italics_rgxmatch = _mk.italics_rgxmatch(_conf_composite.make_str.italics);
- _conf_composite.make.num_top = _mk.num_top(_conf_composite.make_str.num_top);
- _conf_composite.make.num_depth = _mk.num_depth(_conf_composite.make_str.num_depth);
- _conf_composite.make.substitute = _mk.substitute(_conf_composite.make_str.substitute);
- _conf_composite.make.texpdf_font = _mk.texpdf_font(_conf_composite.make_str.texpdf_font);
- }
- /+ conf ------------------------------------------------------------------- +/
- if ("webserv" in header_sdlang.maybe.tags) {
- _conf_composite.conf.webserv_url_root = extractSDLangTabOrAttrib(header_sdlang, "webserv", "url_root");
- _conf_composite.conf.webserv_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "path");
- _conf_composite.conf.webserv_images = extractSDLangTabOrAttrib(header_sdlang, "webserv", "images");
- _conf_composite.conf.webserv_cgi = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi");
- _conf_composite.conf.webserv_cgi_host = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_host");
- _conf_composite.conf.webserv_cgi_host_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_host_path");
- _conf_composite.conf.webserv_cgi_port = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_port");
- _conf_composite.conf.webserv_cgi_user = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_user");
- _conf_composite.conf.webserv_cgi_file_links = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_file_links");
- }
- if ("processing" in header_sdlang.maybe.tags) {
- _conf_composite.conf.processing_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_path");
- _conf_composite.conf.processing_dir = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_dir");
- _conf_composite.conf.processing_concord_max = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_concord_max");
- }
- if ("flag" in header_sdlang.maybe.tags) {
- _conf_composite.conf.flag_act0 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act0");
- _conf_composite.conf.flag_act1 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act1");
- _conf_composite.conf.flag_act2 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act2");
- _conf_composite.conf.flag_act3 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act3");
- _conf_composite.conf.flag_act4 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act4");
- _conf_composite.conf.flag_act5 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act5");
- _conf_composite.conf.flag_act6 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act6");
- _conf_composite.conf.flag_act7 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act7");
- _conf_composite.conf.flag_act8 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act8");
- _conf_composite.conf.flag_act9 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act9");
- }
- if ("default" in header_sdlang.maybe.tags) {
- _conf_composite.conf.default_papersize = extractSDLangTabOrAttrib(header_sdlang, "default", "papersize");
- _conf_composite.conf.default_text_wrap = extractSDLangTabOrAttrib(header_sdlang, "default", "text_wrap");
- _conf_composite.conf.default_emphasis = extractSDLangTabOrAttrib(header_sdlang, "default", "emphasis");
- _conf_composite.conf.default_language = extractSDLangTabOrAttrib(header_sdlang, "default", "language");
- _conf_composite.conf.default_digest = extractSDLangTabOrAttrib(header_sdlang, "default", "digest");
- }
- if ("search" in header_sdlang.maybe.tags) {
- _conf_composite.conf.search_flag = extractSDLangTabOrAttrib(header_sdlang, "search", "flag");
- _conf_composite.conf.search_action = extractSDLangTabOrAttrib(header_sdlang, "search", "action");
- _conf_composite.conf.search_db = extractSDLangTabOrAttrib(header_sdlang, "search", "db");
- _conf_composite.conf.search_title = extractSDLangTabOrAttrib(header_sdlang, "search", "title");
- }
- /+ meta ------------------------------------------------------------------- +/
- if ("classify" in header_sdlang.maybe.tags) {
- _conf_composite.meta.classify_dewey = extractSDLangTabOrAttrib(header_sdlang, "classify", "dewey");
- _conf_composite.meta.classify_keywords = extractSDLangTabOrAttrib(header_sdlang, "classify", "keywords");
- _conf_composite.meta.classify_loc = extractSDLangTabOrAttrib(header_sdlang, "classify", "loc");
- _conf_composite.meta.classify_subject = extractSDLangTabOrAttrib(header_sdlang, "classify", "subject");
- _conf_composite.meta.classify_topic_register = extractSDLangTabOrAttrib(header_sdlang, "classify", "topic_register");
- }
- if ("date" in header_sdlang.maybe.tags) {
- _conf_composite.meta.date_added_to_site = extractSDLangTabOrAttrib(header_sdlang, "date", "added_to_site");
- _conf_composite.meta.date_available = extractSDLangTabOrAttrib(header_sdlang, "date", "available");
- _conf_composite.meta.date_created = extractSDLangTabOrAttrib(header_sdlang, "date", "created");
- _conf_composite.meta.date_issued = extractSDLangTabOrAttrib(header_sdlang, "date", "issued");
- _conf_composite.meta.date_modified = extractSDLangTabOrAttrib(header_sdlang, "date", "modified");
- _conf_composite.meta.date_published = extractSDLangTabOrAttrib(header_sdlang, "date", "published");
- _conf_composite.meta.date_valid = extractSDLangTabOrAttrib(header_sdlang, "date", "valid");
- }
- if ("identifier" in header_sdlang.maybe.tags) {
- _conf_composite.meta.identifier_isbn = extractSDLangTabOrAttrib(header_sdlang, "identifier", "isbn");
- _conf_composite.meta.identifier_oclc = extractSDLangTabOrAttrib(header_sdlang, "identifier", "oclc");
- _conf_composite.meta.identifier_pg = extractSDLangTabOrAttrib(header_sdlang, "identifier", "pg");
- }
- if ("links" in header_sdlang.maybe.tags) {
- // _conf_composite.meta.links = extractSDLangTabOrAttrib(header_sdlang, "links", "");
- }
- if ("notes" in header_sdlang.maybe.tags) {
- _conf_composite.meta.notes_abstract = extractSDLangTabOrAttrib(header_sdlang, "notes", "abstract");
- _conf_composite.meta.notes_description = extractSDLangTabOrAttrib(header_sdlang, "notes", "description");
- }
- if ("original" in header_sdlang.maybe.tags) {
- _conf_composite.meta.original_language = extractSDLangTabOrAttrib(header_sdlang, "original", "language");
- _conf_composite.meta.original_language_char = extractSDLangTabOrAttrib(header_sdlang, "original", "language_char");
- _conf_composite.meta.original_source = extractSDLangTabOrAttrib(header_sdlang, "original", "source");
- _conf_composite.meta.original_title = extractSDLangTabOrAttrib(header_sdlang, "original", "title");
- }
- if ("publisher" in header_sdlang.maybe.tags) {
- // _conf_composite.meta.publisher = extractSDLangTabOrAttrib(header_sdlang, "publisher", "");
- }
- if ("rights" in header_sdlang.maybe.tags) {
- _conf_composite.meta.rights_copyright = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright");
- _conf_composite.meta.rights_copyright_text = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_text");
- _conf_composite.meta.rights_copyright_audio = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_audio");
- _conf_composite.meta.rights_copyright_cover = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_cover");
- _conf_composite.meta.rights_copyright_illustrations = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_illustrations");
- _conf_composite.meta.rights_copyright_photographs = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_photographs");
- _conf_composite.meta.rights_copyright_translation = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_translation");
- _conf_composite.meta.rights_copyright_video = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright_video");
- _conf_composite.meta.rights_license = extractSDLangTabOrAttrib(header_sdlang, "rights", "license");
- }
- if (_conf_composite.meta.creator_author.empty) {
- if ("creator" in header_sdlang.maybe.tags) {
- _conf_composite.meta.creator_author = extractSDLangTabOrAttrib(header_sdlang, "creator", "author");
- _conf_composite.meta.creator_author_email = extractSDLangTabOrAttrib(header_sdlang, "creator", "author_email");
- _conf_composite.meta.creator_illustrator = extractSDLangTabOrAttrib(header_sdlang, "creator", "illustrator");
- _conf_composite.meta.creator_translator = extractSDLangTabOrAttrib(header_sdlang, "creator", "translator");
- }
- // dochead_meta["creator"]["author_raw"] = dochead_meta["creator"]["author"];
- string[] authors_arr;
- auto authors_raw_arr = _conf_composite.meta.creator_author.split(rgx.arr_delimiter);
- foreach (author_raw; authors_raw_arr) {
- authors_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1");
- }
- _conf_composite.meta.creator_author = join(authors_arr, ", ").chomp.chomp;
- }
- if (_conf_composite.meta.title_main.empty) {
- if ("title" in header_sdlang.maybe.tags) {
- _conf_composite.meta.title_edition = extractSDLangTabOrAttrib(header_sdlang, "title", "edition");
- // _conf_composite.meta.title_full = extractSDLangTabOrAttrib(header_sdlang, "title", "full");
- _conf_composite.meta.title_language = extractSDLangTabOrAttrib(header_sdlang, "title", "language");
- _conf_composite.meta.title_main = extractSDLangTabOrAttrib(header_sdlang, "title", "main");
- _conf_composite.meta.title_note = extractSDLangTabOrAttrib(header_sdlang, "title", "note");
- _conf_composite.meta.title_sub = extractSDLangTabOrAttrib(header_sdlang, "title", "sub");
- _conf_composite.meta.title_subtitle = extractSDLangTabOrAttrib(header_sdlang, "title", "subtitle");
- }
- if (_conf_composite.meta.title_main.empty) {
- Tag _maintag = header_sdlang.getTag("title");
- if (_maintag !is null) {
- if ("main" in _maintag.maybe.tags) {
- _conf_composite.meta.title_main
- = to!string(_maintag.getTagValues("main"));
- } else if ("main" !in _maintag.maybe.attributes) {
- _conf_composite.meta.title_main
- = (_maintag.values[0]).to!string; // test that this exists
- }
- }
- }
- if ((!(_conf_composite.meta.title_subtitle.empty))
- && (_conf_composite.meta.title_sub.empty)) {
- _conf_composite.meta.title_sub = _conf_composite.meta.title_subtitle;
- }
- _conf_composite.meta.title_full = (_conf_composite.meta.title_sub.empty)
- ? _conf_composite.meta.title_main
- : format(
- "%s - %s",
- _conf_composite.meta.title_main,
- _conf_composite.meta.title_sub,
- );
- }
- return _conf_composite;
- }
- }
-}
-static template parseSDLangConfig() {
- import
- std.exception,
- std.regex,
- std.stdio,
- std.string,
- std.traits,
- std.typecons,
- std.utf,
- std.conv : to;
- import sdlang;
- auto parseSDLangConfig(string configuration, string conf_sdl_filename) {
- Tag sdl_root_conf;
- try {
- sdl_root_conf = parseSource(configuration);
- }
- catch(ParseException e) {
- stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
- stderr.writeln(e.msg);
- }
- return sdl_root_conf;
- }
-}
-/++
- return composite make from config files
-+/
-
-template confFilesSDLtoStruct() {
- import
- std.exception,
- std.regex,
- std.stdio,
- std.string,
- std.traits,
- std.typecons,
- std.utf,
- std.conv : to;
- import
- sdp.meta.conf_make_meta_structs,
- sdp.meta.rgx;
- auto configParseSDL(T)(
- T _text
- ){
- Tag sdl_root;
- try {
- sdl_root = parseSource(_text.to!string);
- }
- catch(ParseException e) {
- stderr.writeln("SDLang problem with this document header:");
- stderr.writeln(_src_header);
- // Error messages of the form:
- // myFile.sdl(5:28): Error: Invalid integer suffix.
- stderr.writeln(e.msg);
- }
- debug(sdlang) {
- writeln("header SDL:");
- writeln(__LINE__, ": ", sdl_root.toSDLDocument());
- writeln(__LINE__, ": ", sdl_root.maybe.namespaces);
- writeln("header make sdlang: ", sdl_root.toSDLDocument());
- writeln(__LINE__, ": ", sdl_root.getTagValues("title"));
- writeln(__LINE__, ": ", sdl_root.getTagValues("creator"));
- Tag creator = sdl_root.getTag("creator");
- if (creator !is null) {
- if ("author" in creator.maybe.tags) {
- writeln(__LINE__, ": ", creator.getTagValues("author"));
- } else if ("author" in creator.maybe.attributes) {
- writeln(__LINE__, ": ", creator.maybe.attributes["author"][0].value);
- }
- }
- }
- return sdl_root; // sdlang.ast.Tag
- }
- auto confFilesSDLtoStruct(S,L)(
- S sdl_root_config_share,
- L sdl_root_config_local,
- ){
- mixin SiSUmakeMetaStructsSDLang;
- ConfCompositePlus _conf_composite;
- foreach (conf_sdlang; [sdl_root_config_share, sdl_root_config_local]) {
- if ("make" in conf_sdlang.maybe.tags) {
- confCompositeMakeBuild _mk;
- _conf_composite.make_str.bold = extractSDLangTabOrAttrib(conf_sdlang, "make", "bold"); // TODO
- _conf_composite.make_str.breaks = extractSDLangTabOrAttrib(conf_sdlang, "make", "breaks");
- _conf_composite.make_str.cover_image = extractSDLangTabOrAttrib(conf_sdlang, "make", "cover_image");
- _conf_composite.make_str.css = extractSDLangTabOrAttrib(conf_sdlang, "make", "css");
- _conf_composite.make_str.emphasis = extractSDLangTabOrAttrib(conf_sdlang, "make", "emphasis"); // TODO
- _conf_composite.make_str.footer = extractSDLangTabOrAttrib(conf_sdlang, "make", "footer");
- _conf_composite.make_str.headings = extractSDLangTabOrAttrib(conf_sdlang, "make", "headings");
- _conf_composite.make_str.home_button_image = extractSDLangTabOrAttrib(conf_sdlang, "make", "home_button_image");
- _conf_composite.make_str.home_button_text = extractSDLangTabOrAttrib(conf_sdlang, "make", "home_button_text");
- _conf_composite.make_str.italics = extractSDLangTabOrAttrib(conf_sdlang, "make", "italics"); // TODO
- _conf_composite.make_str.num_top = extractSDLangTabOrAttrib(conf_sdlang, "make", "num_top");
- _conf_composite.make_str.num_depth = extractSDLangTabOrAttrib(conf_sdlang, "make", "num_depth");
- _conf_composite.make_str.substitute = extractSDLangTabOrAttrib(conf_sdlang, "make", "substitute"); // TODO
- _conf_composite.make_str.texpdf_font = extractSDLangTabOrAttrib(conf_sdlang, "make", "texpdf_font");
- _conf_composite.make.bold_rgxmatch = _mk.bold_rgxmatch(_conf_composite.make_str.bold); //
- _conf_composite.make.breaks = _mk.breaks(_conf_composite.make_str.breaks);
- _conf_composite.make.cover_image = _mk.cover_image(_conf_composite.make_str.cover_image);
- _conf_composite.make.css = _mk.css(_conf_composite.make_str.css);
- _conf_composite.make.emphasis_rgxmatch = _mk.emphasis_rgxmatch(_conf_composite.make_str.emphasis);
- _conf_composite.make.footer = _mk.footer(_conf_composite.make_str.footer);
- _conf_composite.make.headings = _mk.headings(_conf_composite.make_str.headings);
- _conf_composite.make.home_button_image = _mk.home_button_image(_conf_composite.make_str.home_button_image);
- _conf_composite.make.home_button_text = _mk.home_button_text(_conf_composite.make_str.home_button_text);
- _conf_composite.make.italics_rgxmatch = _mk.italics_rgxmatch(_conf_composite.make_str.italics);
- _conf_composite.make.num_top = _mk.num_top(_conf_composite.make_str.num_top);
- _conf_composite.make.num_depth = _mk.num_depth(_conf_composite.make_str.num_depth);
- _conf_composite.make.substitute = _mk.substitute(_conf_composite.make_str.substitute); // TODO
- _conf_composite.make.texpdf_font = _mk.texpdf_font(_conf_composite.make_str.texpdf_font);
- }
- }
- return _conf_composite;
- }
-}
-/++
- default settings
-+/
-template SiSUmakeMetaStructsSDLang() {
- import
- std.algorithm,
- std.array,
- std.container,
- std.exception,
- std.file,
- std.getopt,
- std.json,
- std.path,
- std.process,
- std.range,
- std.regex,
- std.stdio,
- std.string,
- std.traits,
- std.typecons,
- std.uni,
- std.utf,
- std.conv : to;
- import sdp.meta.conf_make_meta_structs;
- string extractSDLangTabOrAttrib(S)(
- S conf_sdlang,
- string maintab,
- string atab
- ) {
- string _conf_composite_string = "";
- if (maintab in conf_sdlang.maybe.tags) {
- auto _maintag = conf_sdlang.getTag(maintab);
- if (
- (atab in _maintag.maybe.tags)
- && (_maintag.getTagValues(atab).length > 0)
- ) {
- debug(configsdlang) {
- writeln(
- " ", __LINE__,
- ": sdl tag, ",
- maintab, ":", atab, ": ",
- _maintag.getTagValues(atab)[0]
- );
- }
- if (_maintag.getTagValues(atab).length == 1) {
- writeln((_maintag.getTagValues(atab)[0]).to!string);
- _conf_composite_string
- = (_maintag.getTagValues(atab)[0]).to!string;
- } else if (_maintag.getTagValues(atab).length > 1) {
- string _tmp = "";
- foreach (st; _maintag.getTagValues(atab)) {
- writeln(st.to!string, ";");
- _tmp ~= st.to!string ~ ";";
- }
- _conf_composite_string = _tmp;
- }
- } else if (
- (atab in _maintag.maybe.attributes)
- && (_maintag.attributes[atab][0].value.length > 0)
- ) {
- debug(configsdlang) {
- writeln(
- " ", __LINE__,
- ": sdl attrib, ",
- maintab, ":", atab, ": ",
- _maintag.attributes[atab][0].value
- );
- }
- _conf_composite_string
- = (_maintag.attributes[atab][0].value).to!string;
- }
- }
- return _conf_composite_string;
- }
-}
diff --git a/src/sdp/meta/doc_debugs.d b/src/sdp/meta/doc_debugs.d
index 89ca3a7..66b5f0e 100644
--- a/src/sdp/meta/doc_debugs.d
+++ b/src/sdp/meta/doc_debugs.d
@@ -23,8 +23,8 @@ template SiSUdebugs() {
std.utf,
std.conv : to;
auto SiSUdebugs(S,T)(
- auto return ref const S contents,
- auto return ref T doc_matters,
+ const S contents,
+ T doc_matters,
) {
mixin SiSUrgxInit;
mixin InternalMarkup;
@@ -595,8 +595,8 @@ template SiSUdebugs() {
}
debug(checkdoc) {
void out_segnames(S,T)(
- auto return ref const S contents,
- auto return ref T doc_matters,
+ const S contents,
+ T doc_matters,
) {
foreach (key; doc_matters.xml.keys_seq.seg) {
if (contents[key].length > 1) {
@@ -611,7 +611,7 @@ template SiSUdebugs() {
}
debug(checkdoc) {
void out_toc(S)(
- auto return ref const S contents,
+ const S contents,
string key,
) {
if (contents[key].length > 1) {
@@ -629,7 +629,7 @@ template SiSUdebugs() {
}
debug(checkdoc) {
void out_endnotes(S)(
- auto return ref const S contents,
+ const S contents,
string key,
) {
if (contents[key].length > 1) {
@@ -645,7 +645,7 @@ template SiSUdebugs() {
}
debug(checkdoc) {
void out_bookindex(S)(
- auto return ref const S contents,
+ const S contents,
string key,
) {
if (contents[key].length > 1) {
diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d
index 8160010..29af49c 100644
--- a/src/sdp/meta/metadoc.d
+++ b/src/sdp/meta/metadoc.d
@@ -14,11 +14,11 @@ template SiSUabstraction() {
sdp.meta.conf_make_meta_json,
sdp.meta.defaults,
sdp.meta.doc_debugs,
- sdp.meta.read_config_files,
- sdp.meta.read_source_files,
sdp.meta.rgx,
- sdp.output.hub,
- sdp.output.paths_source;
+ sdp.source.paths_source,
+ sdp.source.read_config_files,
+ sdp.source.read_source_files,
+ sdp.output.hub;
mixin SiSUrgxInit;
mixin contentJSONtoSiSUstruct;
mixin SiSUbiblio;
diff --git a/src/sdp/meta/read_config_files.d b/src/sdp/meta/read_config_files.d
deleted file mode 100644
index 22d285f..0000000
--- a/src/sdp/meta/read_config_files.d
+++ /dev/null
@@ -1,226 +0,0 @@
-/++
- read configuration files<BR>
- - read config files<BR>
- meta_config_files.d
-+/
-module sdp.meta.read_config_files;
-static template configReadInSiteTOML() {
- import
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- final string configReadInSiteTOML(M,E)(M manifest, E env) {
- auto conf_file_details = ConfigFilePaths!()(manifest, env);
- string conf_toml = conf_file_details.config_filename_site_toml;
- auto 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 = asNormalizedPath(chainPath(pth.to!string, conf_toml)).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 configReadInDocTOML() {
- import
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- final string configReadInDocTOML(M,E)(M manifest, E env) {
- auto conf_file_details = ConfigFilePaths!()(manifest, env);
- string conf_toml = conf_file_details.config_filename_document_toml;
- auto possible_config_path_locations = conf_file_details.possible_config_path_locations.sisu_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 = asNormalizedPath(chainPath(pth.to!string, conf_toml)).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
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- auto 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
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- final auto readConfigSite(M,E)(M _manifest, E _env) {
- string config_file_str;
- string conf_filename = "NONE";
- auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
- auto 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(pth; possible_config_path_locations) {
- auto conf_file = asNormalizedPath(chainPath(pth.to!string, conf_fn)).array;
- conf_filename = conf_fn;
- if (config_file_str.length > 0) {
- // conf_filename = conf_fn;
- break;
- }
- try {
- if (exists(conf_file)) {
- debug(io) {
- writeln("WARNING (io debug) in config file found: ", conf_file);
- // writeln(__LINE__, ": found: ", conf_file, " in ", pth);
- }
- config_file_str = conf_file.readText;
- break;
- }
- } catch (ErrnoException ex) {
- } catch (FileException ex) {
- }
- }
- if (config_file_str.length > 0) { break; }
- }
- struct _ConfContent {
- string filename() {
- return conf_filename;
- }
- string filetype() {
- return conf_filename.extension.chompPrefix(".");
- }
- auto content() {
- return config_file_str;
- }
- }
- return _ConfContent();
- }
-}
-static template readConfigDoc() {
- import
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- final auto readConfigDoc(M,E)(M _manifest, E _env) {
- string config_file_str;
- string conf_filename = "NONE";
- auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
- auto possible_config_path_locations = _conf_file_details.possible_config_path_locations.sisu_document_make;
- foreach(conf_fn; [_conf_file_details.config_filename_document_toml]) {
- foreach(pth; possible_config_path_locations) {
- auto conf_file = asNormalizedPath(chainPath(pth.to!string, conf_fn)).array;
- conf_filename = conf_fn;
- if (config_file_str.length > 0) {
- // conf_filename = conf_fn;
- 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) {
- }
- }
- if (config_file_str.length > 0) { break; }
- }
- struct _ConfContent {
- string filename() {
- return conf_filename;
- }
- string filetype() {
- return conf_filename.extension.chompPrefix(".");
- }
- auto content() {
- return config_file_str;
- }
- }
- return _ConfContent();
- }
-}
-static template configReadSiteTOML() {
- import
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- import toml;
- final auto configReadSiteTOML(M,E)(M _manifest, E _env) {
- auto _configuration = configReadInSiteTOML!()(_manifest, _env);
- auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
- string _conf_toml = _conf_file_details.config_filename_site_toml;
- auto _toml_conf = configTOML!()(_configuration, _conf_toml);
- return _toml_conf;
- }
-}
-static template configReadDocTOML() {
- import
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- import toml;
- final auto configReadDocTOML(M,E)(M _manifest, E _env) {
- auto _configuration = configReadInDocTOML!()(_manifest, _env);
- auto _conf_file_details = ConfigFilePaths!()(_manifest, _env);
- string _conf_toml = _conf_file_details.config_filename_document_toml;
- auto _toml_conf = configTOML!()(_configuration, _conf_toml);
- return _toml_conf;
- }
-}
diff --git a/src/sdp/meta/read_source_files.d b/src/sdp/meta/read_source_files.d
deleted file mode 100644
index 135d8e8..0000000
--- a/src/sdp/meta/read_source_files.d
+++ /dev/null
@@ -1,354 +0,0 @@
-/++
- module meta_read_source_files;<BR>
- - open markup files<BR>
- - if master file scan for addional files to import/insert
-+/
-module sdp.meta.read_source_files;
-static template SiSUrawMarkupContent() {
- import
- sdp.meta.rgx;
- import
- sdp.meta,
- sdp.output.paths_source,
- std.file,
- std.path;
- mixin SiSUrgxInit;
- static auto rgx = Rgx();
- string[] _images=[];
- auto _extract_images(S)(S content_block) {
- string[] images_;
- auto _content_block = content_block.to!string;
- if (auto m = _content_block.matchAll(rgx.image)) {
- images_ ~= m.captures[1].to!string;
- }
- return images_;
- }
- auto rawsrc = RawMarkupContent();
- auto SiSUrawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) {
- auto _0_header_1_body_content_2_insert_filelist_tuple
- = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src);
- return _0_header_1_body_content_2_insert_filelist_tuple;
- }
- struct RawMarkupContent {
- final sourceContent(in string fn_src) {
- auto raw = MarkupRawUnit();
- auto source_txt_str
- = raw.markupSourceReadIn(fn_src);
- return source_txt_str;
- }
- final auto sourceContentSplitIntoHeaderAndBody(O)(O _opt_action, in string source_txt_str, in string fn_src="") {
- auto raw = MarkupRawUnit();
- string[] insert_file_list;
- string[] images_list;
- auto t
- = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str);
- auto header_raw = t[0];
- auto sourcefile_body_content = t[1];
- if (fn_src.match(rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise
- auto ins = Inserts();
- auto tu
- = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- static assert(!isTypeTuple!(tu));
- sourcefile_body_content = tu[0];
- insert_file_list = tu[1].dup;
- images_list = tu[2].dup;
- } else if (_opt_action.source || _opt_action.sisupod) {
- auto ins = Inserts();
- auto tu
- = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src);
- static assert(!isTypeTuple!(tu));
- images_list = tu[2].dup;
- }
- t = tuple(
- header_raw,
- sourcefile_body_content,
- insert_file_list,
- images_list
- );
- static assert(t.length==4);
- return t;
- }
- }
- struct MarkupRawUnit {
- import std.file;
- final private string readInMarkupSource(in char[] fn_src) {
- enforce(
- exists(fn_src)!=0,
- "file not found: «" ~
- fn_src ~ "»"
- );
- string source_txt_str;
- try {
- if (exists(fn_src)) {
- debug(io) {
- writeln("in src, markup source file found: ", fn_src);
- }
- source_txt_str = fn_src.readText;
- }
- }
- catch (ErrnoException ex) {
- }
- catch (UTFException ex) {
- // Handle validation errors
- }
- catch (FileException ex) {
- // Handle errors
- }
- std.utf.validate(source_txt_str);
- return source_txt_str;
- }
- final private char[][] header0Content1(in string src_text) {
- /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/
- char[][] header_and_content;
- auto m = (cast(char[]) src_text).matchFirst(rgx.heading_a);
- header_and_content ~= m.pre;
- header_and_content ~= m.hit ~ m.post;
- assert(header_and_content.length == 2,
- "document markup is broken, header body split == "
- ~ header_and_content.length.to!string
- ~ "; (header / body array split should == 2 (split is on level A~))"
- );
- return header_and_content;
- }
- final private char[][] markupSourceLineArray(in char[] src_text) {
- char[][] source_line_arr
- = (cast(char[]) src_text).split(rgx.newline_eol_strip_preceding);
- return source_line_arr;
- }
- auto markupSourceReadIn(in string fn_src) {
- static auto rgx = Rgx();
- enforce(
- fn_src.match(rgx.src_pth_sst_or_ssm),
- "not a sisu markup filename: «" ~
- fn_src ~ "»"
- );
- auto source_txt_str = readInMarkupSource(fn_src);
- return source_txt_str;
- }
- 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[] source_txt = hc[1];
- auto source_line_arr = markupSourceLineArray(source_txt);
- auto t = tuple(
- header,
- source_line_arr,
- file_insert_list,
- images_list
- );
- return t;
- }
- final char[][] getInsertMarkupSourceContentRawLineArray(
- in char[] fn_src_insert,
- Regex!(char) rgx_file
- ) {
- enforce(
- fn_src_insert.match(rgx_file),
- "not a sisu markup filename: «" ~
- fn_src_insert ~ "»"
- );
- auto source_txt_str = readInMarkupSource(fn_src_insert);
- auto source_line_arr = markupSourceLineArray(source_txt_str);
- return source_line_arr;
- }
- }
- struct Inserts {
- auto scan_subdoc_source(O)(
- O _opt_action,
- char[][] markup_sourcefile_insert_content,
- string fn_src
- ) {
- mixin SiSUrgxInitFlags;
- char[][] contents_insert;
- auto type1 = flags_type_init;
- auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm);
- auto markup_src_file_path = fn_pth_full.captures[1];
- foreach (line; markup_sourcefile_insert_content) {
- if (type1["curly_code"] == 1) {
- type1["header_make"] = 0;
- type1["header_meta"] = 0;
- if (line.matchFirst(rgx.block_curly_code_close)) {
- type1["curly_code"] = 0;
- }
- contents_insert ~= line;
- } else if (line.matchFirst(rgx.block_curly_code_open)) {
- type1["curly_code"] = 1;
- type1["header_make"] = 0;
- type1["header_meta"] = 0;
- contents_insert ~= line;
- } else if (type1["tic_code"] == 1) {
- type1["header_make"] = 0;
- type1["header_meta"] = 0;
- if (line.matchFirst(rgx.block_tic_close)) {
- type1["tic_code"] = 0;
- }
- contents_insert ~= line;
- } else if (line.matchFirst(rgx.block_tic_code_open)) {
- type1["tic_code"] = 1;
- type1["header_make"] = 0;
- type1["header_meta"] = 0;
- contents_insert ~= line;
- } else if (
- (type1["header_make"] == 1)
- && line.matchFirst(rgx.native_header_sub)
- ) {
- type1["header_make"] = 1;
- type1["header_meta"] = 0;
- } else if (
- (type1["header_meta"] == 1)
- && line.matchFirst(rgx.native_header_sub)
- ) {
- type1["header_meta"] = 1;
- type1["header_make"] = 0;
- } else if (auto m = line.match(rgx.insert_src_fn_ssi_or_sst)) {
- type1["header_make"] = 0;
- type1["header_meta"] = 0;
- auto insert_fn = m.captures[2];
- auto insert_sub_pth = m.captures[1];
- auto fn_src_insert
- = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array;
- auto raw = MarkupRawUnit();
- auto markup_sourcesubfile_insert_content
- = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts);
- debug(insert_file) {
- tell_l("red", line);
- tell_l("red", fn_src_insert);
- tell_l("fuchsia", "ERROR");
- writeln(
- " length contents insert array: ",
- markup_sourcesubfile_insert_content.length
- );
- }
- if (_opt_action.source || _opt_action.sisupod) {
- _images ~= _extract_images(markup_sourcesubfile_insert_content);
- }
- auto ins = Inserts();
- /+
- - 1. load file
- - 2. read lines
- - 3. scan lines
- - a. if filename insert, and insert filename
- - repeat 1
- - b. else
- - add line to new array;
- - build image list, search for any image files to add to image list
- +/
- } else {
- type1["header_make"] = 0;
- type1["header_meta"] = 0;
- contents_insert ~= line; // images to extract for image list?
- if (_opt_action.source || _opt_action.sisupod) {
- auto _image_linelist = _extract_images(line);
- if (_image_linelist.length > 0) {
- _images ~= _image_linelist;
- }
- }
- }
- } // end src subdoc (inserts) loop
- auto t = tuple(
- contents_insert,
- _images
- );
- return t;
- }
- auto scan_master_src_for_insert_files_and_import_content(O)(
- O _opt_action,
- char[][] sourcefile_body_content,
- string fn_src
- ) {
- import std.algorithm;
- mixin SiSUrgxInitFlags;
- char[][] contents;
- auto type = flags_type_init;
- auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm);
- auto markup_src_file_path = fn_pth_full.captures[1];
- char[][] contents_insert;
- string[] _images =[];
- string[] insert_file_list =[];
- foreach (line; sourcefile_body_content) {
- if (type["curly_code"] == 1) {
- if (line.matchFirst(rgx.block_curly_code_close)) {
- type["curly_code"] = 0;
- }
- contents ~= line;
- } else if (line.matchFirst(rgx.block_curly_code_open)) {
- type["curly_code"] = 1;
- contents ~= line;
- } else if (type["tic_code"] == 1) {
- if (line.matchFirst(rgx.block_tic_close)) {
- type["tic_code"] = 0;
- }
- contents ~= line;
- } else if (line.matchFirst(rgx.block_tic_code_open)) {
- type["tic_code"] = 1;
- contents ~= line;
- } else if (auto m = line.match(rgx.insert_src_fn_ssi_or_sst)) {
- auto insert_fn = m.captures[2];
- auto insert_sub_pth = m.captures[1];
- auto fn_src_insert
- = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array;
- insert_file_list ~= fn_src_insert.to!string;
- auto raw = MarkupRawUnit();
- /+ TODO +/
- auto markup_sourcefile_insert_content
- = raw.getInsertMarkupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts);
- debug(insert_file) {
- tell_l("red", line);
- tell_l("red", fn_src_insert);
- writeln(
- " length contents insert array: ",
- markup_sourcefile_insert_content.length
- );
- }
- auto ins = Inserts();
- auto contents_insert_tu = ins.scan_subdoc_source(
- _opt_action,
- markup_sourcefile_insert_content,
- fn_src_insert.to!string
- );
- contents ~= contents_insert_tu[0]; // images to extract for image list?
- if (_opt_action.source || _opt_action.sisupod) {
- auto _image_linelist = _extract_images(contents_insert_tu[0]);
- if (_image_linelist.length > 0) {
- _images ~= _image_linelist;
- }
- }
- /+
- - 1. load file
- - 2. read lines
- - 3. scan lines
- - a. if filename insert, and insert filename
- - repeat 1
- - b. else
- - add line to new array;
- - build image list, search for any image files to add to image list
- +/
- } else {
- contents ~= line;
- if (_opt_action.source || _opt_action.sisupod) {
- auto _image_linelist = _extract_images(line);
- if (_image_linelist.length > 0) {
- _images ~= _image_linelist;
- }
- }
- }
- } // end src doc loop
- string[] images = [];
- foreach(i; uniq(_images.sort())) {
- images ~= i;
- }
- debug(insert_file) {
- writeln(__LINE__);
- writeln(contents.length);
- }
- auto t = tuple(
- contents,
- insert_file_list,
- images
- );
- return t;
- }
- }
-}