aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/spine.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-09-21 10:29:15 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-09-22 14:14:40 -0400
commitb65fb777715cd02e52286ea11422c6c5e828291c (patch)
treee23abedb96c766c729d4d985c50d496271688448 /src/sisudoc/spine.d
parentpod: carry tools/po4a, the translation working set (diff)
pod: generate the po4a configuration, --po4a-cfg
A document's po4a configuration is derived rather than kept. Spine already knows both halves without looking: the manifest says which languages, and the markup says which files, through the << lines the parser follows. Derived, it cannot disagree with the document, where a hand-kept file eventually does: a language added to the manifest and forgotten in the Makefile is a translation nobody updates. It prints, rather than writing. Spine does not write into a source tree, and the file belongs beside the catalogues in the pod it describes: spine --po4a-cfg <pod> > <pod>/tools/po4a/po4a.cfg Three things the Makefile it replaces knew, which had to be found by running po4a rather than by reading: --keep 0 is the difference between regenerating a document and destroying it. po4a will not write a translated file below a completeness threshold, and that threshold defaults to 80%. A partly translated document is the normal state of one being worked on, and sisu covers it: an untranslated string falls back to the source text. Measured at the default, 181 of live-manual's 189 translated files would be discarded, and nine languages would collapse to eight surviving files, reading as the document reverting to its source language rather than as a failure. index.html.in is not markup and no << line names it, so a configuration built from the manifest and the insert list alone drops it, and with it index.html.in.pot and its nine .po files at the next regeneration. It is found by asking whether the source language has one. neverwrap is not set, and the measurement is recorded beside the code: setting it turns 889 of 1126 strings fuzzy in four languages, and po4a does not use a fuzzy translation, so Catalan's coverage would fall from about 46% to about 12%. Tidy formatting is not worth that. The run-complete banner is suppressed for this action. The configuration goes to stdout and the banner would otherwise be part of the file, which is what the round trips already avoid by leaving early; this one prints from inside output processing and cannot. (assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/spine.d')
-rw-r--r--src/sisudoc/spine.d33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d
index 9013c3e..9424e02 100644
--- a/src/sisudoc/spine.d
+++ b/src/sisudoc/spine.d
@@ -97,14 +97,24 @@ string program_name = "spine";
static auto rgx = RgxI();
static auto rgx_y = RgxYaml();
static auto rgx_files = RgxFiles();
+ /+ ↓ an action whose output is a file's contents, printed to stdout, turns
+ this off: the banner would otherwise be part of what it printed. The
+ round trips do the same by leaving before scope(success) runs, which
+ they can because they leave early; --po4a-cfg prints from inside
+ output processing and so says so here instead. Set where the options
+ are read, below: the banner is declared before they exist.
+ +/
+ bool _run_banner = true;
scope(success) {
- writefln(
- "~ run complete, ok ~ (%s-%s.%s.%s, %s D:%s, %s %s)",
- program_name,
- _ver.major, _ver.minor, _ver.patch,
- __VENDOR__, __VERSION__,
- bits, os,
- );
+ if (_run_banner) {
+ writefln(
+ "~ run complete, ok ~ (%s-%s.%s.%s, %s D:%s, %s %s)",
+ program_name,
+ _ver.major, _ver.minor, _ver.patch,
+ __VENDOR__, __VERSION__,
+ bits, os,
+ );
+ }
}
scope(failure) {
debug(checkdoc) {
@@ -166,6 +176,7 @@ string program_name = "spine";
"pdf" : false,
"pdf-color-links" : false,
"pdf-init" : false,
+ "po4a-cfg" : false,
"pod" : false,
"pod2" : false,
"serial" : false,
@@ -288,6 +299,7 @@ string program_name = "spine";
"pdf", "latex output for pdfs", &opts["pdf"],
"pdf-color-links", "mono or color links for pdfs", &opts["pdf-color-links"],
"pdf-init", "initialise latex shared files (see latex-header-sty)", &opts["pdf-init"],
+ "po4a-cfg", "print the po4a configuration for this document", &opts["po4a-cfg"],
"pod", "spine (doc reform) pod source content bundled", &opts["pod"],
"pod2", "pod with document abstraction (.ssp) bundled", &opts["pod2"],
"quiet|q", "output to terminal", &opts["vox_is1"],
@@ -359,6 +371,10 @@ string program_name = "spine";
"debug-stages", "debug stages", &opts["debug-stages"],
// "sqlite-db-filename", "=[filename].sql.db", &settings["sqlite-db-filename"],
);
+ /+ ↓ --po4a-cfg prints a file's contents; see the banner above +/
+ if (opts["po4a-cfg"]) {
+ _run_banner = false;
+ }
if (helpInfo.helpWanted) {
defaultGetoptPrinter("Some information about the program.", helpInfo.options);
}
@@ -611,6 +627,9 @@ string program_name = "spine";
@trusted bool ocn_off() {
return ((opts["ocn-off"]) || (opts["no-ocn"])) ? true : false;
}
+ @trusted bool po4a_cfg() {
+ return opts["po4a-cfg"];
+ }
@trusted bool pod() {
return (opts["pod"] || opts["pod2"]) ? true : false;
}