aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/spine.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/spine.d')
-rw-r--r--src/sisudoc/spine.d41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d
index 9ceb069..4bf714d 100644
--- a/src/sisudoc/spine.d
+++ b/src/sisudoc/spine.d
@@ -214,6 +214,7 @@ string program_name = "spine";
string[string] settings = [
"output" : "",
"ssp-round-trip" : "",
+ "db-round-trip" : "",
"www-http" : "",
"www-host" : "",
"www-host-doc-root" : "",
@@ -275,6 +276,7 @@ string program_name = "spine";
"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"],
@@ -397,6 +399,45 @@ string program_name = "spine";
stdout.flush;
exit(0);
}
+ /+ ↓ 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);
+ }
enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff, text, skel }
struct OptActions {
@trusted bool allow_downloads() {