diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-21 16:12:56 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-23 08:22:15 -0400 |
| commit | 8b81e9a11c7af642c4d0d8584a9cb348cc887d6e (patch) | |
| tree | 8ba9c356ff71bf18f5623c22d30a8b2513321cfe /src/sisudoc/spine.d | |
| parent | uid and paths separator "~" in place of ":" (diff) | |
ocda: warn if heading claims reserved segment name
spine automatically builds some segments, including: (toc, endnotes,
glossary, bibliography, bookindex, blurb, _the_title) these are now
identified as reserved names and a user is now warned if any of these
names have been manually assigned to a heading by markup. A document
still builds but to disambiguate the ocn of the heading is attached to
the markup (reserved) name and this is seeded before a document not
after. It is read off the finished abstraction rather than reported by
the parser, and beside the ocn alignment check for the same reason: it
is a statement about a document rather than a step in building one.
WARNING reserved segment name: the_autonomous_contract... [en]
heading 1 at ocn 135 asks for "endnotes", which spine gives its
own generated section
it is named "endnotes-135" instead; ...
A warning: the document is correct and complete and the name it ends
up with works.
--strict makes it a failure for the run, as it does for ocn alignment,
and by the same reasoning: the outputs are written and can be looked at,
and the exit status is taken at the end.
Two of the thirty-six sample documents have reserved segment names,
"1~endnotes" heading. Output is unchanged: nothing here touches the
abstraction.
(assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/spine.d')
| -rw-r--r-- | src/sisudoc/spine.d | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d index 18beda2..c1a3f63 100644 --- a/src/sisudoc/spine.d +++ b/src/sisudoc/spine.d @@ -72,6 +72,7 @@ import sisudoc.ocda.meta.conf_make_meta_json; import sisudoc.ocda.meta.defaults; import sisudoc.ocda.meta.doc_debugs; import sisudoc.ocda.meta.ocn_align; +import sisudoc.ocda.meta.reserved_names; import sisudoc.ocda.meta.rgx; import sisudoc.ocda.meta.rgx_yaml; import sisudoc.ocda.meta.rgx_files; @@ -438,8 +439,11 @@ Verifying: check is otherwise automatic and runs before anything is written. - --strict document checks that warn become failures, ocn - alignment between languages among them. + --strict document checks that warn become failures: ocn + alignment between languages, and a heading that + claims a segment name spine keeps for a section of + its own (toc, endnotes, glossary, bibliography, + bookindex, blurb). ┃"); /+ ↓ --help is a question answered on stdout, not a run: the scope(success) banner would be the last line of the answer @@ -1681,6 +1685,12 @@ Verifying: +/ mixin spineOcnAlign _ocna; _ocna.ST_OcnProfile[] _ocn_profiles; + /+ ↓ headings that claimed a name spine keeps for a generated section. + Reported as each document goes by, where the document can be named, and + remembered here only so that --strict has something to fail on. + +/ + mixin spineReservedNames _rsvd; + bool _reserved_name_used = false; /+ ↓ what verify found, gathered as the documents go by +/ size_t _verify_checked = 0; size_t _verify_failed = 0; @@ -1854,6 +1864,23 @@ Verifying: } synchronized { _ocn_profiles ~= _ocn_p; } } + /+ ↓ a heading of this document that asked for a name spine uses for a section + of its own. Said here, where the document can be named, and per language: + the markup is per language and so is the answer. + +/ + { + auto _rsvd_uses = _rsvd.reservedNameHeadings(doc); + if (_rsvd_uses.length > 0) { + foreach (_line; _rsvd.reservedNameReportLines( + doc.matters.src.doc_uid_out_no_lang, + doc.matters.src.language, + _rsvd_uses, + )) { + stderr.writeln(_line); + } + synchronized { _reserved_name_used = true; } + } + } if (doc.matters.opt.action.curate) { auto _hvst = spineMetaDocCurate!()(doc.matters, hvst); if ( @@ -2058,6 +2085,20 @@ Verifying: } _ocn_profiles ~= _ocn_p; } + /+ ↓ reserved segment names, as above +/ + { + auto _rsvd_uses = _rsvd.reservedNameHeadings(doc); + if (_rsvd_uses.length > 0) { + foreach (_line; _rsvd.reservedNameReportLines( + doc.matters.src.doc_uid_out_no_lang, + doc.matters.src.language, + _rsvd_uses, + )) { + stderr.writeln(_line); + } + _reserved_name_used = true; + } + } if (doc.matters.opt.action.curate) { auto _hvst = spineMetaDocCurate!()(doc.matters, hvst); if ( @@ -2288,6 +2329,19 @@ Verifying: import core.stdc.stdlib : exit; exit(1); } + /+ ↓ --strict and a heading that claimed a name spine keeps for itself. + The same shape as the check above: the warning has already named the + document and the heading, the output of the run is complete and can be + looked at, and this is the exit status. A publishable run should not + contain a heading called something other than what its author wrote. + +/ + if (_reserved_name_used && _opt_action.strict) { + stderr.writeln( + "~ run FAILED ~ --strict: a heading claims a reserved segment name" + ); + import core.stdc.stdlib : exit; + exit(1); + } /+ ↓ a verification that failed is a failed run, whatever else went well. --no-verify has already said its piece per document and does not reach here: it turns the failure into a warning and the output is produced |
