metanorma-iso 3.5.37 → 3.5.39
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.adoc +13 -0
- data/docs/validation.md +137 -0
- data/lib/isodoc/iso/docx/middle_title_renderer.rb +1 -1
- data/lib/isodoc/iso/iso.amendment.xsl +9 -2
- data/lib/isodoc/iso/iso.international-standard.xsl +9 -2
- data/lib/metanorma/iso/front_id.rb +0 -1
- data/lib/metanorma/iso/html/renderer.rb +505 -508
- data/lib/metanorma/iso/themes/iso/theme.yaml +9 -2
- data/lib/metanorma/iso/themes/iso-legacy/theme.yaml +9 -2
- data/lib/metanorma/iso/validation/model_validator.rb +13 -0
- data/lib/metanorma/iso/validation/rules/base.rb +34 -0
- data/lib/metanorma/iso/validation/rules/doctype_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/foreword_presence_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/foreword_structure_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/iteration_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/normative_references_presence_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/only_child_clause_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/scope_presence_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/scope_subclauses_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/section_sequence_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/style_abbrev_articles_rule.rb +5 -2
- data/lib/metanorma/iso/validation/rules/style_empty_clause_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/subcommittee_type_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/subpart_iec_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/symbols_section_content_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/symbols_section_count_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/technical_committee_type_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/termdef_style_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/terms_presence_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/title_first_level_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/title_names_doctype_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/title_pairing_rule.rb +4 -0
- data/lib/metanorma/iso/validation/rules/title_siblings_consistency_rule.rb +4 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/script/migrate-logo-records.rb +92 -0
- metadata +4 -2
|
@@ -72,8 +72,15 @@ dark_admonition_bg: "#2a1d21"
|
|
|
72
72
|
publishers:
|
|
73
73
|
- "ISO"
|
|
74
74
|
publisher_name: "ISO"
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
logos:
|
|
76
|
+
- publisher: ISO
|
|
77
|
+
use: cover
|
|
78
|
+
style: color-light
|
|
79
|
+
file: iso-logo.svg
|
|
80
|
+
logo_slots:
|
|
81
|
+
- slot: cover
|
|
82
|
+
use: cover
|
|
83
|
+
style: color-light
|
|
77
84
|
|
|
78
85
|
# Section ordering
|
|
79
86
|
preface_order:
|
|
@@ -30,8 +30,15 @@ cover_separator_color: "rgba(227,0,15,0.25)"
|
|
|
30
30
|
publishers:
|
|
31
31
|
- "ISO"
|
|
32
32
|
publisher_name: "ISO"
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
logos:
|
|
34
|
+
- publisher: ISO
|
|
35
|
+
use: cover
|
|
36
|
+
style: color-light
|
|
37
|
+
file: iso-logo.svg
|
|
38
|
+
logo_slots:
|
|
39
|
+
- slot: cover
|
|
40
|
+
use: cover
|
|
41
|
+
style: color-light
|
|
35
42
|
|
|
36
43
|
# Section ordering
|
|
37
44
|
preface_order:
|
|
@@ -94,6 +94,7 @@ module Metanorma
|
|
|
94
94
|
|
|
95
95
|
instances.flat_map do |rule|
|
|
96
96
|
next [] unless rule.applicable?(context)
|
|
97
|
+
next [] if doctype_exempt?(rule, context)
|
|
97
98
|
|
|
98
99
|
rule.check(context)
|
|
99
100
|
rescue StandardError => e
|
|
@@ -102,6 +103,18 @@ module Metanorma
|
|
|
102
103
|
end
|
|
103
104
|
end
|
|
104
105
|
|
|
106
|
+
# Engine enforcement of the document-type exemption declared via
|
|
107
|
+
# {Rules::Base.exempt_doctypes} (issue metanorma-pdfa#130): rules
|
|
108
|
+
# that enforce the full-standard structure contract declare the
|
|
109
|
+
# amendment doctypes and are skipped for those documents. A state
|
|
110
|
+
# without a doctype exempts nothing.
|
|
111
|
+
def doctype_exempt?(rule, context)
|
|
112
|
+
doctype = context.state&.doctype
|
|
113
|
+
return false unless doctype
|
|
114
|
+
|
|
115
|
+
rule.class.exempt_doctypes.include?(doctype.to_s)
|
|
116
|
+
end
|
|
117
|
+
|
|
105
118
|
def reporter_for(output_format)
|
|
106
119
|
OUTPUT_FORMATS.fetch(output_format) do
|
|
107
120
|
raise ArgumentError, "unknown output format #{output_format.inspect}"
|
|
@@ -21,6 +21,10 @@ module Metanorma
|
|
|
21
21
|
POLICY_SOURCES = %i[house_style directives].freeze
|
|
22
22
|
POLICY_MN_CATEGORIES = %i[style structure references].freeze
|
|
23
23
|
|
|
24
|
+
# The empty exemption list returned by {exempt_doctypes} when a
|
|
25
|
+
# rule class declares none.
|
|
26
|
+
DEFAULT_EXEMPT_DOCTYPES = [].freeze
|
|
27
|
+
|
|
24
28
|
class << self
|
|
25
29
|
# Mark a class as abstract — RuleRegistry skips abstract
|
|
26
30
|
# classes when discovering runnable rules. Used by StyleRule
|
|
@@ -93,6 +97,36 @@ module Metanorma
|
|
|
93
97
|
@policy_metadata
|
|
94
98
|
end
|
|
95
99
|
|
|
100
|
+
# Declare the document types the rule does NOT apply to
|
|
101
|
+
# (issue metanorma-pdfa#130). Rules that enforce the
|
|
102
|
+
# full-standard structure contract — the Scope clause, the
|
|
103
|
+
# Normative references, the Terms clause, the section
|
|
104
|
+
# sequencing — legitimately fail on amendments and technical
|
|
105
|
+
# corrigenda, which are not freestanding standards. Such rules
|
|
106
|
+
# declare the amendment doctypes and the engine
|
|
107
|
+
# ({ModelValidator}) skips them when the document's doctype
|
|
108
|
+
# matches:
|
|
109
|
+
#
|
|
110
|
+
# exempt_doctypes "amendment", "technical-corrigendum"
|
|
111
|
+
#
|
|
112
|
+
# Declarations accumulate across calls and the accumulated
|
|
113
|
+
# list is frozen. The default is the empty list. This is a
|
|
114
|
+
# per-class declaration: it does not inherit, so a subclass
|
|
115
|
+
# of an exempt rule must decide for itself (the audit spec
|
|
116
|
+
# keeps structure rules honest). The engine consults the
|
|
117
|
+
# class-level list — declare it on the rule class, never on
|
|
118
|
+
# instances.
|
|
119
|
+
def exempt_doctypes(*types)
|
|
120
|
+
if types.empty?
|
|
121
|
+
return @exempt_doctypes if instance_variable_defined?(:@exempt_doctypes) && @exempt_doctypes
|
|
122
|
+
|
|
123
|
+
return DEFAULT_EXEMPT_DOCTYPES
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
declared = instance_variable_defined?(:@exempt_doctypes) ? @exempt_doctypes : []
|
|
127
|
+
@exempt_doctypes = (declared + types.map(&:to_s)).uniq.freeze
|
|
128
|
+
end
|
|
129
|
+
|
|
96
130
|
private
|
|
97
131
|
|
|
98
132
|
# Keep the metadata coherent: declared values must come from the
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
rule: "doctype must be a recognised ISO document type",
|
|
16
16
|
source: :directives, directives: "3.1",
|
|
17
17
|
mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
ALLOWED_DOCTYPES = %w[
|
|
20
24
|
international-standard
|
|
@@ -20,6 +20,10 @@ module Metanorma
|
|
|
20
20
|
rule: "the Foreword is a mandatory element",
|
|
21
21
|
source: :directives, directives: "12.3",
|
|
22
22
|
mn_category: :structure
|
|
23
|
+
# Amendments and technical corrigenda are not freestanding
|
|
24
|
+
# standards; the full-standard structure contract does not
|
|
25
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
26
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
23
27
|
|
|
24
28
|
def applicable?(context)
|
|
25
29
|
!context.root.nil? && !context.root.preface.nil?
|
|
@@ -13,6 +13,10 @@ module Metanorma
|
|
|
13
13
|
rule: "the Foreword must not contain subclauses",
|
|
14
14
|
source: :directives, directives: "12.4",
|
|
15
15
|
mn_category: :structure
|
|
16
|
+
# Amendments and technical corrigenda are not freestanding
|
|
17
|
+
# standards; the full-standard structure contract does not
|
|
18
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
19
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
16
20
|
|
|
17
21
|
def applicable?(context)
|
|
18
22
|
!context.root.nil? && !context.root.preface.nil?
|
|
@@ -17,6 +17,10 @@ module Metanorma
|
|
|
17
17
|
policy category: "Document structure",
|
|
18
18
|
rule: "bibdata/status/iteration must be a number",
|
|
19
19
|
source: :directives, mn_category: :structure
|
|
20
|
+
# Amendments and technical corrigenda are not freestanding
|
|
21
|
+
# standards; the full-standard structure contract does not
|
|
22
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
23
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
20
24
|
|
|
21
25
|
def applicable?(context)
|
|
22
26
|
!context.root.nil? && context.state&.document
|
|
@@ -13,6 +13,10 @@ module Metanorma
|
|
|
13
13
|
rule: "the document must contain a Normative references clause",
|
|
14
14
|
source: :directives, directives: "15.3",
|
|
15
15
|
mn_category: :structure
|
|
16
|
+
# Amendments and technical corrigenda are not freestanding
|
|
17
|
+
# standards; the full-standard structure contract does not
|
|
18
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
19
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
16
20
|
|
|
17
21
|
def applicable?(context)
|
|
18
22
|
!context.root.nil?
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
rule: "a subclause must not be the only child at its level",
|
|
16
16
|
source: :directives, directives: "22.3.2",
|
|
17
17
|
mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
def applicable?(context)
|
|
20
24
|
!context.root.nil?
|
|
@@ -13,6 +13,10 @@ module Metanorma
|
|
|
13
13
|
rule: "the document must contain a Scope clause",
|
|
14
14
|
source: :directives, directives: "14.3",
|
|
15
15
|
mn_category: :structure
|
|
16
|
+
# Amendments and technical corrigenda are not freestanding
|
|
17
|
+
# standards; the full-standard structure contract does not
|
|
18
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
19
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
16
20
|
|
|
17
21
|
def applicable?(context)
|
|
18
22
|
!context.root.nil?
|
|
@@ -13,6 +13,10 @@ module Metanorma
|
|
|
13
13
|
rule: "the Scope must not contain subclauses",
|
|
14
14
|
source: :directives, directives: "14.4",
|
|
15
15
|
mn_category: :structure
|
|
16
|
+
# Amendments and technical corrigenda are not freestanding
|
|
17
|
+
# standards; the full-standard structure contract does not
|
|
18
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
19
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
16
20
|
|
|
17
21
|
def applicable?(context)
|
|
18
22
|
!context.root.nil?
|
|
@@ -21,6 +21,10 @@ module Metanorma
|
|
|
21
21
|
rule: "sections follow the DIR 2 arrangement (Foreword, Introduction, Scope, Terms, Clauses, Annexes, Normative References, Bibliography)",
|
|
22
22
|
source: :directives, directives: "6.4",
|
|
23
23
|
mn_category: :structure
|
|
24
|
+
# Amendments and technical corrigenda are not freestanding
|
|
25
|
+
# standards; the full-standard structure contract does not
|
|
26
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
27
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
24
28
|
|
|
25
29
|
SectionItem = Struct.new(:kind, :node, keyword_init: true)
|
|
26
30
|
|
|
@@ -22,9 +22,12 @@ module Metanorma
|
|
|
22
22
|
rule: "use 'an' before an abbreviated term beginning with a vowel sound ('an ISO standard', 'an XML file')",
|
|
23
23
|
source: :house_style, mn_category: :style
|
|
24
24
|
|
|
25
|
+
# Consonant-letter-name initialisms (PDF "pee", JPG "jay",
|
|
26
|
+
# GPS "jee", UN "you") take "a" and are NOT listed; the list
|
|
27
|
+
# is strictly vowel-letter-name initialisms.
|
|
25
28
|
LETTER_PRONOUNCED = %w[
|
|
26
|
-
GPS UN URN ERP HR SQL API ISO HTML XML RGB RPG SAP
|
|
27
|
-
|
|
29
|
+
GPS UN URN ERP HR SQL API ISO HTML XML RGB RPG SAP
|
|
30
|
+
RPM RSA SLA UML URL
|
|
28
31
|
].freeze
|
|
29
32
|
|
|
30
33
|
A_ARTICLE_REGEX =
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
policy category: "Document structure",
|
|
16
16
|
rule: "no clause or annex without content beyond its title; note-only clauses are forbidden",
|
|
17
17
|
source: :house_style, mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
# Attribute names whose presence makes a clause non-empty.
|
|
20
24
|
# Layout-only children (pagebreak, bookmark, columnbreak,
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
rule: "subcommittee subdivisions use subtypes SC, JSC",
|
|
16
16
|
source: :directives, directives: "12.5.2",
|
|
17
17
|
mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
ALLOWED_SUBTYPES = %w[SC JSC].freeze
|
|
20
24
|
|
|
@@ -14,6 +14,10 @@ module Metanorma
|
|
|
14
14
|
rule: "subpart numbering is valid only on IEC documents",
|
|
15
15
|
source: :directives, directives: "11.4",
|
|
16
16
|
mn_category: :structure
|
|
17
|
+
# Amendments and technical corrigenda are not freestanding
|
|
18
|
+
# standards; the full-standard structure contract does not
|
|
19
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
20
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
17
21
|
|
|
18
22
|
SUBPART_PATTERN = /-\d+-\d+/.freeze
|
|
19
23
|
|
|
@@ -14,6 +14,10 @@ module Metanorma
|
|
|
14
14
|
rule: "a Symbols and Abbreviated Terms section may only contain a definition list",
|
|
15
15
|
source: :directives, directives: "17.5",
|
|
16
16
|
mn_category: :structure
|
|
17
|
+
# Amendments and technical corrigenda are not freestanding
|
|
18
|
+
# standards; the full-standard structure contract does not
|
|
19
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
20
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
17
21
|
|
|
18
22
|
def applicable?(context)
|
|
19
23
|
!context.root.nil?
|
|
@@ -13,6 +13,10 @@ module Metanorma
|
|
|
13
13
|
rule: "at most one Symbols and Abbreviated Terms section (vocabulary documents excepted)",
|
|
14
14
|
source: :directives, directives: "17",
|
|
15
15
|
mn_category: :structure
|
|
16
|
+
# Amendments and technical corrigenda are not freestanding
|
|
17
|
+
# standards; the full-standard structure contract does not
|
|
18
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
19
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
16
20
|
|
|
17
21
|
def applicable?(context)
|
|
18
22
|
!context.root.nil?
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
rule: "technical committee subdivisions use subtypes TC, PC, JTC, JPC",
|
|
16
16
|
source: :directives, directives: "12.5.2",
|
|
17
17
|
mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
ALLOWED_SUBTYPES = %w[TC PC JTC JPC].freeze
|
|
20
24
|
|
|
@@ -37,6 +37,10 @@ module Metanorma
|
|
|
37
37
|
rule: "a definition must not start with an article or end with a full stop",
|
|
38
38
|
source: :directives, directives: "16.5.6",
|
|
39
39
|
mn_category: :style
|
|
40
|
+
# Amendments and technical corrigenda are not freestanding
|
|
41
|
+
# standards; the full-standard structure contract does not
|
|
42
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
43
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
40
44
|
|
|
41
45
|
ARTICLE_REGEX = /\A(the|a)\b/i.freeze
|
|
42
46
|
PERIOD_REGEX = /\.\Z/.freeze
|
|
@@ -13,6 +13,10 @@ module Metanorma
|
|
|
13
13
|
rule: "the document must contain a Terms and definitions clause",
|
|
14
14
|
source: :directives, directives: "16.3",
|
|
15
15
|
mn_category: :structure
|
|
16
|
+
# Amendments and technical corrigenda are not freestanding
|
|
17
|
+
# standards; the full-standard structure contract does not
|
|
18
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
19
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
16
20
|
|
|
17
21
|
def applicable?(context)
|
|
18
22
|
!context.root.nil? && !context.state.amd
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
rule: "every first-level subclause must have a title",
|
|
16
16
|
source: :directives, directives: "22.2",
|
|
17
17
|
mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
def applicable?(context)
|
|
20
24
|
!context.root.nil?
|
|
@@ -17,6 +17,10 @@ module Metanorma
|
|
|
17
17
|
rule: "titles must not name the document type",
|
|
18
18
|
source: :directives, directives: "11.5.2",
|
|
19
19
|
mn_category: :structure
|
|
20
|
+
# Amendments and technical corrigenda are not freestanding
|
|
21
|
+
# standards; the full-standard structure contract does not
|
|
22
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
23
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
20
24
|
|
|
21
25
|
DOCTYPE_WORDS_REGEX = /International\sStandard | Technical\sSpecification |
|
|
22
26
|
Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi.freeze
|
|
@@ -24,6 +24,10 @@ module Metanorma
|
|
|
24
24
|
rule: "EN and FR title components must be symmetric",
|
|
25
25
|
source: :directives, directives: "11",
|
|
26
26
|
mn_category: :structure
|
|
27
|
+
# Amendments and technical corrigenda are not freestanding
|
|
28
|
+
# standards; the full-standard structure contract does not
|
|
29
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
30
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
27
31
|
|
|
28
32
|
COMPONENTS = %w[title-intro title-main title-part].freeze
|
|
29
33
|
MISSING_CODE_BY_COMPONENT_AND_LANG = {
|
|
@@ -15,6 +15,10 @@ module Metanorma
|
|
|
15
15
|
rule: "sibling subclauses must be uniformly titled or uniformly untitled",
|
|
16
16
|
source: :directives, directives: "22.2",
|
|
17
17
|
mn_category: :structure
|
|
18
|
+
# Amendments and technical corrigenda are not freestanding
|
|
19
|
+
# standards; the full-standard structure contract does not
|
|
20
|
+
# apply to them (metanorma/metanorma-pdfa#130).
|
|
21
|
+
exempt_doctypes "amendment", "technical-corrigendum"
|
|
18
22
|
|
|
19
23
|
def applicable?(context)
|
|
20
24
|
!context.root.nil?
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# One-shot migration: the three logo hashes (logos_light / logos_dark /
|
|
4
|
+
# header_logos) become the logo records collection + slot declarations.
|
|
5
|
+
# Run from the repo root: ruby script/migrate-logo-records.rb
|
|
6
|
+
|
|
7
|
+
require "yaml"
|
|
8
|
+
|
|
9
|
+
root = "lib/metanorma/iso/themes"
|
|
10
|
+
|
|
11
|
+
Dir.children(root).sort.each do |e|
|
|
12
|
+
path = File.join(root, e)
|
|
13
|
+
yaml_path = if File.directory?(path)
|
|
14
|
+
File.join(path, "theme.yaml")
|
|
15
|
+
elsif e.end_with?(".yaml")
|
|
16
|
+
path
|
|
17
|
+
end
|
|
18
|
+
next unless yaml_path && File.file?(yaml_path)
|
|
19
|
+
|
|
20
|
+
text = File.read(yaml_path)
|
|
21
|
+
cfg = YAML.safe_load_file(yaml_path, aliases: false)
|
|
22
|
+
|
|
23
|
+
records = []
|
|
24
|
+
(cfg["logos_light"] || {}).each do |p, f|
|
|
25
|
+
records << { "publisher" => p, "use" => "cover", "style" => "color-light", "file" => f }
|
|
26
|
+
end
|
|
27
|
+
(cfg["logos_dark"] || {}).each do |p, f|
|
|
28
|
+
records << { "publisher" => p, "use" => "cover", "style" => "color-dark", "file" => f }
|
|
29
|
+
end
|
|
30
|
+
(cfg["header_logos"] || {}).each do |p, f|
|
|
31
|
+
records << { "publisher" => p, "use" => "header", "style" => "color-light", "file" => f }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
slots = []
|
|
35
|
+
records.select { |r| r["use"] == "cover" }.map { |r| r["style"] }.uniq.each do |s|
|
|
36
|
+
slots << { "slot" => "cover", "use" => "cover", "style" => s }
|
|
37
|
+
end
|
|
38
|
+
records.select { |r| r["use"] == "header" }.map { |r| r["style"] }.uniq.each do |s|
|
|
39
|
+
slots << { "slot" => "header", "use" => "header", "style" => s }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
had_keys = %w[logos_light logos_dark header_logos].any? do |k|
|
|
43
|
+
text.match?(/^#{k}:/)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
block = String.new
|
|
47
|
+
if records.empty?
|
|
48
|
+
if cfg["extends"] && had_keys
|
|
49
|
+
# Explicit child cut: the extending theme replaces the parent's
|
|
50
|
+
# records with its own empty set, as the empty hash maps did.
|
|
51
|
+
block << "logos: []\n"
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
block << "logos:\n"
|
|
55
|
+
records.each do |r|
|
|
56
|
+
block << "- publisher: #{r['publisher']}\n"
|
|
57
|
+
block << " use: #{r['use']}\n"
|
|
58
|
+
block << " style: #{r['style']}\n"
|
|
59
|
+
block << " lang: #{r['lang']}\n" if r["lang"]
|
|
60
|
+
block << " file: #{r['file']}\n"
|
|
61
|
+
end
|
|
62
|
+
block << "logo_slots:\n"
|
|
63
|
+
slots.each do |s|
|
|
64
|
+
block << "- slot: #{s['slot']}\n"
|
|
65
|
+
block << " use: #{s['use']}\n"
|
|
66
|
+
block << " style: #{s['style']}\n"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
next if !had_keys && block.empty?
|
|
71
|
+
|
|
72
|
+
%w[logos_light logos_dark header_logos].each do |k|
|
|
73
|
+
text = text.sub(/^#{k}: \{\}\n/, "")
|
|
74
|
+
text = text.sub(/^#{k}:\n(?:[ \t]+.*\n)*/, "")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if block.empty?
|
|
78
|
+
File.write(yaml_path, text)
|
|
79
|
+
puts "stripped: #{yaml_path}"
|
|
80
|
+
else
|
|
81
|
+
new_text =
|
|
82
|
+
if text.match?(/^publisher_name:.*\n/)
|
|
83
|
+
text.sub(/^(publisher_name:.*\n)/) { Regexp.last_match(1) + block }
|
|
84
|
+
elsif text.match?(/^publishers:\n(?:[ \t-]+.*\n)*/)
|
|
85
|
+
text.sub(/^(publishers:\n(?:[ \t-]+.*\n)*)/) { Regexp.last_match(1) + block }
|
|
86
|
+
else
|
|
87
|
+
raise "no publisher anchor in #{yaml_path}"
|
|
88
|
+
end
|
|
89
|
+
File.write(yaml_path, new_text)
|
|
90
|
+
puts "migrated: #{yaml_path}"
|
|
91
|
+
end
|
|
92
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-iso
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.5.
|
|
4
|
+
version: 3.5.39
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: isodoc
|
|
@@ -515,6 +515,7 @@ files:
|
|
|
515
515
|
- docs/validation-baselines.md
|
|
516
516
|
- docs/validation-rule-kinds.md
|
|
517
517
|
- docs/validation-suppression-authoring.md
|
|
518
|
+
- docs/validation.md
|
|
518
519
|
- exe/metanorma-iso-validate
|
|
519
520
|
- lib/html2doc/lists.rb
|
|
520
521
|
- lib/isodoc/iso/base_convert.rb
|
|
@@ -987,6 +988,7 @@ files:
|
|
|
987
988
|
- lib/metanorma/requirements/requirements.rb
|
|
988
989
|
- lib/tasks/docx_parity.rake
|
|
989
990
|
- metanorma-iso.gemspec
|
|
991
|
+
- script/migrate-logo-records.rb
|
|
990
992
|
- scripts/migrate-flavor-document-model.sh
|
|
991
993
|
- scripts/rice-sts-demo
|
|
992
994
|
- tasks/sts_golden.rake
|