metanorma-iso 3.5.38 → 3.5.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.adoc +13 -0
  4. data/docs/validation.md +137 -0
  5. data/lib/isodoc/iso/docx/middle_title_renderer.rb +1 -1
  6. data/lib/isodoc/iso/iso.amendment.xsl +9 -2
  7. data/lib/isodoc/iso/iso.international-standard.xsl +9 -2
  8. data/lib/metanorma/iso/html/renderer.rb +505 -508
  9. data/lib/metanorma/iso/themes/iso/theme.yaml +9 -2
  10. data/lib/metanorma/iso/themes/iso-legacy/theme.yaml +9 -2
  11. data/lib/metanorma/iso/validation/model_validator.rb +13 -0
  12. data/lib/metanorma/iso/validation/rules/base.rb +34 -0
  13. data/lib/metanorma/iso/validation/rules/doctype_rule.rb +4 -0
  14. data/lib/metanorma/iso/validation/rules/foreword_presence_rule.rb +4 -0
  15. data/lib/metanorma/iso/validation/rules/foreword_structure_rule.rb +4 -0
  16. data/lib/metanorma/iso/validation/rules/iteration_rule.rb +4 -0
  17. data/lib/metanorma/iso/validation/rules/normative_references_presence_rule.rb +4 -0
  18. data/lib/metanorma/iso/validation/rules/only_child_clause_rule.rb +4 -0
  19. data/lib/metanorma/iso/validation/rules/scope_presence_rule.rb +4 -0
  20. data/lib/metanorma/iso/validation/rules/scope_subclauses_rule.rb +4 -0
  21. data/lib/metanorma/iso/validation/rules/section_sequence_rule.rb +4 -0
  22. data/lib/metanorma/iso/validation/rules/style_abbrev_articles_rule.rb +5 -2
  23. data/lib/metanorma/iso/validation/rules/style_empty_clause_rule.rb +4 -0
  24. data/lib/metanorma/iso/validation/rules/subcommittee_type_rule.rb +4 -0
  25. data/lib/metanorma/iso/validation/rules/subpart_iec_rule.rb +4 -0
  26. data/lib/metanorma/iso/validation/rules/symbols_section_content_rule.rb +4 -0
  27. data/lib/metanorma/iso/validation/rules/symbols_section_count_rule.rb +4 -0
  28. data/lib/metanorma/iso/validation/rules/technical_committee_type_rule.rb +4 -0
  29. data/lib/metanorma/iso/validation/rules/termdef_style_rule.rb +4 -0
  30. data/lib/metanorma/iso/validation/rules/terms_presence_rule.rb +4 -0
  31. data/lib/metanorma/iso/validation/rules/title_first_level_rule.rb +4 -0
  32. data/lib/metanorma/iso/validation/rules/title_names_doctype_rule.rb +4 -0
  33. data/lib/metanorma/iso/validation/rules/title_pairing_rule.rb +4 -0
  34. data/lib/metanorma/iso/validation/rules/title_siblings_consistency_rule.rb +4 -0
  35. data/lib/metanorma/iso/version.rb +1 -1
  36. data/script/migrate-logo-records.rb +92 -0
  37. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 221d4446691fdc7a98e414262b615aeb01e98f4fc48acfb043e7f7068f9d4d53
4
- data.tar.gz: 463775b1aa78ef2e2f93b746d45ec17137a8a1b0e1cc6f4c6b814ed6dd1a0fff
3
+ metadata.gz: da240e228ac0cf796e085001b75242dc2aa41e8dd67cc3aaa597274f5b3e15be
4
+ data.tar.gz: 26867cb97c50948597f7454de83756512a35e50f13fd98393bc068f3f81b4383
5
5
  SHA512:
6
- metadata.gz: 5407718865562d2100b28ce0827fa4ed3efee056a3095bcc85d8d607d919680d0313e5cb731326ce64afbb787734121da3893d7a06adaaf683f5d1907dae9185
7
- data.tar.gz: cc0abe4edd9de7479eb9160ed07d776b532dac89599be95bdf0a5111dcdae88c43b7fe6cef7a2100f024617dcd967e7ce435fbe3baebaf4ea5e015d18967d664
6
+ metadata.gz: 668a9306dc36ad38800220cccbb1767222d905682e3e2640305eace497654def08a22bc8956c75c74293d25df7f41ed49288ca5afa46c73541e48554c0a5bf3c
7
+ data.tar.gz: 769289b8df4ebbe0141aa9fe0797dbc8c9a33e9f800e8be9e0eaafd9a0998470128b6d11482fac810e6065d6bd51b2d4bcd8675a36b3c55b2cac48afb80a3e88
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem "metanorma-standoc", "~> 3.5.7" # Standoc::Document split + the pubid-dispat
12
12
  # Dev pin: golden capture and the engine-delegation parity runs execute
