diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-11 11:37:35 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-12 12:14:39 -0400 |
| commit | c9089281e09f82db58f5538a84385717cd5897a5 (patch) | |
| tree | ce7fdc4b6f46d447748a917ec098705d1d2bac66 /src | |
| parent | ocda: reading .ocda.db now faster than parsing markup (diff) | |
ocda: what a document has, as plain data
ST_DocHas in metadoc_object_setter, filled by the parser, in place of
DocHas_, a struct of accessors nested inside docAbstraction() that
closed over the parser's locals. The member names are the ones the
output writers already use, so nothing downstream changes.
The point is that a struct closing over parser locals can only ever be
built by the parser. A document loaded from a .ssp or a .ocda.db has to
arrive at the same value with only what the artefact carries, and now
there is something for it to fill.
Two small things fall out. imagelist is a string[] rather than the lazy
uniq range it was, and images() is therefore imagelist.length rather
than counting the commas in the range's string representation, which
carried a "TODO not ideal rethink". Same answer unless a filename
contains a comma; the reference test agrees on all 35.
(assisted by Claude-Code)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src.d | 74 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_object_setter.d | 47 |
2 files changed, 63 insertions, 58 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d index 229bff1..c5e2ce8 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src.d @@ -1552,65 +1552,35 @@ template docAbstraction() { lev_anchor_tag = ""; anchor_tag = ""; // identify parts - 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; - } - } - DocHas_ doc_has() { - return DocHas_(); - } + /+ ↓ what the document has, as plain data. ST_DocHas is in + metadoc_object_setter so that it can also be built from a loaded + abstraction, without the parser's locals to hand + +/ + ST_DocHas doc_has_ = { + inline_links : dochas["inline_links"], + inline_notes_reg : dochas["inline_notes"], + inline_notes_star : dochas["inline_notes_star"], + codeblocks : dochas["codeblock"], + tables : dochas["table"], + blocks : dochas["block"], + groups : dochas["group"], + poems : dochas["poem"], + quotes : dochas["quote"], + imagelist : image_list.array, + section_keys_sequenced : document_section_keys_sequenced, + segnames_lv4 : segnames_4, + segnames_lv_0_to_4 : segnames_0_to_4, + tag_associations : tag_assoc, + }; // the doc to be returned struct ST_docAbstraction { ObjGenericComposite[][string] document_the; - DocHas_ doc_has; + ST_DocHas doc_has; } ST_docAbstraction ret; { ret.document_the = document_the; - ret.doc_has = doc_has; + ret.doc_has = doc_has_; } return ret; } // ← closed: abstract doc source diff --git a/src/sisudoc/ocda/meta/metadoc_object_setter.d b/src/sisudoc/ocda/meta/metadoc_object_setter.d index ba2f268..2eab062 100644 --- a/src/sisudoc/ocda/meta/metadoc_object_setter.d +++ b/src/sisudoc/ocda/meta/metadoc_object_setter.d @@ -56,19 +56,54 @@ module sisudoc.ocda.meta.metadoc_object_setter; @safe: template ObjectSetter() { /+ structs +/ - struct DocObj_TxtAttrib_ { - int indent_base = 0; - int indent_hang = 0; - bool bullet = false; - string language = ""; + /+ ↓ what a document has: the counts, the lists and the indexes that the + output writers ask doc_matters.has for. + . + plain data, so that it can be built by the parser, which has the whole + markup in front of it, or from a loaded abstraction, which has only + what the artefact carries. The member names are the ones the writers + already use, so which of the two built it is not visible downstream. + . + docSectKeysSeq() turns section_keys_sequenced into the per format + accessors (.scroll, .seg, .sql, .latex, .text) the writers walk. + +/ + struct ST_DocHas { + uint inline_links; + uint inline_notes_reg; + uint inline_notes_star; + uint codeblocks; + uint tables; + uint blocks; + uint groups; + uint poems; + uint quotes; + string[] imagelist; + string[][string] section_keys_sequenced; + string[] segnames_lv4; + string[] segnames_lv_0_to_4; + string[string][string] tag_associations; + ulong images() { + return imagelist.length; + } + auto keys_seq() { + import sisudoc.ocda.meta.metadoc_from_src_functions : docSectKeysSeq; + mixin docSectKeysSeq; + return docSectKeysSeq(section_keys_sequenced); + } } - struct DocObj_Has_ { + struct DocObj_Has_ { // review bool inline_links = false; bool inline_notes_reg = false; bool inline_notes_star = false; bool images = false; bool image_without_dimensions = false; } + struct DocObj_TxtAttrib_ { + int indent_base = 0; + int indent_hang = 0; + bool bullet = false; + string language = ""; + } struct DocObj_Table_ { int number_of_columns = 0; double[] column_widths = []; |
