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.d102
1 files changed, 72 insertions, 30 deletions
diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d
index 9424e02..ab4eaa3 100644
--- a/src/sisudoc/spine.d
+++ b/src/sisudoc/spine.d
@@ -431,7 +431,26 @@ string program_name = "spine";
import sisudoc.ocda.abstraction.db_in;
mixin spineAbstractionDbRead;
mixin sspObjectRecord;
- auto _doc = dbReadFile(settings["db-round-trip"]);
+ /+ ↓ a database now holds every language of its document, so a language has to
+ be named. --lang says which; with none named dbReadFile if there is only
+ one, takes the only document there is, and where there is a choice
+ reports the languages and stops rather than picking one. A .ssp emitted
+ for a language nobody asked for would match nothing, and this is what the
+ round trip test compares byte for byte.
+ +/
+ string _rt_lang = "";
+ {
+ auto _langs = settings["lang"].split(",");
+ if (_langs.length > 0 && _langs[0] != "all") {
+ _rt_lang = _langs[0];
+ }
+ }
+ auto _doc = dbReadFile(settings["db-round-trip"], _rt_lang);
+ if (_doc.format.length == 0 && _doc.section_order.length == 0) {
+ import core.stdc.stdlib : exit;
+ stdout.flush;
+ exit(1);
+ }
string[] _out;
if (_doc.format.length > 0) { _out ~= _doc.format; }
if (_doc.source.length > 0) { _out ~= "% Source: " ~ _doc.source; }
@@ -880,8 +899,15 @@ string program_name = "spine";
} else if (
/+ ↓ these cannot run in parallel however asked: --curate aggregates
across documents, and the shared sqlite db has the one writer
+ .
+ --ocda-db joins them because one database now holds every
+ language of a document, written a language at a time. Several
+ languages at once against one file, one of them clearing it and
+ each opening its own transaction, is a race, and the losing
+ language would be missing from the artefact.
+/
sqlite_shared_db_action
+ || ocda_db
|| source_or_pod
) {
_is = false;
@@ -1690,38 +1716,54 @@ string program_name = "spine";
_artefact_args.join(", "));
}
foreach (_artefact; _artefact_args) {
- auto doc = spineDocFromArtefact!()(
- _artefact, program_info, _opt_action, _env, _make_and_meta_struct,
- );
- if (!doc.loaded) {
- stderr.writeln("ERROR: could not load ", _artefact,
- (doc.note.length > 0) ? ": " ~ doc.note : "");
+ /+ ↓ a .ocda.db holds every language of its document, so one artefact can
+ be several documents to build. A .ssp is one, and comes back as a
+ single unnamed language.
+ +/
+ string[] _artefact_langs
+ = spineArtefactLanguages!()(_artefact, _opt_action.languages_set);
+ if (_artefact_langs.length == 0) {
+ stderr.writeln("WARNING: ", _artefact.baseName,
+ " holds no document in the language(s) asked for: ",
+ _opt_action.languages_set.join(" "));
continue;
}
- if (_opt_action.vox_gt_1) {
- writeln("-- ~ document from ", doc.source_name,
- " ~ ------------------------------------");
- writeln(" ", _artefact);
- }
- if (doc.matters.opt.action.curate) {
- auto _hvst = spineMetaDocCurate!()(doc.matters, hvst);
- if (_hvst.title.length > 0 && _hvst.author_surname_fn.length > 0) {
- hvst.curates ~= _hvst;
+ foreach (_artefact_lang; _artefact_langs) {
+ auto doc = spineDocFromArtefact!()(
+ _artefact, program_info, _opt_action, _env, _make_and_meta_struct,
+ _artefact_lang,
+ );
+ if (!doc.loaded) {
+ stderr.writeln("ERROR: could not load ", _artefact,
+ (_artefact_lang.length > 0) ? " [" ~ _artefact_lang ~ "]" : "",
+ (doc.note.length > 0) ? ": " ~ doc.note : "");
+ continue;
}
- }
- if (!(doc.matters.opt.action.skip_output)) {
- doc.outputHub!();
- }
- if (_opt_action.vox_gt_1) {
- writeln("processed artefact: ", _artefact.baseName,
- " [", doc.matters.src.language, "]");
- }
- /+ ↓ the images a database carried, written out for this run only +/
- if (doc.images_tmp.length > 0) {
- try {
- if (doc.images_tmp.exists) { doc.images_tmp.rmdirRecurse; }
- } catch (Exception ex) {
- stderr.writeln("WARNING: could not remove ", doc.images_tmp, ": ", ex.msg);
+ if (_opt_action.vox_gt_1) {
+ writeln("-- ~ document from ", doc.source_name,
+ " ~ ------------------------------------");
+ writeln(" ", _artefact);
+ }
+ if (doc.matters.opt.action.curate) {
+ auto _hvst = spineMetaDocCurate!()(doc.matters, hvst);
+ if (_hvst.title.length > 0 && _hvst.author_surname_fn.length > 0) {
+ hvst.curates ~= _hvst;
+ }
+ }
+ if (!(doc.matters.opt.action.skip_output)) {
+ doc.outputHub!();
+ }
+ if (_opt_action.vox_gt_1) {
+ writeln("processed artefact: ", _artefact.baseName,
+ " [", doc.matters.src.language, "]");
+ }
+ /+ ↓ the images a database carried, written out for this run only +/
+ if (doc.images_tmp.length > 0) {
+ try {
+ if (doc.images_tmp.exists) { doc.images_tmp.rmdirRecurse; }
+ } catch (Exception ex) {
+ stderr.writeln("WARNING: could not remove ", doc.images_tmp, ": ", ex.msg);
+ }
}
}
}