13
13
  # against the released engine (metanorma-document#165); the gemspec
14
14
  # floor is raised in the engine-delegation wave.
15
- gem "metanorma-document", "~> 0.5.15"
15
+ gem "metanorma-document", "~> 0.5.21" # the logo records schema wave
16
16
  gem "rake"
17
17
  # relaton-bib is retired; its successors ship in the relaton 3.1 line.
18
18
  gem "rspec"
data/README.adoc CHANGED
@@ -92,6 +92,19 @@ The metanorma-cli gem is the command-line interface for the Metanorma tool suite
92
92
 
93
93
  See https://www.metanorma.com/author/iso/[The ISO flavor of Metanorma].
94
94
 
95
+ The validation subsystem is documented in the `docs/` directory:
96
+
97
+ * link:docs/validation.md[The validation system] — rules and codes, the
98
+ validation profiles (`DEFAULT`, `STRICT`, `PUBLICATION`, published profile
99
+ files, `only_codes`/`except_codes`) and the amendment document-type
100
+ exemption (`exempt_doctypes`).
101
+ * link:docs/validation-rule-kinds.md[Validation rule kinds] — the four
102
+ implementation kinds behind a rule code.
103
+ * link:docs/validation-suppression-authoring.md[Suppressing validation
104
+ warnings] — the document-level suppression attributes.
105
+ * link:docs/validation-baselines.md[Validation baselines] — the flavour
106
+ severity baselines and the suppression resolution chain.
107
+
95
108
  == Examples
96
109
 
97
110
  * Example documents are avalable at the https://github.com/metanorma/mn-samples-iso[mn-samples-iso] repository.
