aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/meta/metadoc_from_src.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2019-05-08 18:45:02 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-08-19 14:42:40 -0400
commit6b46ba599b7f687a592e2e50fdd007ed31319243 (patch)
tree9ba93fc931804a14506bae682eadaaef413f0024 /src/doc_reform/meta/metadoc_from_src.d
parentbook index sort: Aa-Zz (replaces A-Za-z) (diff)
0.7.0 meta_abstruction, doc "has" struct replaces several tuples
Diffstat (limited to 'src/doc_reform/meta/metadoc_from_src.d')
-rw-r--r--src/doc_reform/meta/metadoc_from_src.d121
1 files changed, 96 insertions, 25 deletions
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index 3d6b441..6a10534 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -347,6 +347,18 @@ template DocReformDocAbstraction() {
"glossary" : 0,
"blurb" : 0,
];
+ uint[string] dochas = [
+ "inline_links" : 0,
+ "inline_notes" : 0,
+ "inline_notes_star" : 0,
+ "codeblock" : 0,
+ "table" : 0,
+ "block" : 0,
+ "group" : 0,
+ "poem" : 0,
+ "quote" : 0,
+ "images" : 0,
+ ];
auto obj_type_status = flags_type_init;
string[string] object_number_poem = [
"start" : "",
@@ -807,7 +819,7 @@ template DocReformDocAbstraction() {
processing.remove("verse");
object_number_poem["start"] = obj_cite_digits.object_number.to!string;
}
- line.flow_txt_block_start(obj_type_status, object_number_poem);
+ line.flow_txt_block_start(obj_type_status, dochas, object_number_poem);
continue;
} else if (!line.empty) { /+ line not empty +/
/+ non blocks (headings, paragraphs) & closed blocks +/
@@ -1753,7 +1765,7 @@ template DocReformDocAbstraction() {
}
return images_;
}
- string[] segnames_lv0_to_4;
+ string[] segnames_0_to_4;
auto _image_dimensions(O,M)(O obj, M manifest_matter) {
if (obj.has.image_without_dimensions) {
import std.math;
@@ -1819,7 +1831,7 @@ template DocReformDocAbstraction() {
writeln(obj.text);
}
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
}
if (obj.metainfo.heading_lev_markup == 0) {
/+ TODO second hit (of two) with same assertion failure, check, fix and reinstate
@@ -1851,7 +1863,7 @@ template DocReformDocAbstraction() {
foreach (ref obj; the_table_of_contents_section) {
if (obj.metainfo.is_a == "heading") {
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
if (obj.metainfo.heading_lev_markup == 4) {
obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1];
assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames],
@@ -1891,7 +1903,7 @@ template DocReformDocAbstraction() {
writeln(obj.text);
}
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
if (obj.metainfo.heading_lev_markup == 4) {
obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html];
obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
@@ -1920,7 +1932,7 @@ template DocReformDocAbstraction() {
obj = _links(obj);
}
}
- auto images=uniq(_images.sort());
+ auto image_list = (_images.sort()).uniq;
/+ optional only one 1~ level +/
if (the_endnotes_section.length > 1) {
dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup;
@@ -1936,7 +1948,7 @@ template DocReformDocAbstraction() {
obj.metainfo.ocn = obj_cite_digits.object_number;
obj.metainfo.identifier = obj_cite_digits.identifier;
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
if (obj.metainfo.heading_lev_markup == 4) {
obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
if (segnames["html"].length > obj.ptr.html_segnames + 1) {
@@ -1972,7 +1984,7 @@ template DocReformDocAbstraction() {
obj.metainfo.ocn = obj_cite_digits.object_number;
obj.metainfo.identifier = obj_cite_digits.identifier;
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
if (obj.metainfo.heading_lev_markup == 4) {
obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
if (segnames["html"].length > obj.ptr.html_segnames + 1) {
@@ -2012,7 +2024,7 @@ template DocReformDocAbstraction() {
obj.metainfo.ocn = obj_cite_digits.object_number;
obj.metainfo.identifier = obj_cite_digits.identifier;
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
if (obj.metainfo.heading_lev_markup == 4) {
obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
if (segnames["html"].length > obj.ptr.html_segnames + 1) {
@@ -2053,7 +2065,7 @@ template DocReformDocAbstraction() {
debug(dom) {
}
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
}
obj_cite_digits = ocn_emit(OCNstatus.on);
obj.metainfo.ocn = obj_cite_digits.object_number;
@@ -2104,7 +2116,7 @@ template DocReformDocAbstraction() {
obj.metainfo.ocn = obj_cite_digits.object_number;
obj.metainfo.identifier = obj_cite_digits.identifier;
if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
if (obj.metainfo.heading_lev_markup == 4) {
obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
if (segnames["html"].length > obj.ptr.html_segnames + 1) {
@@ -2306,11 +2318,10 @@ template DocReformDocAbstraction() {
document_section_keys_sequenced["scroll"] ~= "tail";
document_section_keys_sequenced["seg"] ~= "tail";
}
- auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced);
- auto segnames_lv4 = segnames["html"].dup;
+ auto segnames_4 = segnames["html"].dup;
auto segnames_lv1_to_4 = segnames["epub"].dup;
debug(segnames) {
- writeln("segnames_lv4: ", segnames_lv4);
+ writeln("segnames_lv4: ", segnames_4);
writeln("segnames_lv1_to_4: ", segnames_lv1_to_4);
}
destroy(the_document_head_section);
@@ -2335,13 +2346,59 @@ template DocReformDocAbstraction() {
dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
+ auto doc_has() {
+ struct DocHas_ {
+ uint inline_links() {
+ return dochas["inline_links"];
+ }
+ uint inline_notes_reg() {
+ return dochas["inline_notes"];
+ }
+ uint inline_notes_star() {
+ return dochas["inline_notes_star"];
+ }
+ uint codeblocks() {
+ return dochas["codeblock"];
+ }
+ uint tables() {
+ return dochas["table"];
+ }
+ uint blocks() {
+ return dochas["block"];
+ }
+ uint groups() {
+ return dochas["group"];
+ }
+ uint poems() {
+ return dochas["poem"];
+ }
+ uint quotes() {
+ return dochas["quote"];
+ }
+ ulong images() { // TODO not ideal rethink
+ return (image_list.to!string.strip("[","]").split(",").length);
+ }
+ auto imagelist() {
+ return image_list;
+ }
+ auto keys_seq() {
+ return docSectKeysSeq!()(document_section_keys_sequenced);
+ }
+ string[] segnames_lv4() {
+ return segnames_4;
+ }
+ string[] segnames_lv_0_to_4() {
+ return segnames_0_to_4;
+ }
+ string[string][string] tag_associations() {
+ return tag_assoc;
+ }
+ }
+ return DocHas_();
+ }
auto t = tuple(
document_the,
- sequenced_document_keys,
- segnames_lv4,
- segnames_lv0_to_4,
- tag_assoc,
- images,
+ doc_has,
);
return t;
/+ post loop markup document/text ↑ +/
@@ -2484,9 +2541,10 @@ template DocReformDocAbstraction() {
return line;
}
void flow_txt_block_start(L,T,N)(
- L line,
- return ref T obj_type_status,
- return ref N object_number_poem
+ L line,
+ return ref T obj_type_status,
+ return ref uint[string] dochas,
+ return ref N object_number_poem
) {
debug(asserts) {
static assert(is(typeof(line) == char[]));
@@ -2495,6 +2553,7 @@ template DocReformDocAbstraction() {
}
static auto rgx = Rgx();
if (auto m = line.matchFirst(rgx.block_curly_code_open)) {
+ dochas["codeblock"]++;
an_object["lang"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : "";
@@ -2508,6 +2567,7 @@ template DocReformDocAbstraction() {
obj_type_status["code"] = TriState.on;
obj_type_status["curly_code"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_curly_poem_open)) {
+ dochas["poem"]++;
an_object["syntax"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
@@ -2523,6 +2583,7 @@ template DocReformDocAbstraction() {
obj_type_status["poem"] = TriState.on;
obj_type_status["curly_poem"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_curly_group_open)) {
+ dochas["group"]++;
an_object["syntax"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
@@ -2536,6 +2597,7 @@ template DocReformDocAbstraction() {
obj_type_status["group"] = TriState.on;
obj_type_status["curly_group"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_curly_block_open)) {
+ dochas["block"]++;
an_object["syntax"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
@@ -2549,6 +2611,7 @@ template DocReformDocAbstraction() {
obj_type_status["block"] = TriState.on;
obj_type_status["curly_block"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_curly_quote_open)) {
+ dochas["quote"]++;
an_object["syntax"] = "";
an_object["attrib"] = m["attrib"].to!string;
an_object["lang"] = m["lang"].to!string;
@@ -2568,18 +2631,21 @@ template DocReformDocAbstraction() {
line
);
}
+ dochas["table"] ++;
an_object["table_head"] = m["attrib"].to!string;
an_object["block_type"] = "curly";
obj_type_status["blocks"] = TriState.on;
obj_type_status["table"] = TriState.on;
obj_type_status["curly_table"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { /+ table: special table block markup syntax! +/
+ dochas["table"]++;
an_object["table_head"] = m["attrib"].to!string;
an_object["block_type"] = "special";
obj_type_status["blocks"] = TriState.on;
obj_type_status["table"] = TriState.on;
obj_type_status["curly_table_special_markup"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_tic_code_open)) {
+ dochas["codeblock"]++;
an_object["lang"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : "";
@@ -2593,6 +2659,7 @@ template DocReformDocAbstraction() {
obj_type_status["code"] = TriState.on;
obj_type_status["tic_code"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_tic_poem_open)) {
+ dochas["poem"]++;
an_object["syntax"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
@@ -2608,6 +2675,7 @@ template DocReformDocAbstraction() {
obj_type_status["poem"] = TriState.on;
obj_type_status["tic_poem"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_tic_group_open)) {
+ dochas["group"]++;
an_object["syntax"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
@@ -2621,6 +2689,7 @@ template DocReformDocAbstraction() {
obj_type_status["group"] = TriState.on;
obj_type_status["tic_group"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_tic_block_open)) {
+ dochas["block"]++;
an_object["syntax"] = "";
an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : "";
an_object["lang"] = (m["lang"]) ? m["lang"].to!string : "";
@@ -2634,6 +2703,7 @@ template DocReformDocAbstraction() {
obj_type_status["block"] = TriState.on;
obj_type_status["tic_block"] = TriState.on;
} else if (auto m = line.matchFirst(rgx.block_tic_quote_open)) {
+ dochas["quote"]++;
an_object["syntax"] = "";
an_object["attrib"] = m["attrib"].to!string;
an_object["lang"] = m["lang"].to!string;
@@ -2653,6 +2723,7 @@ template DocReformDocAbstraction() {
line
);
}
+ dochas["table"] ++;
an_object["table_head"] = m["attrib"].to!string;
an_object["block_type"] = "tic";
obj_type_status["blocks"] = TriState.on;
@@ -6341,13 +6412,13 @@ template DocReformDocAbstraction() {
template docSectKeysSeq() {
auto docSectKeysSeq(string[][string] document_section_keys_sequenced) {
struct doc_sect_keys_seq {
- auto scroll() {
+ string[] scroll() {
return document_section_keys_sequenced["scroll"];
}
- auto seg() {
+ string[] seg() {
return document_section_keys_sequenced["seg"];
}
- auto sql() {
+ string[] sql() {
return document_section_keys_sequenced["sql"];
}
}