diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-08 07:40:06 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-09 17:49:15 -0400 |
| commit | a28ab7a6c0d1a25a2b1195ff13b639e2256e97a8 (patch) | |
| tree | a159e5cf3a672ae4d6adea861ab3cfcf01736e37 /org/spine.org | |
| parent | test: .ssp round trip script beside the other two (diff) | |
a reader for the ocda db, and its round trip
sisudoc.ocda.abstraction.db_in reads a <doc>.abstraction.db back
into ObjGenericComposite[][string], the same value ssp_in returns
from a .ssp, so a consumer need not know which artefact it was
handed. It mixes in the .ssp reader for that shared document
struct rather than declaring a second one.
--db-round-trip=<file.abstraction.db> reads a database and emits
it as .ssp on stdout, through sspObjectRecord as the other round
trip does. Held against the .ssp written from the same document,
this says whether the two artefacts really carry the same thing:
not a count of fields, as test-abstraction-db.sh does, but the
whole document reconstructed from the database and compared to the
text.
SpinePOD=... ./test/test-abstraction-db-roundtrip.sh ./bin/spine-ldc
PASS: all 35 databases re-emit their document's .ssp exactly
It passed on the first run over the whole sample set, which is evidence
that the database is now field-complete against the .ssp rather than
merely counting the same.
Four tests with different checks:
test-abstraction-ssp.sh the abstraction has not changed
test-abstraction-db.sh the two serialisations agree, field by field
test-abstraction-ssp-roundtrip.sh the .ssp can be read back whole
test-abstraction-db-roundtrip.sh the .db can be read back whole
(assisted by Claude-Code)
Diffstat (limited to 'org/spine.org')
| -rw-r--r-- | org/spine.org | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/org/spine.org b/org/spine.org index 65cb2fe..722f235 100644 --- a/org/spine.org +++ b/org/spine.org @@ -61,6 +61,7 @@ string program_name = "spine"; <<spine_args_init_opts>> <<spine_args_init_settings>> <<spine_args_get_options_aa>> + <<read_spine_ocda_db_back_into_abstraction>> <<spine_args_get_options_aa2str>> <<spine_args_program_info>> <<spine_args_get_configuration_details>> @@ -395,6 +396,7 @@ NOTES on configuration hierarchy: see meta_conf_make_meta.org string[string] settings = [ "output" : "", "ssp-round-trip" : "", + "db-round-trip" : "", "www-http" : "", "www-host" : "", "www-host-doc-root" : "", @@ -462,6 +464,7 @@ auto helpInfo = getopt(args, "odt", "open document format text", &opts["odt"], "output", "=/path/to/output/dir specify where to place output", &settings["output"], "ssp-round-trip", "=/path/to/file.ssp read a .ssp back and re-emit it on stdout", &settings["ssp-round-trip"], + "db-round-trip", "=/path/to/file.abstraction.db read it back and emit .ssp on stdout", &settings["db-round-trip"], "parallel", "parallelisation", &opts["parallel"], "parallel-subprocesses", "nested parallelisation", &opts["parallel-subprocesses"], "pdf", "latex output for pdfs", &opts["pdf"], @@ -586,6 +589,51 @@ if (settings["ssp-round-trip"].length > 0) { } #+END_SRC +**** read ocda.db back CHECK + +#+NAME: read_spine_ocda_db_back_into_abstraction +#+BEGIN_SRC d +/+ ↓ read a <doc>.abstraction.db back into the abstraction and emit it as + .ssp on stdout. compared against the .ssp for the same document, this + says whether the two artefacts really do carry the same thing ++/ +if (settings["db-round-trip"].length > 0) { + import sisudoc.ocda.abstraction.ssp; + import sisudoc.ocda.abstraction.db_in; + mixin spineAbstractionDbRead; + mixin sspObjectRecord; + auto _doc = dbReadFile(settings["db-round-trip"]); + string[] _out; + if (_doc.format.length > 0) { _out ~= _doc.format; } + if (_doc.source.length > 0) { _out ~= "% Source: " ~ _doc.source; } + _out ~= ""; + void _blockdb(string _name, string[] _keys, string[string] _kv) { + _out ~= "@" ~ _name ~ " {"; + foreach (k; _keys) { + if (k in _kv) { _out ~= " " ~ k ~ ": " ~ _kv[k]; } + } + _out ~= "}"; + _out ~= ""; + } + _blockdb("meta", _doc.meta_order, _doc.meta); + _blockdb("make", _doc.make_order, _doc.make); + _blockdb("doc_has", _doc.doc_has_order, _doc.doc_has); + foreach (section; _doc.section_order) { + _out ~= "@" ~ section ~ " {"; + _out ~= ""; + foreach (obj; _doc.abstraction[section]) { + _out ~= sspObjectRecord(obj, section); + } + _out ~= "}"; + _out ~= ""; + } + foreach (line; _out) { writeln(line); } + import core.stdc.stdlib : exit; + stdout.flush; + exit(0); +} +#+END_SRC + **** getopt hash to struct - move getopt options to struct |