@@ -0,0 +1,137 @@
1
+ # The metanorma-iso validation system
2
+
3
+ Metanorma-iso validates a document against the ISO/IEC Directives, Part 2
4
+ and the ISO House Style, and reports every violation with a stable rule
5
+ code such as `ISO_29` or `ISO_63`. This page documents the machinery that
6
+ decides which rules run: the rule registry, the validation profiles, and
7
+ the document-type exemption that keeps amendment documents free of
8
+ full-standard structure findings. The sibling pages cover the rule
9
+ implementation kinds (`validation-rule-kinds.md`), the document-level
10
+ suppression attributes (`validation-suppression-authoring.md`) and the
11
+ flavour severity baselines (`validation-baselines.md`).
12
+
13
+ ## Rules and codes
14
+
15
+ Every rule is a `Metanorma::Iso::Validation::Rules::Base` subclass that
16
+ declares its log key with `code "ISO_N"`, its policy documentation with a
17
+ `policy` declaration, and returns findings from `#check`. The registry
18
+ (`Metanorma::Iso::Validation::RuleRegistry`) discovers every concrete rule
19
+ class under `lib/metanorma/iso/validation/rules/` automatically; a new rule
20
+ file plus one autoload line is the whole registration. The orchestrator
21
+ (`Metanorma::Iso::Validation::ModelValidator`) runs the discovered rules
22
+ against the deserialized document model and mirrors the findings into the
23
+ converter log and the structured report.
24
+
25
+ ## Validation profiles
26
+
27
+ A profile filters which rules run and configures how warnings are treated.
28
+ Profiles are composable: new profiles are new instances, no existing code
29
+ changes.
30
+
31
+ ```ruby
32
+ # The built-in profiles
33
+ Metanorma::Iso.validate(xml, profile: Metanorma::Iso::Validation::Profile::DEFAULT)
34
+ Metanorma::Iso.validate(xml, profile: Metanorma::Iso::Validation::Profile::STRICT)
35
+ Metanorma::Iso.validate(xml, profile: Metanorma::Iso::Validation::Profile::PUBLICATION)
36
+
37
+ # A custom profile
38
+ profile = Metanorma::Iso::Validation::Profile.new(
39
+ name: "ci",
40
+ only_codes: ["ISO_5", "ISO_29", "ISO_30", "ISO_31"],
41
+ strict_warnings: true
42
+ )
43
+ Metanorma::Iso.validate(xml, profile: profile)
44
+ ```
45
+
46
+ The filters are additive: `only_codes` keeps just the named rules;
47
+ `except_codes` drops the named ones. `strict_warnings` promotes warnings to
48
+ fatal findings, so a report with warnings fails alongside reports with
49
+ errors.
50
+
51
+ The built-in profiles are:
52
+
53
+ * `DEFAULT` — every rule runs; warnings are not fatal.
54
+ * `STRICT` — every rule runs; warnings are fatal.
55
+ * `PUBLICATION` — every rule runs except the style-warning family
56
+ (the House Style text lints), for documents whose style findings have
57
+ already been addressed.
58
+
59
+ ### Published profiles
60
+
61
+ Declarative profile files ship with the gem under
62
+ `lib/metanorma/iso/validation/profiles/` (for example `house-style.yml`,
63
+ `quality-english.yml`, `oxford-spelling.yml`). Each file declares the
64
+ `metanorma-validation-profile/1` schema and a `select:` block whose entries
65
+ pick rules by policy metadata — `mn_category`, `source` or `category` — or
66
+ directly by rule class name. Entries are disjunctive; the keys inside one
67
+ entry are conjunctive.
68
+
69
+ ```yaml
70
+ schema: metanorma-validation-profile/1
71
+ profile: house-style-core
72
+ flavor: iso
73
+ select:
74
+ - mn_category: style
75
+ source: house_style
76
+ ```
77
+
78
+ Load a published profile with `Profile.load`:
79
+
80
+ ```ruby
81
+ profile = Metanorma::Iso::Validation::Profile.load("house-style-core")
82
+ Metanorma::Iso.validate(xml, profile: profile)
83
+ ```
84
+
85
+ An unknown profile name or an unrecognized schema aborts the load, so an
86
+ importer pins behavior instead of drifting.
87
+
88
+ ## The amendment document-type exemption
89
+
90
+ Some rules enforce the full-standard structure contract: the Scope clause
91
+ (`ISO_29`), the Normative references (`ISO_30`), the Terms and definitions
92
+ clause (`ISO_31`), the section sequencing (`ISO_28`) and the subclause-free
93
+ Scope (`ISO_39`). Amendments and technical corrigenda are not freestanding
94
+ standards and legitimately lack these elements; running the structure
95
+ contract against them produces false positives.
96
+
97
+ Such rules declare the doctypes they do not apply to with the
98
+ `exempt_doctypes` class-level DSL:
99
+
100
+ ```ruby
101
+ class ScopePresenceRule < Base
102
+ code "ISO_29"
103
+
104
+ policy category: "Document structure",
105
+ rule: "the document must contain a Scope clause",
106
+ source: :directives, directives: "14.3",
107
+ mn_category: :structure
108
+
109
+ # Amendments and technical corrigenda are not freestanding
110
+ # standards; the full-standard structure contract does not
111
+ # apply to them (metanorma/metanorma-pdfa#130).
112
+ exempt_doctypes "amendment", "technical-corrigendum"
113
+ end
114
+ ```
115
+
116
+ The engine enforces the declaration at the rule-run site:
117
+ `ModelValidator` skips a rule when the document's doctype — carried on the
118
+ run's `ConverterState` — appears in the rule's `exempt_doctypes` list. A
119
+ document without a doctype exempts nothing, and rules that do not declare
120
+ the exemption run for every doctype. Declarations accumulate across calls
121
+ and the accumulated list is frozen.
122
+
123
+ The declaration is kept honest by an audit specification
124
+ (`spec/metanorma/validation/exempt_doctypes_spec.rb`): every registered
125
+ rule whose policy category is `Document structure` must declare the
126
+ amendment exemption, so a future structure rule without the declaration
127
+ fails CI. A rule author who sees that failure either adds the declaration
128
+ or reconsiders the rule's category.
129
+
130
+ ## Further reading
131
+
132
+ * `docs/validation-rule-kinds.md` — the four implementation kinds and why
133
+ the code is the interface.
134
+ * `docs/validation-suppression-authoring.md` — the document-level
135
+ suppression attributes.
136
+ * `docs/validation-baselines.md` — the flavour severity baselines and the
137
+ suppression resolution chain.
@@ -89,7 +89,7 @@ module IsoDoc
89
89
  description = localized.title_amd&.value.to_s.strip
