diff options
Diffstat (limited to 'org/spine.org')
| -rw-r--r-- | org/spine.org | 124 |
1 files changed, 121 insertions, 3 deletions
diff --git a/org/spine.org b/org/spine.org index 3158191..fce7ca6 100644 --- a/org/spine.org +++ b/org/spine.org @@ -67,6 +67,12 @@ string program_name = "spine"; <<spine_args_get_configuration_details>> <<spine_args_call_output_hub>> <<spine_args_process_args>> + /+ ↓ the ocn alignment profiles, one per language, compared after the loop. + A named mixin, so that what the template declares stays in a scope of + its own rather than joining main's. + +/ + mixin spineOcnAlign _ocna; + _ocna.ST_OcnProfile[] _ocn_profiles; if (_manifests.length > 1 // _manifests[0] initialized dummy element && _opt_action.abstraction) { <<spine_initialize_output>> @@ -76,7 +82,7 @@ string program_name = "spine"; if (!empty(manifest.src.filename)) { <<spine_each_file_do_scope>> <<spine_each_file_do_abstraction>> - <<spine_each_file_do_show>> + <<spine_each_file_do_show_sync>> <<spine_each_file_do_selected_output>> <<spine_each_file_do_scope_exit>> } else { @@ -89,7 +95,7 @@ string program_name = "spine"; if (!empty(manifest.src.filename)) { <<spine_each_file_do_scope>> <<spine_each_file_do_abstraction>> - <<spine_each_file_do_show>> + <<spine_each_file_do_show_no_sync>> <<spine_each_file_do_selected_output>> <<spine_each_file_do_scope_exit>> } else { @@ -98,6 +104,40 @@ string program_name = "spine"; } } } + /+ ↓ the languages of a document, held against each other. + . + Here because it is the first point at which it can be done: a language + cannot know whether it numbers its objects the same way as its + siblings until they have all been abstracted. A warning, so that a + document with a diverging translation still builds; --strict turns it + into a failure for the run that is meant to be publishable. + . + The outcome is noted per language in the database, where there is one, + under translation.ocn_aligned. Only for documents that have more than + one language: a single language document has nothing to align with, + and "true" there would be an answer to a question nobody asked. + +/ + bool _ocn_align_failed = false; + if (_ocn_profiles.length > 1) { + auto _ocn_results = _ocna.ocnAlignCompare(_ocn_profiles); + foreach (_line; _ocna.ocnAlignReportLines(_ocn_results)) { + stderr.writeln(_line); + } + bool[string][string] _aligned; // doc_key -> lang -> aligned + foreach (_r; _ocn_results) { + _aligned[_r.doc_key][_r.lang] = _r.aligned; + _aligned[_r.doc_key][_r.reference_lang] = true; + if (!_r.aligned) { _ocn_align_failed = true; } + } + foreach (_p; _ocn_profiles) { + if (_p.db_file.length == 0) { continue; } + if (_p.doc_key !in _aligned) { continue; } + if (_p.lang !in _aligned[_p.doc_key]) { continue; } + import sisudoc.outputs.io_out.sqlite_ocda_db : spineOcdaDbDocNote; + spineOcdaDbDocNote!()(_p.db_file, _p.lang, "translation.ocn_aligned", + _aligned[_p.doc_key][_p.lang] ? "true" : "false"); + } + } /+ ↓ documents given as an abstraction artefact rather than as markup. .ssp and .ocda.db are read, not parsed, and what comes back is the doc the output writers already take, so this loop is the markup one @@ -196,6 +236,18 @@ string program_name = "spine"; foreach (ref _dlr; _url_downloads) { cleanupDownload(_dlr); } + /+ ↓ --strict and a document whose languages diverged: fatal to the run. + At the end rather than where the check runs, so that the outputs of + the run are complete and can be looked at. The warning has already + been printed with the detail; this is the exit status. + +/ + if (_ocn_align_failed && _opt_action.strict) { + stderr.writeln( + "~ run FAILED ~ --strict: ocn alignment differs between languages" + ); + import core.stdc.stdlib : exit; + exit(1); + } /+ ↓ sqlite statements that failed are fatal to the run, report and exit non-zero +/ { import sisudoc.outputs.io_out.sqlite_collection_db : sqliteFailureTally; @@ -235,6 +287,7 @@ import sisudoc.ocda.meta.conf_make_meta_structs; 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.rgx; import sisudoc.ocda.meta.rgx_yaml; import sisudoc.ocda.meta.rgx_files; @@ -479,6 +532,7 @@ bool[string] opts = [ "section_blurb" : true, "backmatter" : true, "skip-output" : false, + "strict" : false, "theme-dark" : false, "theme-light" : false, "workon" : false, @@ -587,6 +641,7 @@ auto helpInfo = getopt(args, "section-toc", "table of contents (default)", &opts["section_toc"], "serial", "serial document processing (default)", &opts["serial"], "skip-output", "skip output", &opts["skip-output"], + "strict", "document checks that warn become failures", &opts["strict"], "show-abstraction", "show document abstraction (write .ssp file)", &opts["show-abstraction"], "show-config", "show config", &opts["show-config"], "show-curate", "show curate", &opts["show-curate"], @@ -1086,6 +1141,9 @@ struct OptActions { @trusted bool skip_output() { return opts["skip-output"]; } + @trusted bool strict() { + return opts["strict"]; + } @trusted bool workon() { return opts["workon"]; } @@ -1833,7 +1891,7 @@ if ((doc.matters.opt.action.debug_do) **** 0. abstraction ***** show document summary - abstraction _print summary_ (to screen) :abstraction:summary: -#+NAME: spine_each_file_do_show +#+NAME: spine_each_file_do_show_sync #+HEADER: :noweb yes #+BEGIN_SRC d <<spine_each_file_do_debugs_checkdoc_0>> @@ -1842,6 +1900,21 @@ if ((doc.matters.opt.action.debug_do) <<spine_each_file_do_debugs_checkdoc_3>> <<spine_each_file_show_abstraction_peg>> <<spine_each_file_ocda_db>> +<<spine_ocn_alignment_synchronized>> +<<spine_each_file_do_debugs_checkdoc_4>> +<<spine_each_file_do_debugs_checkdoc_5>> +#+END_SRC + +#+NAME: spine_each_file_do_show_no_sync +#+HEADER: :noweb yes +#+BEGIN_SRC d +<<spine_each_file_do_debugs_checkdoc_0>> +<<spine_each_file_do_debugs_checkdoc_1>> +<<spine_each_file_do_debugs_checkdoc_2>> +<<spine_each_file_do_debugs_checkdoc_3>> +<<spine_each_file_show_abstraction_peg>> +<<spine_each_file_ocda_db>> +<<spine_ocn_alignment_non_synchronized>> <<spine_each_file_do_debugs_checkdoc_4>> <<spine_each_file_do_debugs_checkdoc_5>> #+END_SRC @@ -1923,6 +1996,51 @@ if (doc.matters.opt.action.ocda_db) { } #+END_SRC +***** align ocn synchronized (parallel processing) + +#+NAME: spine_ocn_alignment_synchronized +#+BEGIN_SRC d +/+ ↓ the ocn alignment profile of this language, kept for the + check that runs once every language of the document has been + abstracted. Taken whatever the outputs are: the languages of + a document share their object numbering whether or not + anything is being written. ++/ +{ + auto _ocn_p = _ocna.ocnProfile(doc); + if (doc.matters.opt.action.ocda_db) { + import sisudoc.outputs.io_out.paths_output; + auto _pths_pod_ocn = spinePathsPods!()(doc.matters); + _ocn_p.db_file = _pths_pod_ocn.pod_dir_() ~ "/" + ~ doc.matters.src.doc_uid_out_no_lang ~ ".ocda.db"; + } + synchronized { _ocn_profiles ~= _ocn_p; } +} +#+END_SRC + +***** align ocn non-synchronized (serial processing) + +#+NAME: spine_ocn_alignment_non_synchronized +#+BEGIN_SRC d +/+ ↓ the ocn alignment profile of this language, kept for the + check that runs once every language of the document has been + abstracted. Taken whatever the outputs are: the languages of + a document share their object numbering whether or not + anything is being written. ++/ +{ + auto _ocn_p = _ocna.ocnProfile(doc); + if (doc.matters.opt.action.ocda_db) { + import sisudoc.outputs.io_out.paths_output; + auto _pths_pod_ocn = spinePathsPods!()(doc.matters); + _ocn_p.db_file = _pths_pod_ocn.pod_dir_() ~ "/" + ~ doc.matters.src.doc_uid_out_no_lang ~ ".ocda.db"; + } + _ocn_profiles ~= _ocn_p; +} +#+END_SRC + + ***** abstraction curate :abstraction:curate: - abstraction curate |
