metanorma-standoc 1.8.8 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -13
- data/.hound.yml +3 -1
- data/.rubocop.yml +3 -7
- data/Gemfile.devel +0 -0
- data/lib/asciidoctor/standoc/base.rb +42 -36
- data/lib/asciidoctor/standoc/biblio.rng +1 -0
- data/lib/asciidoctor/standoc/blocks.rb +25 -9
- data/lib/asciidoctor/standoc/blocks_notes.rb +41 -24
- data/lib/asciidoctor/standoc/cleanup.rb +59 -84
- data/lib/asciidoctor/standoc/cleanup_block.rb +63 -85
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +51 -29
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +1 -0
- data/lib/asciidoctor/standoc/cleanup_image.rb +71 -0
- data/lib/asciidoctor/standoc/cleanup_maths.rb +36 -27
- data/lib/asciidoctor/standoc/cleanup_ref.rb +24 -15
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +47 -0
- data/lib/asciidoctor/standoc/cleanup_section.rb +77 -134
- data/lib/asciidoctor/standoc/cleanup_section_names.rb +75 -0
- data/lib/asciidoctor/standoc/converter.rb +10 -3
- data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +67 -66
- data/lib/asciidoctor/standoc/front.rb +35 -18
- data/lib/asciidoctor/standoc/front_contributor.rb +70 -45
- data/lib/asciidoctor/standoc/inline.rb +30 -22
- data/lib/asciidoctor/standoc/isodoc.rng +321 -4
- data/lib/asciidoctor/standoc/lists.rb +4 -2
- data/lib/asciidoctor/standoc/macros.rb +50 -23
- data/lib/asciidoctor/standoc/macros_form.rb +63 -0
- data/lib/asciidoctor/standoc/ref.rb +87 -112
- data/lib/asciidoctor/standoc/ref_date_id.rb +62 -0
- data/lib/asciidoctor/standoc/ref_sect.rb +20 -17
- data/lib/asciidoctor/standoc/section.rb +3 -1
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +31 -16
- data/lib/asciidoctor/standoc/terms.rb +27 -16
- data/lib/asciidoctor/standoc/utils.rb +35 -9
- data/lib/asciidoctor/standoc/validate.rb +30 -28
- data/lib/metanorma-standoc.rb +0 -1
- data/lib/metanorma/standoc/version.rb +5 -5
- data/metanorma-standoc.gemspec +11 -11
- data/spec/asciidoctor/base_spec.rb +715 -509
- data/spec/asciidoctor/blocks_spec.rb +830 -727
- data/spec/asciidoctor/cleanup_sections_spec.rb +51 -14
- data/spec/asciidoctor/cleanup_spec.rb +1836 -1673
- data/spec/asciidoctor/inline_spec.rb +330 -283
- data/spec/asciidoctor/isobib_cache_spec.rb +406 -358
- data/spec/asciidoctor/lists_spec.rb +3 -3
- data/spec/asciidoctor/macros_plantuml_spec.rb +8 -8
- data/spec/asciidoctor/macros_spec.rb +546 -444
- data/spec/asciidoctor/macros_yaml2text_spec.rb +1 -1
- data/spec/asciidoctor/refs_dl_spec.rb +4 -4
- data/spec/asciidoctor/refs_spec.rb +1528 -1533
- data/spec/asciidoctor/section_spec.rb +778 -689
- data/spec/asciidoctor/table_spec.rb +6 -6
- data/spec/asciidoctor/validate_spec.rb +296 -304
- data/spec/spec_helper.rb +13 -9
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +66 -66
- data/spec/vcr_cassettes/isobib_get_123.yml +17 -17
- data/spec/vcr_cassettes/isobib_get_123_1.yml +31 -31
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +40 -40
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +17 -17
- data/spec/vcr_cassettes/isobib_get_124.yml +16 -16
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +78 -66
- metadata +69 -67
- data/lib/liquid/custom_blocks/key_iterator.rb +0 -21
- data/lib/liquid/custom_blocks/with_json_nested_context.rb +0 -18
- data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +0 -19
- data/lib/liquid/custom_filters/values.rb +0 -7
@@ -0,0 +1,75 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
module Cleanup
|
4
|
+
def get_or_make_title(node)
|
5
|
+
unless node.at("./title")
|
6
|
+
if node.children.empty?
|
7
|
+
node << "<title/>"
|
8
|
+
else
|
9
|
+
node.children.first.previous = "<title/>"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
node.at("./title")
|
13
|
+
end
|
14
|
+
|
15
|
+
def replace_title(doc, xpath, text, first = false)
|
16
|
+
return unless text
|
17
|
+
|
18
|
+
doc.xpath(xpath).each_with_index do |node, i|
|
19
|
+
next if first && !i.zero?
|
20
|
+
|
21
|
+
title = get_or_make_title(node)
|
22
|
+
fn = title.xpath("./fn")
|
23
|
+
fn.each(&:remove)
|
24
|
+
title.content = text
|
25
|
+
fn.each { |n| title << n }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def sections_names_cleanup(xml)
|
30
|
+
replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
|
31
|
+
replace_title(xml, "//preface//abstract", @i18n&.abstract)
|
32
|
+
replace_title(xml, "//foreword", @i18n&.foreword)
|
33
|
+
replace_title(xml, "//introduction", @i18n&.introduction)
|
34
|
+
replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
|
35
|
+
section_names_refs_cleanup(xml)
|
36
|
+
section_names_terms_cleanup(xml)
|
37
|
+
end
|
38
|
+
|
39
|
+
def section_names_refs_cleanup(xml)
|
40
|
+
replace_title(xml, "//references[@normative = 'true']",
|
41
|
+
@i18n&.normref, true)
|
42
|
+
replace_title(xml, "//references[@normative = 'false']",
|
43
|
+
@i18n&.bibliography, true)
|
44
|
+
end
|
45
|
+
|
46
|
+
NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
|
47
|
+
SYMABBR = "[.//definitions[@type = 'symbols']]"\
|
48
|
+
"[.//definitions[@type = 'abbreviated_terms']]".freeze
|
49
|
+
SYMnoABBR = "[.//definitions[@type = 'symbols']]"\
|
50
|
+
"[not(.//definitions[@type = 'abbreviated_terms'])]".freeze
|
51
|
+
ABBRnoSYM = "[.//definitions[@type = 'abbreviated_terms']]"\
|
52
|
+
"[not(.//definitions[@type = 'symbols'])]".freeze
|
53
|
+
|
54
|
+
def section_names_terms_cleanup(x)
|
55
|
+
replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
|
56
|
+
replace_title(x, "//definitions[@type = 'abbreviated_terms']",
|
57
|
+
@i18n&.abbrev)
|
58
|
+
replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
|
59
|
+
replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
|
60
|
+
@i18n&.termsdefsymbols, true)
|
61
|
+
replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
|
62
|
+
@i18n&.termsdefabbrev, true)
|
63
|
+
replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
|
64
|
+
@i18n&.termsdefsymbolsabbrev, true)
|
65
|
+
replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
|
66
|
+
@i18n&.termsdefsymbolsabbrev, true)
|
67
|
+
replace_title(
|
68
|
+
x,
|
69
|
+
"//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
|
70
|
+
@i18n&.termsdef, true
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -13,7 +13,7 @@ require "asciidoctor/standoc/validate"
|
|
13
13
|
require "asciidoctor/standoc/utils"
|
14
14
|
require "asciidoctor/standoc/cleanup"
|
15
15
|
require "asciidoctor/standoc/reqt"
|
16
|
-
require_relative "./macros
|
16
|
+
require_relative "./macros"
|
17
17
|
|
18
18
|
module Asciidoctor
|
19
19
|
module Standoc
|
@@ -39,6 +39,13 @@ module Asciidoctor
|
|
39
39
|
inline_macro Asciidoctor::Standoc::TermRefInlineMacro
|
40
40
|
inline_macro Asciidoctor::Standoc::IndexXrefInlineMacro
|
41
41
|
inline_macro Asciidoctor::Standoc::IndexRangeInlineMacro
|
42
|
+
inline_macro Asciidoctor::Standoc::AddMacro
|
43
|
+
inline_macro Asciidoctor::Standoc::DelMacro
|
44
|
+
inline_macro Asciidoctor::Standoc::FormInputMacro
|
45
|
+
inline_macro Asciidoctor::Standoc::FormLabelMacro
|
46
|
+
inline_macro Asciidoctor::Standoc::FormTextareaMacro
|
47
|
+
inline_macro Asciidoctor::Standoc::FormSelectMacro
|
48
|
+
inline_macro Asciidoctor::Standoc::FormOptionMacro
|
42
49
|
block Asciidoctor::Standoc::ToDoAdmonitionBlock
|
43
50
|
treeprocessor Asciidoctor::Standoc::ToDoInlineAdmonitionBlock
|
44
51
|
block Asciidoctor::Standoc::PlantUMLBlockMacro
|
@@ -76,8 +83,8 @@ module Asciidoctor
|
|
76
83
|
attr_accessor :_file
|
77
84
|
end
|
78
85
|
|
79
|
-
def self.inherited(
|
80
|
-
|
86
|
+
def self.inherited(konv) # rubocop:disable Lint/MissingSuper
|
87
|
+
konv._file = caller_locations(1..1).first.absolute_path
|
81
88
|
end
|
82
89
|
|
83
90
|
# path to isodoc assets in child gems
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "erb"
|
4
4
|
|
5
5
|
module Asciidoctor
|
6
6
|
module Datamodel
|
7
7
|
class PlantumlRenderer
|
8
|
-
TEMPLATES_PATH = File.expand_path(
|
8
|
+
TEMPLATES_PATH = File.expand_path("../views/datamodel", __dir__).freeze
|
9
9
|
|
10
10
|
attr_reader :yml, :plantuml_path
|
11
11
|
|
@@ -15,23 +15,23 @@ module Asciidoctor
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def join_as_plantuml(*ary)
|
18
|
-
ary.compact.join("\n").sub(/\s+\Z/,
|
18
|
+
ary.compact.join("\n").sub(/\s+\Z/, "")
|
19
19
|
end
|
20
20
|
|
21
21
|
def render
|
22
22
|
ERB.new(
|
23
23
|
File.read(
|
24
|
-
File.join(TEMPLATES_PATH,
|
24
|
+
File.join(TEMPLATES_PATH, "plantuml_representation.adoc.erb")
|
25
25
|
)
|
26
26
|
).result(binding)
|
27
27
|
end
|
28
28
|
|
29
29
|
def diagram_caption
|
30
|
-
yml[
|
30
|
+
yml["caption"]
|
31
31
|
end
|
32
32
|
|
33
33
|
def imports_yml_to_plantuml
|
34
|
-
return if empty?(yml,
|
34
|
+
return if empty?(yml, "imports")
|
35
35
|
|
36
36
|
<<~TEMPLATE
|
37
37
|
'******* IMPORTS ******************************************************
|
@@ -40,7 +40,7 @@ module Asciidoctor
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def class_defs_yml_to_plantuml
|
43
|
-
return if empty?(yml,
|
43
|
+
return if empty?(yml, "classes") && empty?(yml, "enums")
|
44
44
|
|
45
45
|
<<~TEMPLATE
|
46
46
|
'******* CLASS DEFINITIONS ********************************************
|
@@ -52,7 +52,7 @@ module Asciidoctor
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def class_groups_yml_to_plantuml
|
55
|
-
return if empty?(yml,
|
55
|
+
return if empty?(yml, "groups")
|
56
56
|
|
57
57
|
<<~TEMPLATE
|
58
58
|
'******* CLASS GROUPS *************************************************
|
@@ -63,7 +63,7 @@ module Asciidoctor
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def class_relations_yml_to_plantuml
|
66
|
-
return if empty?(yml,
|
66
|
+
return if empty?(yml, "classes") && empty?(yml, "relations")
|
67
67
|
|
68
68
|
<<~TEMPLATE
|
69
69
|
'******* CLASS RELATIONS **********************************************
|
@@ -75,7 +75,7 @@ module Asciidoctor
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def diagram_options_yml_to_plantuml
|
78
|
-
return if empty?(yml,
|
78
|
+
return if empty?(yml, "diagram_options")
|
79
79
|
|
80
80
|
<<~TEMPLATE
|
81
81
|
'******* DIAGRAM SPECIFIC CONFIG **************************************
|
@@ -86,7 +86,7 @@ module Asciidoctor
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def bottom_yml_to_plantuml
|
89
|
-
return if empty?(yml,
|
89
|
+
return if empty?(yml, "bottom")
|
90
90
|
|
91
91
|
<<~TEMPLATE
|
92
92
|
'******* BOTTOM OVERRIDE CONFIG **************************************
|
@@ -95,7 +95,7 @@ module Asciidoctor
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def fidelity_yml_to_plantuml
|
98
|
-
return if empty?(yml,
|
98
|
+
return if empty?(yml, "fidelity")
|
99
99
|
|
100
100
|
<<~TEMPLATE
|
101
101
|
'******* FIDELITY *****************************************************
|
@@ -133,7 +133,7 @@ module Asciidoctor
|
|
133
133
|
|
134
134
|
attributes.map do |(attr_name, attr_hash)|
|
135
135
|
attribute_to_plantuml(attr_name, attr_hash)
|
136
|
-
end.join(
|
136
|
+
end.join("").sub(/\n\Z/, "")
|
137
137
|
end
|
138
138
|
|
139
139
|
def attribute_to_plantuml(attr_name, attr_hash)
|
@@ -143,9 +143,10 @@ module Asciidoctor
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def attribute_cardinality_plantuml(cardinality, with_bracket = true)
|
146
|
-
return
|
147
|
-
|
148
|
-
|
146
|
+
return "" if cardinality.nil? ||
|
147
|
+
(cardinality["min"] == cardinality["max"] &&
|
148
|
+
cardinality["min"] == 1)
|
149
|
+
|
149
150
|
card = "#{cardinality['min']}..#{cardinality['max']}"
|
150
151
|
return card unless with_bracket
|
151
152
|
|
@@ -172,7 +173,7 @@ module Asciidoctor
|
|
172
173
|
def classes_to_relations_plantuml(classes)
|
173
174
|
output_ary = classes.map do |(class_name, class_hash)|
|
174
175
|
class_hash ||= {}
|
175
|
-
relations = class_hash[
|
176
|
+
relations = class_hash["relations"]
|
176
177
|
relations_to_plantuml(class_name, relations)
|
177
178
|
end
|
178
179
|
|
@@ -183,9 +184,9 @@ module Asciidoctor
|
|
183
184
|
return unless relations
|
184
185
|
|
185
186
|
output_ary = relations.map do |relation|
|
186
|
-
source = class_name || relation[
|
187
|
+
source = class_name || relation["source"]
|
187
188
|
relation_to_plantuml(source,
|
188
|
-
relation[
|
189
|
+
relation["target"],
|
189
190
|
relation)
|
190
191
|
end
|
191
192
|
|
@@ -194,41 +195,41 @@ module Asciidoctor
|
|
194
195
|
|
195
196
|
def relation_arrow(relationship, relation)
|
196
197
|
[
|
197
|
-
relationship_type_to_plantuml(
|
198
|
-
relationship[
|
199
|
-
(relation[
|
200
|
-
relationship_type_to_plantuml(
|
201
|
-
relationship[
|
202
|
-
].compact.join(
|
198
|
+
relationship_type_to_plantuml("source",
|
199
|
+
relationship["source"]["type"]),
|
200
|
+
(relation["direction"]).to_s,
|
201
|
+
relationship_type_to_plantuml("target",
|
202
|
+
relationship["target"]["type"]),
|
203
|
+
].compact.join("-")
|
203
204
|
end
|
204
205
|
|
205
206
|
def relation_label(action)
|
206
|
-
return
|
207
|
+
return "" unless action
|
207
208
|
|
208
|
-
case action[
|
209
|
-
when
|
209
|
+
case action["direction"]
|
210
|
+
when "source"
|
210
211
|
" : < #{action['verb']}"
|
211
|
-
when
|
212
|
+
when "target"
|
212
213
|
" : #{action['verb']} >"
|
213
214
|
else
|
214
|
-
|
215
|
+
""
|
215
216
|
end
|
216
217
|
end
|
217
218
|
|
218
219
|
def source_arrow_end(source, relationship)
|
219
220
|
source_attribute = relationship_cardinality_to_plantuml(
|
220
|
-
relationship[
|
221
|
+
relationship["source"]["attribute"]
|
221
222
|
)
|
222
|
-
[source, source_attribute].join(
|
223
|
+
[source, source_attribute].join(" ")
|
223
224
|
end
|
224
225
|
|
225
226
|
def target_arrow_end(target, relationship, action)
|
226
227
|
target_attribute = relationship_cardinality_to_plantuml(
|
227
|
-
relationship[
|
228
|
+
relationship["target"]["attribute"]
|
228
229
|
)
|
229
230
|
[
|
230
|
-
[target_attribute, target].join(
|
231
|
-
relation_label(action)
|
231
|
+
[target_attribute, target].join(" "),
|
232
|
+
relation_label(action),
|
232
233
|
].join
|
233
234
|
end
|
234
235
|
|
@@ -239,9 +240,9 @@ module Asciidoctor
|
|
239
240
|
end
|
240
241
|
|
241
242
|
def relation_to_plantuml(source, target, relation)
|
242
|
-
relationship = relation[
|
243
|
-
relationship[
|
244
|
-
relationship[
|
243
|
+
relationship = relation["relationship"] || {}
|
244
|
+
relationship["source"] ||= {}
|
245
|
+
relationship["target"] ||= {}
|
245
246
|
relation_output_lines(source, target, relation, relationship)
|
246
247
|
end
|
247
248
|
|
@@ -249,22 +250,22 @@ module Asciidoctor
|
|
249
250
|
output_lines = [
|
250
251
|
source_arrow_end(source, relationship),
|
251
252
|
relation_arrow(relationship, relation),
|
252
|
-
target_arrow_end(target, relationship, relation[
|
253
|
-
relation_association(source, target, relationship[
|
254
|
-
].join(
|
253
|
+
target_arrow_end(target, relationship, relation["action"]),
|
254
|
+
relation_association(source, target, relationship["association"]),
|
255
|
+
].join(" ")
|
255
256
|
|
256
257
|
join_as_plantuml(*output_lines)
|
257
258
|
end
|
258
259
|
|
259
260
|
def relationship_type_to_plantuml(relation_end, relationship_type)
|
260
|
-
is_source = (relation_end ==
|
261
|
+
is_source = (relation_end == "source")
|
261
262
|
mappings = {
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
263
|
+
"direct" => is_source ? "<" : ">",
|
264
|
+
"inheritance" => is_source ? "<|" : "|>",
|
265
|
+
"composition" => "*",
|
266
|
+
"aggregation" => "o",
|
266
267
|
}
|
267
|
-
mappings.fetch(relationship_type,
|
268
|
+
mappings.fetch(relationship_type, "")
|
268
269
|
end
|
269
270
|
|
270
271
|
def relationship_cardinality_to_plantuml(attribute)
|
@@ -273,12 +274,12 @@ module Asciidoctor
|
|
273
274
|
return unless attribute_name
|
274
275
|
|
275
276
|
attribute_hash = attribute[attribute_name] || {}
|
276
|
-
card = attribute_cardinality(attribute_hash[
|
277
|
+
card = attribute_cardinality(attribute_hash["cardinality"])
|
277
278
|
"\"+#{attribute_name}#{card}\""
|
278
279
|
end
|
279
280
|
|
280
281
|
def attribute_cardinality(attribute_cardinality)
|
281
|
-
cardinality =
|
282
|
+
cardinality = ""
|
282
283
|
if attribute_cardinality
|
283
284
|
cardinality = attribute_cardinality_plantuml(
|
284
285
|
attribute_cardinality,
|
@@ -308,7 +309,7 @@ module Asciidoctor
|
|
308
309
|
end
|
309
310
|
|
310
311
|
def model_stereotype_to_plantuml(model_stereotype)
|
311
|
-
return
|
312
|
+
return "" unless model_stereotype
|
312
313
|
|
313
314
|
" <<#{model_stereotype}>>"
|
314
315
|
end
|
@@ -325,7 +326,7 @@ module Asciidoctor
|
|
325
326
|
groups ||= []
|
326
327
|
return if groups.empty?
|
327
328
|
|
328
|
-
groups.reduce(
|
329
|
+
groups.reduce("") do |output, group|
|
329
330
|
output += "\ntogether {\n"
|
330
331
|
group.each do |class_name|
|
331
332
|
output += "\nclass #{class_name}\n"
|
@@ -350,9 +351,9 @@ module Asciidoctor
|
|
350
351
|
end
|
351
352
|
|
352
353
|
def format_hidden_class(accum, fidelity_classes, class_hash)
|
353
|
-
return accum if class_hash[
|
354
|
+
return accum if class_hash["relations"].nil?
|
354
355
|
|
355
|
-
class_hash[
|
356
|
+
class_hash["relations"].each_with_object(accum) do |relation, acc|
|
356
357
|
format_source_target_relation(relation, fidelity_classes, acc)
|
357
358
|
format_association_relation(relation, fidelity_classes, acc)
|
358
359
|
end
|
@@ -367,36 +368,36 @@ module Asciidoctor
|
|
367
368
|
end
|
368
369
|
|
369
370
|
def format_association_relation(relation, fidelity_classes, acc)
|
370
|
-
return unless relation[
|
371
|
-
|
371
|
+
return unless relation["relationship"] &&
|
372
|
+
relation["relationship"]["association"]
|
372
373
|
|
373
|
-
association = relation[
|
374
|
+
association = relation["relationship"]["association"]
|
374
375
|
return unless association && !fidelity_classes.key?(association)
|
375
376
|
|
376
377
|
acc.merge!(association => true)
|
377
378
|
end
|
378
379
|
|
379
380
|
def hide_other_classes(fidelity)
|
380
|
-
return
|
381
|
+
return "" if fidelity.nil? || fidelity["classes"].nil?
|
381
382
|
|
382
|
-
output =
|
383
|
-
hidden_classes = fidelity[
|
384
|
-
|
385
|
-
format_hidden_class(acc, fidelity[
|
383
|
+
output = ""
|
384
|
+
hidden_classes = fidelity["classes"]
|
385
|
+
.reduce({}) do |acc, (_class_name, class_hash)|
|
386
|
+
format_hidden_class(acc, fidelity["classes"], class_hash)
|
386
387
|
end
|
387
388
|
|
388
|
-
hidden_classes.
|
389
|
+
hidden_classes.each_key do |hidden_class_name|
|
389
390
|
output += "\nhide #{hidden_class_name}\n"
|
390
391
|
end
|
391
392
|
output
|
392
393
|
end
|
393
394
|
|
394
395
|
def fidelity_to_plantuml(fidelity)
|
395
|
-
return
|
396
|
+
return "" if fidelity.nil?
|
396
397
|
|
397
|
-
output =
|
398
|
-
output += hide_other_classes(fidelity) if fidelity[
|
399
|
-
output += "\nhide members\n" if fidelity[
|
398
|
+
output = ""
|
399
|
+
output += hide_other_classes(fidelity) if fidelity["hideOtherClasses"]
|
400
|
+
output += "\nhide members\n" if fidelity["hideMembers"]
|
400
401
|
output
|
401
402
|
end
|
402
403
|
|
@@ -3,7 +3,7 @@ require "nokogiri"
|
|
3
3
|
require "htmlentities"
|
4
4
|
require "pathname"
|
5
5
|
require "open-uri"
|
6
|
-
require_relative "./front_contributor
|
6
|
+
require_relative "./front_contributor"
|
7
7
|
|
8
8
|
module Asciidoctor
|
9
9
|
module Standoc
|
@@ -40,6 +40,7 @@ module Asciidoctor
|
|
40
40
|
|
41
41
|
def metadata_committee(node, xml)
|
42
42
|
return unless node.attr("technical-committee")
|
43
|
+
|
43
44
|
xml.editorialgroup do |a|
|
44
45
|
committee_component("technical-committee", node, a)
|
45
46
|
end
|
@@ -47,8 +48,8 @@ module Asciidoctor
|
|
47
48
|
|
48
49
|
def metadata_ics(node, xml)
|
49
50
|
ics = node.attr("library-ics")
|
50
|
-
ics
|
51
|
-
xml.ics { |
|
51
|
+
ics&.split(/,\s*/)&.each do |i|
|
52
|
+
xml.ics { |elem| elem.code i }
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
@@ -71,15 +72,15 @@ module Asciidoctor
|
|
71
72
|
|
72
73
|
def datetypes
|
73
74
|
%w{ published accessed created implemented obsoleted
|
74
|
-
confirmed updated issued circulated unchanged received
|
75
|
-
vote-started vote-ended
|
76
|
-
}
|
75
|
+
confirmed updated issued circulated unchanged received
|
76
|
+
vote-started vote-ended announced }
|
77
77
|
end
|
78
78
|
|
79
79
|
def metadata_date(node, xml)
|
80
80
|
datetypes.each { |t| metadata_date1(node, xml, t) }
|
81
|
-
node.attributes.
|
81
|
+
node.attributes.each_key do |a|
|
82
82
|
next unless a == "date" || /^date_\d+$/.match(a)
|
83
|
+
|
83
84
|
type, date = node.attr(a).split(/ /, 2)
|
84
85
|
type or next
|
85
86
|
xml.date **{ type: type } do |d|
|
@@ -93,7 +94,8 @@ module Asciidoctor
|
|
93
94
|
end
|
94
95
|
|
95
96
|
def metadata_script(node, xml)
|
96
|
-
xml.script (node.attr("script") ||
|
97
|
+
xml.script (node.attr("script") ||
|
98
|
+
default_script(node.attr("language")))
|
97
99
|
end
|
98
100
|
|
99
101
|
def relaton_relations
|
@@ -114,8 +116,8 @@ module Asciidoctor
|
|
114
116
|
end
|
115
117
|
|
116
118
|
def relation_normalise(type)
|
117
|
-
type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From")
|
118
|
-
sub(/-in$/, "In")
|
119
|
+
type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From")
|
120
|
+
.sub(/-in$/, "In")
|
119
121
|
end
|
120
122
|
|
121
123
|
def metadata_getrelation(node, xml, type, desc = nil)
|
@@ -124,8 +126,8 @@ module Asciidoctor
|
|
124
126
|
id = d.split(/,\s*/)
|
125
127
|
xml.relation **{ type: relation_normalise(type) } do |r|
|
126
128
|
desc.nil? or r.description relation_normalise(desc)
|
127
|
-
fetch_ref(r, d, nil, {}) or r.bibitem do |b|
|
128
|
-
b.title id[1]
|
129
|
+
fetch_ref(r, d, nil, **{}) or r.bibitem do |b|
|
130
|
+
b.title id[1] || "--"
|
129
131
|
b.docidentifier id[0]
|
130
132
|
end
|
131
133
|
end
|
@@ -134,11 +136,20 @@ module Asciidoctor
|
|
134
136
|
|
135
137
|
def metadata_keywords(node, xml)
|
136
138
|
return unless node.attr("keywords")
|
137
|
-
|
139
|
+
|
140
|
+
node.attr("keywords").split(/,\s*/).each do |kw|
|
138
141
|
xml.keyword kw
|
139
142
|
end
|
140
143
|
end
|
141
144
|
|
145
|
+
def metadata_classifications(node, xml)
|
146
|
+
csv_split(node.attr("classification"), ",")&.each do |c|
|
147
|
+
vals = c.split(/:/, 2)
|
148
|
+
vals.size == 1 and vals = ["default", vals[0]]
|
149
|
+
xml.classification vals[1], type: vals[0]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
142
153
|
def metadata(node, xml)
|
143
154
|
title node, xml
|
144
155
|
metadata_source(node, xml)
|
@@ -155,14 +166,16 @@ module Asciidoctor
|
|
155
166
|
metadata_copyright(node, xml)
|
156
167
|
metadata_relations(node, xml)
|
157
168
|
metadata_series(node, xml)
|
169
|
+
metadata_classifications(node, xml)
|
158
170
|
metadata_keywords(node, xml)
|
159
|
-
xml.ext do
|
171
|
+
xml.ext do
|
160
172
|
metadata_ext(node, xml)
|
161
173
|
end
|
162
174
|
end
|
163
175
|
|
164
176
|
def metadata_ext(node, ext)
|
165
177
|
metadata_doctype(node, ext)
|
178
|
+
metadata_subdoctype(node, ext)
|
166
179
|
metadata_committee(node, ext)
|
167
180
|
metadata_ics(node, ext)
|
168
181
|
end
|
@@ -171,11 +184,13 @@ module Asciidoctor
|
|
171
184
|
xml.doctype doctype(node)
|
172
185
|
end
|
173
186
|
|
174
|
-
def
|
187
|
+
def metadata_subdoctype(node, xml)
|
188
|
+
s = node.attr("docsubtype") and xml.subdoctype s
|
175
189
|
end
|
176
190
|
|
177
|
-
def
|
178
|
-
|
191
|
+
def metadata_note(node, xml); end
|
192
|
+
|
193
|
+
def metadata_series(node, xml); end
|
179
194
|
|
180
195
|
def title(node, xml)
|
181
196
|
title_english(node, xml)
|
@@ -187,7 +202,8 @@ module Asciidoctor
|
|
187
202
|
at = { language: lang, format: "text/plain" }
|
188
203
|
xml.title **attr_code(at) do |t|
|
189
204
|
t << (Metanorma::Utils::asciidoc_sub(node.attr("title") ||
|
190
|
-
|
205
|
+
node.attr("title-en")) ||
|
206
|
+
node.title)
|
191
207
|
end
|
192
208
|
end
|
193
209
|
end
|
@@ -196,6 +212,7 @@ module Asciidoctor
|
|
196
212
|
node.attributes.each do |k, v|
|
197
213
|
next unless /^title-(?<titlelang>.+)$/ =~ k
|
198
214
|
next if titlelang == "en"
|
215
|
+
|
199
216
|
xml.title v, { language: titlelang, format: "text/plain" }
|
200
217
|
end
|
201
218
|
end
|