90
90
  return if label.empty? && description.empty?
91
91
 
92
- text = label.empty? ? description : "#{label}: #{description}"
92
+ text = [label, description].reject(&:empty?).join(": ")
93
93
  append_title(doc, :main_title2, text)
94
94
  end
95
95
 
@@ -1261,7 +1261,7 @@
1261
1261
  <xsl:when test="$layoutVersion = '1972' or $layoutVersion = '1979' or $layoutVersion = '1987' or ($layoutVersion = '1989' and $revision_date_num &lt;= 19981231)"><!-- copyright renders in the footer footer-preface-first_1987-1998--></xsl:when>
1262
1262
  <xsl:otherwise>
1263
1263
 
1264
- <xsl:call-template name="inner-cover-page">
1264
+ <xsl:call-template name="inner-cover-pages">
1265
1265
  <xsl:with-param name="num" select="$num"/>
1266
1266
  </xsl:call-template>
1267
1267
 
@@ -4366,7 +4366,7 @@
4366
4366
  <!-- ============================= -->
4367
4367
 
4368
4368
  <!-- element with title -->
4369
- <xsl:template match="*[mn:title or mn:fmt-title]" mode="contents">
4369
+ <xsl:template match="*[mn:title or mn:fmt-title]" mode="contents" name="title_contents">
4370
4370
  <xsl:variable name="level">
4371
4371
  <xsl:call-template name="getLevel">
4372
4372
  <xsl:with-param name="depth" select="mn:fmt-title/@depth | mn:title/@depth"/>
@@ -8283,6 +8283,13 @@
8283
8283
  </xsl:call-template>
8284
8284
  </xsl:template>
8285
8285
 
8286
+ <xsl:template name="inner-cover-pages">
8287
+ <xsl:param name="num"/>
8288
+ <xsl:call-template name="inner-cover-page">
8289
+ <xsl:with-param name="num" select="$num"/>
8290
+ </xsl:call-template>
8291
+ </xsl:template>
8292
+
8286
8293
  <!-- insert cover page image -->
8287
8294
  <!-- background cover image -->
8288
8295
  <xsl:template name="insertBackgroundPageImage">
@@ -1261,7 +1261,7 @@
1261
1261
  <xsl:when test="$layoutVersion = '1972' or $layoutVersion = '1979' or $layoutVersion = '1987' or ($layoutVersion = '1989' and $revision_date_num &lt;= 19981231)"><!-- copyright renders in the footer footer-preface-first_1987-1998--></xsl:when>
1262
1262
  <xsl:otherwise>
1263
1263
 
1264
- <xsl:call-template name="inner-cover-page">
1264
+ <xsl:call-template name="inner-cover-pages">
1265
1265
  <xsl:with-param name="num" select="$num"/>
1266
1266
  </xsl:call-template>
1267
1267
 
@@ -4366,7 +4366,7 @@
4366
4366
  <!-- ============================= -->
4367
4367
 
4368
4368
  <!-- element with title -->
4369
- <xsl:template match="*[mn:title or mn:fmt-title]" mode="contents">
4369
+ <xsl:template match="*[mn:title or mn:fmt-title]" mode="contents" name="title_contents">
4370
4370
  <xsl:variable name="level">
4371
4371
  <xsl:call-template name="getLevel">
4372
4372
  <xsl:with-param name="depth" select="mn:fmt-title/@depth | mn:title/@depth"/>
@@ -8283,6 +8283,13 @@
8283
8283
  </xsl:call-template>
8284
8284
  </xsl:template>
8285
8285
 
8286
+ <xsl:template name="inner-cover-pages">
8287
+ <xsl:param name="num"/>
8288
+ <xsl:call-template name="inner-cover-page">
8289
+ <xsl:with-param name="num" select="$num"/>
8290
+ </xsl:call-template>
8291
+ </xsl:template>
8292
+
8286
8293
  <!-- insert cover page image -->
8287
8294
  <!-- background cover image -->
8288
8295
  <xsl:template name="insertBackgroundPageImage">