metanorma-ietf 3.7.19 → 3.7.20
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/lib/metanorma/ietf/attributes_table.rb +99 -0
- data/lib/metanorma/ietf/front.rb +15 -1
- data/lib/metanorma/ietf/grammar_enums.rb +107 -0
- data/lib/metanorma/ietf/log.rb +7 -0
- data/lib/metanorma/ietf/processor.rb +19 -1
- data/lib/metanorma/ietf/transformer/block_transformer.rb +21 -0
- data/lib/metanorma/ietf/transformer/figure_transformer.rb +6 -0
- data/lib/metanorma/ietf/transformer/inline_transformer.rb +10 -5
- data/lib/metanorma/ietf/transformer/model_validation.rb +6 -1
- data/lib/metanorma/ietf/transformer/term_transformer.rb +13 -5
- data/lib/metanorma/ietf/validate.rb +4 -0
- data/lib/metanorma/ietf/version.rb +1 -1
- data/lib/metanorma/ietf.rb +2 -0
- data/tools/generate_attributes_table.rb +80 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01a29754c24fe3e73f52d13534abcda9fb4c7b6a7f9664dbc9f35ebe1ecd6f78
|
|
4
|
+
data.tar.gz: d2fc3c04bfe7b898575c090544547bf724b38842bb9c0cef7f642307268f7250
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d87c39b7f5fcdd2568ebed6f06f3f31694fc5302ea632659d07e1f286c944c92269a2f7d8ac2697529229b622124234d2ae0c13ef31e401e5401bec15fc9bc17
|
|
7
|
+
data.tar.gz: 1cb9b4c0198cc325598c77dc939836af3953f4ae91a95f87c1ada0eedb6b576cd517ae8066149b19e61e7c6f4e9a1ea1949baa0a14233dbefc56740c2877b48d
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Ietf
|
|
5
|
+
# The flavor's document-attribute interface. Asciidoctor downcases
|
|
6
|
+
# attribute names, so the RFC-XML-world spellings and the
|
|
7
|
+
# hyphenated spellings both land in the document attribute set;
|
|
8
|
+
# the alias groups below are the accepted spellings per canonical
|
|
9
|
+
# attribute, and `scan` flags declared attributes that look like a
|
|
10
|
+
# misspelling of one of them. This replaces the raw pipe of
|
|
11
|
+
# hard-coded spellings that silently dropped declarations (#348).
|
|
12
|
+
# The value enums live in GrammarEnums, generated from the bundled
|
|
13
|
+
# grammar; this table is hand-maintained.
|
|
14
|
+
module AttributesTable
|
|
15
|
+
# canonical attribute => every accepted spelling (downcased;
|
|
16
|
+
# the canonical name comes first and is the citation form)
|
|
17
|
+
ALIASES = {
|
|
18
|
+
"submission-type" => %w(submission-type submissiontype),
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
# the flavor-owned attributes the near-miss scan guards; the
|
|
22
|
+
# author-line family (author, firstname, middlename, lastname,
|
|
23
|
+
# authorinitials, email, authorcount, plus their _N siblings)
|
|
24
|
+
# and the RFC 7749 carryovers read as PI settings are known
|
|
25
|
+
# spellings too, and are matched structurally in `scan`
|
|
26
|
+
CANONICAL = (%w[
|
|
27
|
+
abbrev area asciititle author authorcount authorinitials
|
|
28
|
+
background consensus derived-from doctitle docnumber
|
|
29
|
+
firstname intended-series ipr ipr-extract lastname middlename
|
|
30
|
+
show-on-front-page submission-type workgroup
|
|
31
|
+
] + ALIASES.values.flatten).uniq.sort.freeze
|
|
32
|
+
|
|
33
|
+
# every guarded spelling => its canonical citation form
|
|
34
|
+
CANONICAL_BY_SPELLING = CANONICAL.to_h do |s|
|
|
35
|
+
[s, (ALIASES.find { |_, spellings| spellings.include?(s) } || [s]).first]
|
|
36
|
+
end.freeze
|
|
37
|
+
|
|
38
|
+
AUTHOR_LINE_RE = /\A(author(?:initials)?|email|firstname|lastname|middlename)(_\d+)?\z/.freeze
|
|
39
|
+
# asciidoctor's own plural forms of the author-line attributes
|
|
40
|
+
ASCIIDOCTOR_INTRINSICS = %w(authors).freeze
|
|
41
|
+
PI_SETTINGS = %w[
|
|
42
|
+
artworkdelimiter artworklines autobreaks background colonspace
|
|
43
|
+
comments compact editing emoticonic footer header inline
|
|
44
|
+
linkmailto notedraftinprogress private refparent rfcedstyle
|
|
45
|
+
slides sort-refs sym-refs text-list-symbols tocappendix
|
|
46
|
+
tocindent tocnarrow tocompact tocdepth toc-include useobject
|
|
47
|
+
].freeze
|
|
48
|
+
|
|
49
|
+
module_function
|
|
50
|
+
|
|
51
|
+
# the declared value of a canonical attribute, trying every
|
|
52
|
+
# accepted spelling
|
|
53
|
+
def resolve(node, canonical)
|
|
54
|
+
spelling = (ALIASES[canonical] || [canonical])
|
|
55
|
+
.find { |s| node.attr(s) }
|
|
56
|
+
spelling && node.attr(spelling)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# declared attribute spellings that look like a misspelling of a
|
|
60
|
+
# guarded canonical, as [declared, canonical] pairs
|
|
61
|
+
def scan(node)
|
|
62
|
+
node.attributes.keys.filter_map do |declared|
|
|
63
|
+
key = declared.downcase
|
|
64
|
+
next if known_spelling?(key)
|
|
65
|
+
spelling = CANONICAL_BY_SPELLING.keys.find do |s|
|
|
66
|
+
distance(key, s) <= NEAR_MISS_RADIUS
|
|
67
|
+
end
|
|
68
|
+
spelling && [declared, CANONICAL_BY_SPELLING[spelling]]
|
|
69
|
+
end.sort
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# the near-miss radius: one edit. A radius of two collides with
|
|
73
|
+
# asciidoctor's intrinsic attributes (doctime vs doctitle) that
|
|
74
|
+
# every document carries
|
|
75
|
+
NEAR_MISS_RADIUS = 1
|
|
76
|
+
|
|
77
|
+
def known_spelling?(key)
|
|
78
|
+
CANONICAL.include?(key) || AUTHOR_LINE_RE.match?(key) ||
|
|
79
|
+
PI_SETTINGS.include?(key) || ASCIIDOCTOR_INTRINSICS.include?(key)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# classic Levenshtein distance, small enough for attribute names
|
|
83
|
+
def distance(a, b)
|
|
84
|
+
row = (0..b.length).to_a
|
|
85
|
+
a.each_char.with_index(1) do |ca, i|
|
|
86
|
+
prev = row[0]
|
|
87
|
+
row[0] = i
|
|
88
|
+
b.each_char.with_index(1) do |cb, j|
|
|
89
|
+
cur = row[j]
|
|
90
|
+
row[j] = [row[j] + 1, row[j - 1] + 1,
|
|
91
|
+
prev + (ca == cb ? 0 : 1)].min
|
|
92
|
+
prev = cur
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
row[-1]
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
data/lib/metanorma/ietf/front.rb
CHANGED
|
@@ -69,6 +69,7 @@ module Metanorma
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def metadata_series(node, xml)
|
|
72
|
+
scan_declared_attributes(node)
|
|
72
73
|
xml.series **{ type: "stream" } do |s|
|
|
73
74
|
# Asciidoctor downcases attribute names: :submissionType: lands
|
|
74
75
|
# as "submissiontype", :submission-type: as "submission-type";
|
|
@@ -84,7 +85,20 @@ module Metanorma
|
|
|
84
85
|
end
|
|
85
86
|
|
|
86
87
|
def submission_type_attr(node)
|
|
87
|
-
|
|
88
|
+
AttributesTable.resolve(node, "submission-type")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Declared attributes that look like a misspelling of a flavor
|
|
92
|
+
# attribute surface here instead of being dropped silently (the
|
|
93
|
+
# raw-attribute pipe that caused metanorma-ietf#348); runs once
|
|
94
|
+
# per compile
|
|
95
|
+
def scan_declared_attributes(node)
|
|
96
|
+
@attribute_scan_done and return
|
|
97
|
+
@attribute_scan_done = true
|
|
98
|
+
return unless @log
|
|
99
|
+
AttributesTable.scan(node).each do |declared, canonical|
|
|
100
|
+
@log.add("IETF_22", nil, params: [declared, canonical])
|
|
101
|
+
end
|
|
88
102
|
end
|
|
89
103
|
|
|
90
104
|
def title_fallback(node, xml)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# GENERATED FILE: rendered from the bundled RFC XML grammar
|
|
4
|
+
# (lib/metanorma/ietf/schema/v3.rng) by
|
|
5
|
+
# `rake attributes:generate`; do not edit. Every element
|
|
6
|
+
# attribute whose grammar definition carries an explicit
|
|
7
|
+
# choice of values. The grammar is kept in sync with
|
|
8
|
+
# xml2rfc's by the guards:schema_sync CI job.
|
|
9
|
+
module Metanorma
|
|
10
|
+
module Ietf
|
|
11
|
+
module GrammarEnums
|
|
12
|
+
ENUMS = {
|
|
13
|
+
"artwork" => {
|
|
14
|
+
"align" => ["center", "left", "right"],
|
|
15
|
+
},
|
|
16
|
+
"cref" => {
|
|
17
|
+
"display" => ["false", "true"],
|
|
18
|
+
},
|
|
19
|
+
"dl" => {
|
|
20
|
+
"newline" => ["false", "true"],
|
|
21
|
+
"spacing" => ["compact", "normal"],
|
|
22
|
+
},
|
|
23
|
+
"eref" => {
|
|
24
|
+
"brackets" => ["angle", "none"],
|
|
25
|
+
},
|
|
26
|
+
"figure" => {
|
|
27
|
+
"align" => ["center", "left", "right"],
|
|
28
|
+
"suppress-title" => ["false", "true"],
|
|
29
|
+
},
|
|
30
|
+
"iref" => {
|
|
31
|
+
"primary" => ["false", "true"],
|
|
32
|
+
},
|
|
33
|
+
"note" => {
|
|
34
|
+
"removeInRFC" => ["false", "true"],
|
|
35
|
+
},
|
|
36
|
+
"ol" => {
|
|
37
|
+
"indent" => ["adaptive"],
|
|
38
|
+
"spacing" => ["compact", "normal"],
|
|
39
|
+
},
|
|
40
|
+
"organization" => {
|
|
41
|
+
"showOnFrontPage" => ["false", "true"],
|
|
42
|
+
},
|
|
43
|
+
"reference" => {
|
|
44
|
+
"quote-title" => ["false", "true"],
|
|
45
|
+
"quoteTitle" => ["false", "true"],
|
|
46
|
+
},
|
|
47
|
+
"relref" => {
|
|
48
|
+
"displayFormat" => ["bare", "comma", "of", "parens"],
|
|
49
|
+
},
|
|
50
|
+
"rfc" => {
|
|
51
|
+
"category" => ["bcp", "exp", "historic", "info", "std"],
|
|
52
|
+
"consensus" => ["false", "no", "true", "yes"],
|
|
53
|
+
"indexInclude" => ["false", "true"],
|
|
54
|
+
"sortRefs" => ["false", "true"],
|
|
55
|
+
"submissionType" => ["IAB", "IETF", "IRTF", "editorial", "independent"],
|
|
56
|
+
"symRefs" => ["false", "true"],
|
|
57
|
+
"tocInclude" => ["false", "true"],
|
|
58
|
+
},
|
|
59
|
+
"section" => {
|
|
60
|
+
"numbered" => ["false", "true"],
|
|
61
|
+
"removeInRFC" => ["false", "true"],
|
|
62
|
+
"toc" => ["default", "exclude", "include"],
|
|
63
|
+
},
|
|
64
|
+
"seriesInfo" => {
|
|
65
|
+
"stream" => ["IAB", "IETF", "IRTF", "editorial", "independent"],
|
|
66
|
+
},
|
|
67
|
+
"sourcecode" => {
|
|
68
|
+
"markers" => ["false", "true"],
|
|
69
|
+
},
|
|
70
|
+
"spanx" => {
|
|
71
|
+
"xml:space" => ["default", "preserve"],
|
|
72
|
+
},
|
|
73
|
+
"t" => {
|
|
74
|
+
"keepWithNext" => ["false", "true"],
|
|
75
|
+
"keepWithPrevious" => ["false", "true"],
|
|
76
|
+
},
|
|
77
|
+
"table" => {
|
|
78
|
+
"align" => ["center", "left", "right"],
|
|
79
|
+
},
|
|
80
|
+
"td" => {
|
|
81
|
+
"align" => ["center", "left", "right"],
|
|
82
|
+
},
|
|
83
|
+
"texttable" => {
|
|
84
|
+
"align" => ["center", "left", "right"],
|
|
85
|
+
"style" => ["all", "full", "headers", "none"],
|
|
86
|
+
"suppress-title" => ["false", "true"],
|
|
87
|
+
},
|
|
88
|
+
"th" => {
|
|
89
|
+
"align" => ["center", "left", "right"],
|
|
90
|
+
},
|
|
91
|
+
"ttcol" => {
|
|
92
|
+
"align" => ["center", "left", "right"],
|
|
93
|
+
},
|
|
94
|
+
"ul" => {
|
|
95
|
+
"bare" => ["false", "true"],
|
|
96
|
+
"empty" => ["false", "true"],
|
|
97
|
+
"spacing" => ["compact", "normal"],
|
|
98
|
+
},
|
|
99
|
+
"xref" => {
|
|
100
|
+
"format" => ["counter", "default", "none", "title"],
|
|
101
|
+
"pageno" => ["false", "true"],
|
|
102
|
+
"sectionFormat" => ["bare", "comma", "of", "parens"],
|
|
103
|
+
},
|
|
104
|
+
}.freeze
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
data/lib/metanorma/ietf/log.rb
CHANGED
|
@@ -96,6 +96,13 @@ module Metanorma
|
|
|
96
96
|
"xml2rfc's text output does not align; use " \
|
|
97
97
|
"spaces",
|
|
98
98
|
severity: 2 },
|
|
99
|
+
"IETF_22": { category: "Document Attributes",
|
|
100
|
+
error: "unknown document attribute :%s: (did you " \
|
|
101
|
+
"mean :%s:?)",
|
|
102
|
+
severity: 2 },
|
|
103
|
+
"IETF_23": { category: "RFC XML text output",
|
|
104
|
+
error: "xml2rfc preptool warning: %s",
|
|
105
|
+
severity: 2 },
|
|
99
106
|
"IETF_21": { category: "RFC XML submission",
|
|
100
107
|
error: "The IETF submission check expects the " \
|
|
101
108
|
"submitted file to be named %s.xml; rename the " \
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "metanorma/processor"
|
|
2
|
+
require "open3"
|
|
2
3
|
require "tempfile"
|
|
3
4
|
require "fileutils"
|
|
4
5
|
require_relative "transformer"
|
|
@@ -139,7 +140,24 @@ module Metanorma
|
|
|
139
140
|
outflag = { txt: "--text", pdf: "--pdf", html: "--html" }[format]
|
|
140
141
|
|
|
141
142
|
outname ||= inname.sub(/\.xml$/, outext)
|
|
142
|
-
|
|
143
|
+
_out, err, status = Open3.capture3("xml2rfc", outflag, rfcname,
|
|
144
|
+
"-o", outname)
|
|
145
|
+
warn err unless err.empty?
|
|
146
|
+
record_preptool_warnings(err, rfcname)
|
|
147
|
+
status.success?
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# xml2rfc's preptool runs its 5.4.x submission checklist on every
|
|
151
|
+
# txt/pdf/html rendering and prints warnings; the raw pass-through
|
|
152
|
+
# stays on stderr, and the findings also land in the flavor log so
|
|
153
|
+
# the validation report stops being silent about the reference
|
|
154
|
+
# toolchain's opinion (metanorma-ietf#366)
|
|
155
|
+
def record_preptool_warnings(err, rfcname)
|
|
156
|
+
return unless @rfc_validator
|
|
157
|
+
err.scan(/warning:\s*(.+)$/i).each do |(msg)|
|
|
158
|
+
@rfc_validator.record_preptool_warning(msg.strip)
|
|
159
|
+
end
|
|
160
|
+
@rfc_validator.write(rfcname) if @rfc_validator.entries?
|
|
143
161
|
end
|
|
144
162
|
end
|
|
145
163
|
end
|
|
@@ -124,6 +124,23 @@ module Metanorma
|
|
|
124
124
|
text_elem.content = content_fragments
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
+
# RFC XML v3 has no stacked-reference construct: render each
|
|
128
|
+
# child citation through the single-eref path, joined by the
|
|
129
|
+
# authored connectives (custom over named) or a comma (#304;
|
|
130
|
+
# the released leg dropped the whole stack)
|
|
131
|
+
def build_eref_stack(stack)
|
|
132
|
+
refs = stack.eref.to_a
|
|
133
|
+
return nil if refs.empty?
|
|
134
|
+
parts = [build_eref_xref(refs.first)]
|
|
135
|
+
refs[1..].each do |e|
|
|
136
|
+
conn = e.respond_to?(:custom_connective) &&
|
|
137
|
+
!e.custom_connective.to_s.empty? ? e.custom_connective : e.connective
|
|
138
|
+
parts << (conn.nil? || conn.to_s.empty? ? ", " : " #{conn} ")
|
|
139
|
+
parts << build_eref_xref(e)
|
|
140
|
+
end
|
|
141
|
+
parts
|
|
142
|
+
end
|
|
143
|
+
|
|
127
144
|
def build_inline_element(p_node, tag, idx)
|
|
128
145
|
# title/caption models walk through here too (#292): guard
|
|
129
146
|
# the accessor reads for vintages that don't map the tag
|
|
@@ -185,6 +202,10 @@ module Metanorma
|
|
|
185
202
|
coll = p_node.concept
|
|
186
203
|
return nil unless coll.is_a?(Array) && coll[idx]
|
|
187
204
|
build_concept(coll[idx])
|
|
205
|
+
when "erefstack"
|
|
206
|
+
coll = p_node.erefstack
|
|
207
|
+
return nil unless coll.is_a?(Array) && coll[idx]
|
|
208
|
+
build_eref_stack(coll[idx])
|
|
188
209
|
when "fn"
|
|
189
210
|
coll = p_node.fn
|
|
190
211
|
return nil unless coll.is_a?(Array) && coll[idx]
|
|
@@ -160,6 +160,12 @@ module Metanorma
|
|
|
160
160
|
sourcecode = Rfcxml::V3::Sourcecode.new
|
|
161
161
|
anchor_for(figure_node) and
|
|
162
162
|
sourcecode.anchor = to_ncname(anchor_for(figure_node))
|
|
163
|
+
# the caption travels with the pseudocode as flat text
|
|
164
|
+
# (#303: the old bare sourcecode dropped the figure's name;
|
|
165
|
+
# sourcecode/name is a string attribute, unlike figure/name)
|
|
166
|
+
cap = ls_text(figure_node.name)
|
|
167
|
+
cap = cap.tr("\u00A0", " ") if cap
|
|
168
|
+
sourcecode.name = cap if cap && !cap.strip.empty?
|
|
163
169
|
sourcecode.content = [lines.join("\n")]
|
|
164
170
|
sourcecode
|
|
165
171
|
end
|
|
@@ -7,11 +7,16 @@ module Metanorma
|
|
|
7
7
|
|
|
8
8
|
def extract_paragraph_text(paragraph)
|
|
9
9
|
text = paragraph.text
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
joined = text.is_a?(Array) ? text.join : text.to_s
|
|
11
|
+
# markup-carrying paragraphs hold their content in element
|
|
12
|
+
# children; the text runs carry only the whitespace between
|
|
13
|
+
# them (#303 - pseudocode paragraphs rendered empty). The
|
|
14
|
+
# presentation stage pads those runs with no-break spaces,
|
|
15
|
+
# which ASCII strip treats as content
|
|
16
|
+
return joined unless joined.gsub(/[[:space:]\u00A0]/, "").empty?
|
|
17
|
+
return "" unless paragraph.respond_to?(:each_mixed_content)
|
|
18
|
+
|
|
19
|
+
mixed_text(paragraph).tr("\u00A0", " ")
|
|
15
20
|
end
|
|
16
21
|
|
|
17
22
|
def build_eref_xref(elem)
|
|
@@ -11,7 +11,12 @@ module Metanorma
|
|
|
11
11
|
# findings; they are returned as catalog-id/params pairs for
|
|
12
12
|
# Validate to record through the metanorma log.
|
|
13
13
|
module ModelValidation
|
|
14
|
-
|
|
14
|
+
# the grammar is the SSOT for the stream enum (generated into
|
|
15
|
+
# GrammarEnums by rake attributes:generate, synced with
|
|
16
|
+
# xml2rfc's grammar by the guards:schema_sync CI job)
|
|
17
|
+
RFC7841_STREAMS =
|
|
18
|
+
Metanorma::Ietf::GrammarEnums::ENUMS.dig("rfc", "submissionType")
|
|
19
|
+
.freeze
|
|
15
20
|
|
|
16
21
|
# RFC 7841 s2: the category each stream may carry; source of
|
|
17
22
|
# truth is the xml2rfc boilerplate_rfc_7841.py
|
|
@@ -285,12 +285,20 @@ module Metanorma
|
|
|
285
285
|
# (#300): the released path did not gate it on "modified"
|
|
286
286
|
mod = model_attr(source, :modification)
|
|
287
287
|
if mod
|
|
288
|
-
# mixed_text: the modification
|
|
289
|
-
#
|
|
290
|
-
|
|
291
|
-
if
|
|
292
|
-
|
|
288
|
+
# mixed_text: the modification carries its text in
|
|
289
|
+
# paragraphs (SourceModification maps p); the wrapper
|
|
290
|
+
# model's own text runs are empty (#300)
|
|
291
|
+
mod_text = if mod.respond_to?(:p) && mod.p.to_a.any?
|
|
292
|
+
mod.p.to_a.filter_map { |para|
|
|
293
|
+
mt = mixed_text(para)
|
|
294
|
+
mt unless mt.to_s.empty?
|
|
295
|
+
}.join(" ")
|
|
296
|
+
else
|
|
297
|
+
mt = mixed_text(mod)
|
|
298
|
+
mt.to_s.empty? ? nil : mt
|
|
293
299
|
end
|
|
300
|
+
append_text.call(" \u2014 #{mod_text}") if mod_text &&
|
|
301
|
+
!mod_text.empty?
|
|
294
302
|
end
|
|
295
303
|
end
|
|
296
304
|
|
|
@@ -77,6 +77,10 @@ module Metanorma
|
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
def record_preptool_warning(msg)
|
|
81
|
+
@log.add("IETF_23", nil, params: [msg])
|
|
82
|
+
end
|
|
83
|
+
|
|
80
84
|
# idnits3 FILENAME_DOCNAME_MISMATCH / FILENAME_TOO_MANY_DOTS
|
|
81
85
|
# apply to the submitted file, which Datatracker requires to be
|
|
82
86
|
# named after the draft; our build artifact keeps the source
|
data/lib/metanorma/ietf.rb
CHANGED
|
@@ -4,6 +4,8 @@ require_relative "ietf/version"
|
|
|
4
4
|
|
|
5
5
|
module Metanorma
|
|
6
6
|
module Ietf
|
|
7
|
+
autoload :AttributesTable, "metanorma/ietf/attributes_table"
|
|
8
|
+
autoload :GrammarEnums, "metanorma/ietf/grammar_enums"
|
|
7
9
|
autoload :Transformer, "metanorma/ietf/transformer"
|
|
8
10
|
|
|
9
11
|
RFC2629DTD_URL = "https://raw.githubusercontent.com/metanorma/metanorma-ietf/master/rfc2629.dtd"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Regenerates lib/metanorma/ietf/grammar_enums.rb from the bundled
|
|
4
|
+
# grammar (lib/metanorma/ietf/schema/v3.rng): every element attribute
|
|
5
|
+
# whose grammar definition carries an explicit choice of values. The
|
|
6
|
+
# grammar is the SSOT for the value enums (kept in sync with xml2rfc's
|
|
7
|
+
# by the guards:schema_sync CI job); this table is the interface the
|
|
8
|
+
# rest of the flavor reads them through.
|
|
9
|
+
#
|
|
10
|
+
# rake attributes:generate
|
|
11
|
+
|
|
12
|
+
require "nokogiri"
|
|
13
|
+
|
|
14
|
+
module Metanorma
|
|
15
|
+
module Ietf
|
|
16
|
+
module Tools
|
|
17
|
+
module GenerateAttributesTable
|
|
18
|
+
GRAMMAR = File.join(__dir__, "..", "lib", "metanorma", "ietf",
|
|
19
|
+
"schema", "v3.rng")
|
|
20
|
+
OUT = File.join(__dir__, "..", "lib", "metanorma", "ietf",
|
|
21
|
+
"grammar_enums.rb")
|
|
22
|
+
|
|
23
|
+
module_function
|
|
24
|
+
|
|
25
|
+
def run
|
|
26
|
+
doc = Nokogiri::XML(File.read(GRAMMAR))
|
|
27
|
+
enums = {}
|
|
28
|
+
doc.xpath("//gg:define", "gg" => "http://relaxng.org/ns/structure/1.0")
|
|
29
|
+
.each do |define|
|
|
30
|
+
elem = define.at_xpath("./gg:element", "gg" => "http://relaxng.org/ns/structure/1.0")
|
|
31
|
+
elem_name = elem&.[]("name") or next
|
|
32
|
+
elem.xpath(".//gg:attribute", "gg" => "http://relaxng.org/ns/structure/1.0")
|
|
33
|
+
.each do |attr|
|
|
34
|
+
attr_name = attr["name"] or next
|
|
35
|
+
values = attr.xpath(".//gg:choice/gg:value",
|
|
36
|
+
"gg" => "http://relaxng.org/ns/structure/1.0")
|
|
37
|
+
.map(&:text)
|
|
38
|
+
next if values.empty?
|
|
39
|
+
(enums[elem_name] ||= {})[attr_name] = values.sort
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
File.write(OUT, render(enums))
|
|
43
|
+
puts "grammar_enums.rb: #{enums.sum { |_, v| v.size }} enums " \
|
|
44
|
+
"from #{GRAMMAR}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def render(enums)
|
|
48
|
+
body = enums.sort.map do |elem, attrs|
|
|
49
|
+
lines = attrs.sort.map do |attr, values|
|
|
50
|
+
vals = values.map { |v| v.inspect }.join(", ")
|
|
51
|
+
" #{attr.inspect} => [#{vals}],"
|
|
52
|
+
end
|
|
53
|
+
" #{elem.inspect} => {\n#{lines.join("\n")}\n },"
|
|
54
|
+
end.join("\n")
|
|
55
|
+
<<~RUBY
|
|
56
|
+
# frozen_string_literal: true
|
|
57
|
+
|
|
58
|
+
# GENERATED FILE: rendered from the bundled RFC XML grammar
|
|
59
|
+
# (lib/metanorma/ietf/schema/v3.rng) by
|
|
60
|
+
# `rake attributes:generate`; do not edit. Every element
|
|
61
|
+
# attribute whose grammar definition carries an explicit
|
|
62
|
+
# choice of values. The grammar is kept in sync with
|
|
63
|
+
# xml2rfc's by the guards:schema_sync CI job.
|
|
64
|
+
module Metanorma
|
|
65
|
+
module Ietf
|
|
66
|
+
module GrammarEnums
|
|
67
|
+
ENUMS = {
|
|
68
|
+
#{body}
|
|
69
|
+
}.freeze
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
RUBY
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
Metanorma::Ietf::Tools::GenerateAttributesTable.run if $PROGRAM_NAME == __FILE__
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-ietf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.7.
|
|
4
|
+
version: 3.7.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -216,6 +216,7 @@ files:
|
|
|
216
216
|
- lib/isodoc/ietf/xref.rb
|
|
217
217
|
- lib/metanorma-ietf.rb
|
|
218
218
|
- lib/metanorma/ietf.rb
|
|
219
|
+
- lib/metanorma/ietf/attributes_table.rb
|
|
219
220
|
- lib/metanorma/ietf/basicdoc.rng
|
|
220
221
|
- lib/metanorma/ietf/biblio-standoc.rng
|
|
221
222
|
- lib/metanorma/ietf/biblio.rng
|
|
@@ -235,6 +236,7 @@ files:
|
|
|
235
236
|
- lib/metanorma/ietf/document/sections/ietf_content_section.rb
|
|
236
237
|
- lib/metanorma/ietf/document/sections/ietf_sections.rb
|
|
237
238
|
- lib/metanorma/ietf/front.rb
|
|
239
|
+
- lib/metanorma/ietf/grammar_enums.rb
|
|
238
240
|
- lib/metanorma/ietf/html.rb
|
|
239
241
|
- lib/metanorma/ietf/html/renderer.rb
|
|
240
242
|
- lib/metanorma/ietf/ietf.rng
|
|
@@ -299,6 +301,7 @@ files:
|
|
|
299
301
|
- test.pdf.err
|
|
300
302
|
- test.presentation.xml
|
|
301
303
|
- tools/compare_old_new.rb
|
|
304
|
+
- tools/generate_attributes_table.rb
|
|
302
305
|
- tools/ws5_sweep.rb
|
|
303
306
|
homepage: https://github.com/metanorma/metanorma-ietf
|
|
304
307
|
licenses:
|