metanorma-standoc 1.3.29 → 1.4.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/lib/asciidoctor/standoc/base.rb +2 -25
  4. data/lib/asciidoctor/standoc/biblio.rng +13 -3
  5. data/lib/asciidoctor/standoc/blocks.rb +20 -17
  6. data/lib/asciidoctor/standoc/cleanup.rb +2 -0
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +2 -2
  8. data/lib/asciidoctor/standoc/cleanup_section.rb +8 -125
  9. data/lib/asciidoctor/standoc/cleanup_terms.rb +134 -0
  10. data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +57 -0
  11. data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +102 -0
  12. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +408 -0
  13. data/lib/asciidoctor/standoc/inline.rb +10 -5
  14. data/lib/asciidoctor/standoc/isodoc.rng +17 -1
  15. data/lib/asciidoctor/standoc/macros.rb +13 -8
  16. data/lib/asciidoctor/standoc/macros_yaml2text.rb +19 -13
  17. data/lib/asciidoctor/standoc/ref.rb +13 -56
  18. data/lib/asciidoctor/standoc/ref_sect.rb +124 -0
  19. data/lib/asciidoctor/standoc/section.rb +2 -46
  20. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +30 -0
  21. data/lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb +20 -0
  22. data/lib/metanorma/standoc/version.rb +1 -1
  23. data/metanorma-standoc.gemspec +1 -1
  24. data/spec/asciidoctor-standoc/cleanup_spec.rb +51 -0
  25. data/spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb +76 -0
  26. data/spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb +72 -0
  27. data/spec/asciidoctor-standoc/inline_spec.rb +5 -1
  28. data/spec/asciidoctor-standoc/macros_spec.rb +50 -0
  29. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +2 -1
  30. data/spec/asciidoctor-standoc/refs_spec.rb +0 -4
  31. data/spec/examples/datamodel/address_class_profile.adoc +4 -0
  32. data/spec/examples/datamodel/address_component_profile.adoc +4 -0
  33. data/spec/examples/datamodel/common_models_diagram.adoc +4 -0
  34. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +90 -0
  35. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +63 -0
  36. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +15 -0
  37. data/spec/examples/datamodel/models/models/AddressProfile.yml +36 -0
  38. data/spec/examples/datamodel/models/models/AttributeProfile.yml +32 -0
  39. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +79 -0
  40. data/spec/examples/datamodel/models/models/Localization copy.yml +23 -0
  41. data/spec/examples/datamodel/models/models/Localization.yml +23 -0
  42. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +36 -0
  43. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +15 -0
  44. data/spec/examples/datamodel/models/models/Signature copy.yml +20 -0
  45. data/spec/examples/datamodel/models/models/Signature.yml +20 -0
  46. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +16 -0
  47. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +16 -0
  48. data/spec/examples/datamodel/models/models/Validity.yml +14 -0
  49. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +22 -0
  50. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +2 -0
  51. data/spec/examples/datamodel/models/style.uml.inc +37 -0
  52. data/spec/examples/datamodel/models/views/CommonModels.yml +9 -0
  53. data/spec/examples/datamodel/models/views/TopDown.yml +62 -0
  54. data/spec/examples/datamodel/top_down_diagram.adoc +4 -0
  55. data/spec/fixtures/macros_datamodel/address_class_profile.xml +149 -0
  56. data/spec/fixtures/macros_datamodel/address_component_profile.xml +71 -0
  57. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +7 -0
  58. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +7 -0
  59. data/spec/spec_helper.rb +13 -2
  60. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +66 -66
  61. data/spec/vcr_cassettes/isobib_get_123.yml +36 -36
  62. data/spec/vcr_cassettes/isobib_get_123_2001.yml +16 -16
  63. data/spec/vcr_cassettes/isobib_get_124.yml +17 -17
  64. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  65. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +41 -38
  66. metadata +41 -4
@@ -0,0 +1,30 @@
1
+
2
+ [yaml2text,<%= model_path %>,definition]
3
+ ----
4
+
5
+ === {definition.name || "<%= file_name %>"}
6
+ {definition.definition}
7
+
8
+ {if definition.attributes}
9
+ .{definition.name || "<%= file_name %>"} attributes
10
+ |===
11
+ |Name |Definition |Mandatory/ Optional/ Conditional |Max Occur |Data Type
12
+
13
+ {definition.attributes&.*,key,EOK}
14
+ |{key} |{definition.attributes[key].definition || "TODO: enum " + key + "'s definition"} |{definition.attributes[key]&.cardinality&.min == 0 ? "O" : "M"} |{definition.attributes[key]&.cardinality&.max == "*" ? "N" : "1"} |{definition.attributes[key].origin ? "<<" + definition.attributes[key].origin + ">>" : ""}`{definition.attributes[key].type}`
15
+ {EOK}
16
+ |===
17
+ {end}
18
+
19
+ {if definition['values']}
20
+ .{definition.name || "<%= file_name %>"} values
21
+ |===
22
+ |Name |Definition
23
+
24
+ {definition['values']&.*,key,EOK}
25
+ |{key} |{definition['values'][key].definition}
26
+ {EOK}
27
+ |===
28
+ {end}
29
+
30
+ ----
@@ -0,0 +1,20 @@
1
+ [plantuml,title=<%= diagram_caption %>]
2
+ ....
3
+ @startuml
4
+
5
+ <%= diagram_options_yml_to_plantuml %>
6
+
7
+ <%= class_groups_yml_to_plantuml %>
8
+
9
+ <%= imports_yml_to_plantuml %>
10
+
11
+ <%= class_defs_yml_to_plantuml %>
12
+
13
+ <%= class_relations_yml_to_plantuml %>
14
+
15
+ <%= fidelity_yml_to_plantuml %>
16
+
17
+ <%= bottom_yml_to_plantuml %>
18
+
19
+ @enduml
20
+ ....
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.3.29".freeze
3
+ VERSION = "1.4.0".freeze
4
4
  end
5
5
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "ruby-jing"
31
31
  spec.add_dependency "isodoc", "~> 1.0.20"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
- spec.add_dependency "relaton", "~> 1.0.0"
33
+ spec.add_dependency "relaton", "~> 1.1.0"
34
34
  spec.add_dependency "relaton-iev", "~> 1.0.0"
35
35
  spec.add_dependency "sterile", "~> 1.0.14"
36
36
  spec.add_dependency "concurrent-ruby"
@@ -1844,6 +1844,57 @@ it "moves inherit macros to correct location" do
1844
1844
  </clause>
1845
1845
  </sections>
1846
1846
  </standard-document>
1847
+ OUTPUT
1848
+ end
1849
+
1850
+ it "moves %beforeclause admonitions to right position" do
1851
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1852
+ #{ASCIIDOC_BLANK_HDR}
1853
+
1854
+ .Foreword
1855
+ Foreword
1856
+
1857
+ [NOTE,beforeclauses=true]
1858
+ ====
1859
+ Note which is very important
1860
+ ====
1861
+
1862
+ == Introduction
1863
+ Introduction
1864
+
1865
+ == Scope
1866
+ Scope statement
1867
+
1868
+ [IMPORTANT,beforeclauses=true]
1869
+ ====
1870
+ Notice which is very important
1871
+ ====
1872
+ INPUT
1873
+ #{BLANK_HDR}
1874
+ <preface>
1875
+ <foreword id='_' obligation='informative'>
1876
+ <title>Foreword</title>
1877
+ <p id='_'>Foreword</p>
1878
+ </foreword>
1879
+ <introduction id='_' obligation='informative'>
1880
+ <title>Introduction</title>
1881
+ <p id='_'>Introduction</p>
1882
+ </introduction>
1883
+ </preface>
1884
+ <sections>
1885
+ <note id='_'>
1886
+ <p id='_'>Note which is very important</p>
1887
+ </note>
1888
+ <admonition id='_' type='important'>
1889
+ <p id='_'>Notice which is very important</p>
1890
+ </admonition>
1891
+ <clause id='_' inline-header='false' obligation='normative'>
1892
+ <title>Scope</title>
1893
+ <p id='_'>Scope statement</p>
1894
+ </clause>
1895
+ </sections>
1896
+ </standard-document>
1897
+
1847
1898
  OUTPUT
1848
1899
  end
1849
1900
 
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Asciidoctor::Standoc::Datamodel::AttributesTablePreprocessor do
6
+ describe '#process' do
7
+ context 'when simple models without relations' do
8
+ let(:datamodel_file) do
9
+ examples_path('datamodel/address_class_profile.adoc')
10
+ end
11
+ let(:result_file) do
12
+ examples_path('datamodel/address_class_profile.xml')
13
+ end
14
+ let(:output) do
15
+ [
16
+ BLANK_HDR,
17
+ File.read(fixtures_path('macros_datamodel/address_class_profile.xml'))
18
+ ]
19
+ .join
20
+ end
21
+
22
+ after do
23
+ %w[doc html xml err].each do |extention|
24
+ path = examples_path("datamodel/address_class_profile.#{extention}")
25
+ FileUtils.rm_f(path)
26
+ FileUtils.rm_f("address_class_profile.#{extention}")
27
+ end
28
+ end
29
+
30
+ it 'correctly renders input' do
31
+ Asciidoctor.convert_file(datamodel_file,
32
+ backend: :standoc,
33
+ safe: :safe,
34
+ header_footer: true)
35
+ expect(xmlpp(strip_guid(File.read(result_file))))
36
+ .to(be_equivalent_to(xmlpp(output)))
37
+ end
38
+ end
39
+
40
+ context 'when complex relations' do
41
+ let(:datamodel_file) do
42
+ examples_path('datamodel/address_component_profile.adoc')
43
+ end
44
+ let(:result_file) do
45
+ examples_path('datamodel/address_component_profile.xml')
46
+ end
47
+ let(:output) do
48
+ path = fixtures_path('macros_datamodel/address_component_profile.xml')
49
+ [
50
+ BLANK_HDR,
51
+ File.read(path)
52
+ ]
53
+ .join("\n")
54
+ end
55
+
56
+ after do
57
+ %w[doc html xml err].each do |extention|
58
+ path = examples_path(
59
+ "datamodel/address_component_profile.#{extention}"
60
+ )
61
+ FileUtils.rm_f(path)
62
+ FileUtils.rm_f("address_component_profile.#{extention}")
63
+ end
64
+ end
65
+
66
+ it 'correctly renders input' do
67
+ Asciidoctor.convert_file(datamodel_file,
68
+ backend: :standoc,
69
+ safe: :safe,
70
+ header_footer: true)
71
+ expect(xmlpp(strip_guid(File.read(result_file))))
72
+ .to(be_equivalent_to(xmlpp(output)))
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Asciidoctor::Standoc::Datamodel::DiagramPreprocessor do
6
+ describe '#process' do
7
+ context 'when simple models without relations' do
8
+ let(:datamodel_file) do
9
+ examples_path('datamodel/common_models_diagram.adoc')
10
+ end
11
+ let(:result_file) do
12
+ examples_path('datamodel/common_models_diagram.xml')
13
+ end
14
+ let(:output) do
15
+ [
16
+ BLANK_HDR,
17
+ File.read(
18
+ fixtures_path('macros_datamodel/common_models_diagram.xml')
19
+ )
20
+ ].join
21
+ end
22
+
23
+ after do
24
+ %w[doc html xml err].each do |extention|
25
+ path = examples_path("datamodel/common_models_diagram.#{extention}")
26
+ FileUtils.rm_f(path)
27
+ FileUtils.rm_f("common_models_diagram.#{extention}")
28
+ end
29
+ FileUtils.rm_rf('common_models_diagram_htmlimages')
30
+ end
31
+
32
+ it 'correctly renders input' do
33
+ Asciidoctor.convert_file(datamodel_file,
34
+ backend: :standoc,
35
+ safe: :safe,
36
+ header_footer: true)
37
+ expect(xmlpp(strip_src(strip_guid(File.read(result_file)))))
38
+ .to(be_equivalent_to(xmlpp(output)))
39
+ end
40
+ end
41
+
42
+ context 'when complex relations' do
43
+ let(:datamodel_file) { examples_path('datamodel/top_down_diagram.adoc') }
44
+ let(:result_file) { examples_path('datamodel/top_down_diagram.xml') }
45
+ let(:output) do
46
+ [
47
+ BLANK_HDR,
48
+ File.read(fixtures_path('macros_datamodel/top_down_diagram.xml'))
49
+ ].join("\n")
50
+ end
51
+
52
+ after do
53
+ %w[doc html xml err].each do |extention|
54
+ path = examples_path("datamodel/top_down_diagram.#{extention}")
55
+ FileUtils.rm_f(path)
56
+ FileUtils.rm_f("top_down_diagram.#{extention}")
57
+ end
58
+ FileUtils.rm_rf(examples_path('datamodel/plantuml'))
59
+ FileUtils.rm_rf('top_down_diagram_htmlimages')
60
+ end
61
+
62
+ it 'correctly renders input' do
63
+ Asciidoctor.convert_file(datamodel_file,
64
+ backend: :standoc,
65
+ safe: :safe,
66
+ header_footer: true)
67
+ expect(xmlpp(strip_src(strip_guid(File.read(result_file)))))
68
+ .to(be_equivalent_to(xmlpp(output)))
69
+ end
70
+ end
71
+ end
72
+ end
@@ -198,6 +198,8 @@ text, including nested markup.

198
198
  Inline Reference with Text to <<reference,text>>
199
199
  Footnoted Reference with Text to <<reference,fn: text>>
200
200
  Anchored Crossreference to other document <<a.adoc#b>>
201
+ Capitalised Reference to <<reference,capital%>>
202
+ Lowercase Footnoted Reference to <<reference,capital%fn>>
201
203
  INPUT
202
204
  #{BLANK_HDR}
203
205
  <sections>
@@ -207,7 +209,9 @@ text, including nested markup.

207
209
  Footnoted Reference to <xref target="reference"/>
208
210
  Inline Reference with Text to <xref target="reference">text</xref>
209
211
  Footnoted Reference with Text to <xref target="reference">text</xref>
210
- Anchored Crossreference to other document <xref target="a#b"/></p>
212
+ Anchored Crossreference to other document <xref target="a#b"/>
213
+ Capitalised Reference to <xref target='reference' case='capital'></xref>
214
+ Lowercase Footnoted Reference to <xref target='reference' case='capital'></xref></p>
211
215
  </clause>
212
216
  </sections>
213
217
  </standard-document>
@@ -270,6 +270,56 @@ OUTPUT
270
270
  </p>
271
271
  </figure>
272
272
  </sections>
273
+ </standard-document>
274
+ OUTPUT
275
+ end
276
+
277
+ it "skips embedded blocks when supplying line breaks in pseudocode" do
278
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
279
+ #{ASCIIDOC_BLANK_HDR}
280
+
281
+ [pseudocode]
282
+ ====
283
+ [stem]
284
+ ++++
285
+ bar X' = (1)/(v) sum_(i = 1)^(v) t_(i)
286
+ ++++
287
+ ====
288
+ INPUT
289
+ #{BLANK_HDR}
290
+ <sections>
291
+ <figure id='_' class='pseudocode'>
292
+ <formula id='_'>
293
+ <stem type='MathML'>
294
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
295
+ <mover>
296
+ <mi>X</mi>
297
+ <mo>¯</mo>
298
+ </mover>
299
+ <mi>'</mi>
300
+ <mo>=</mo>
301
+ <mfrac>
302
+ <mn>1</mn>
303
+ <mi>v</mi>
304
+ </mfrac>
305
+ <munderover>
306
+ <mo>∑</mo>
307
+ <mrow>
308
+ <mi>i</mi>
309
+ <mo>=</mo>
310
+ <mn>1</mn>
311
+ </mrow>
312
+ <mi>v</mi>
313
+ </munderover>
314
+ <msub>
315
+ <mi>t</mi>
316
+ <mi>i</mi>
317
+ </msub>
318
+ </math>
319
+ </stem>
320
+ </formula>
321
+ </figure>
322
+ </sections>
273
323
  </standard-document>
274
324
  OUTPUT
275
325
  end
@@ -402,7 +402,8 @@ RSpec.describe Asciidoctor::Standoc::Yaml2TextPreprocessor do
402
402
  TEXT
403
403
  end
404
404
 
405
- it 'correctly renders input yaml' do
405
+ # TODO: fix frozen string error
406
+ xit 'correctly renders input yaml' do
406
407
  expect(
407
408
  xmlpp(
408
409
  strip_guid(
@@ -543,7 +543,6 @@ RSpec.describe Asciidoctor::Standoc do
543
543
  <uri>www.iso.org</uri>
544
544
  </organization>
545
545
  </contributor>
546
- <!--
547
546
  <contributor>
548
547
  <role type="publisher"/>
549
548
  <organization>
@@ -552,7 +551,6 @@ RSpec.describe Asciidoctor::Standoc do
552
551
  <uri>www.iec.ch</uri>
553
552
  </organization>
554
553
  </contributor>
555
- -->
556
554
  <edition>2</edition>
557
555
  <language>en</language>
558
556
  <language>fr</language>
@@ -645,7 +643,6 @@ RSpec.describe Asciidoctor::Standoc do
645
643
  <uri>www.iso.org</uri>
646
644
  </organization>
647
645
  </contributor>
648
- <!--
649
646
  <contributor>
650
647
  <role type="publisher"/>
651
648
  <organization>
@@ -654,7 +651,6 @@ RSpec.describe Asciidoctor::Standoc do
654
651
  <uri>www.iec.ch</uri>
655
652
  </organization>
656
653
  </contributor>
657
- -->
658
654
  <edition>2</edition>
659
655
  <language>en</language>
660
656
  <language>fr</language>
@@ -0,0 +1,4 @@
1
+ = Document title
2
+ Author
3
+
4
+ [datamodel_attributes_table,models/models/AddressClassProfile.yml]
@@ -0,0 +1,4 @@
1
+ = Document title
2
+ Author
3
+
4
+ [datamodel_attributes_table,models/models/AddressComponentProfile.yml]
@@ -0,0 +1,4 @@
1
+ = Document title
2
+ Author
3
+
4
+ [datamodel_diagram,models/views/CommonModels.yml]
@@ -0,0 +1,90 @@
1
+ modelType: class
2
+ # TODO
3
+ definition: |
4
+ An `AddressClassProfile` represents a profile of a `ProfileCompliantAddress`.
5
+ It corresponds to the concept of an `AddressClass` originally
6
+ expressed in <<ISO19160-1>> as a referenced codelist.
7
+
8
+ It represents additional attributes and restrictions to the
9
+ `ProfileCompliantAddress` model. It also represents metadata for the use of
10
+ the profile.
11
+
12
+ A single profile can include and support multiple types of
13
+ address formats, such as a numbered street address and a
14
+ "`PO Box`" address simultaneously. Each of these address formats
15
+ is represented as an interchange address class.
16
+
17
+ [example]
18
+ --
19
+ The US Numbered Thoroughfare Address with this syntax can be
20
+ represented as an address class profile:
21
+
22
+ *{sp}{ Complete Landmark Name or Complete Place Name } +
23
+ *{sp}{ Complete Address Number * } +
24
+ *{sp}{ Complete Street Name * } +
25
+ *{sp}{ Complete Subaddress } +
26
+ *{sp}{ Complete Place Name * } +
27
+ *{sp}{ State Name * } +
28
+ *{sp}{ Zip Code } +
29
+ *{sp}{ Zip Plus 4 } +
30
+ *{sp}{ Country Name }
31
+ --
32
+ attributes:
33
+ id:
34
+ definition: Unique identifier of this AddressClassProfile.
35
+ type: CharacterString
36
+ type:
37
+ definition: Intended usage of this profile.
38
+ type: CharacterString
39
+ description:
40
+ definition: Textual description of this profile.
41
+ type: CharacterString
42
+ localization:
43
+ definition: The language and script used within this profile.
44
+ type: Localization
45
+ signature:
46
+ definition: The digital signature to verify the integrity of this profile, and the identity of the publishing authority.
47
+ type: Signature
48
+ cardinality:
49
+ min: 0
50
+ max: 1
51
+ areaApplicability:
52
+ definition: The geographic representation of which this AddressClassProfile applies to. Overlapping geographic areas are allowed across different profiles.
53
+ type: iso19115MD_SpatialRepresentation
54
+ cardinality:
55
+ min: 0
56
+ max: "*"
57
+ timeToLive:
58
+ definition: The maximum time interval between refreshing of this profile via an authoritative source, in seconds.
59
+ type: Integer
60
+ validity:
61
+ definition: The period of date and time that this profile should be considered as valid.
62
+ type: Validity
63
+ relations:
64
+ - target: AttributeProfile
65
+ relationship:
66
+ source:
67
+ type: aggregation
68
+ attribute:
69
+ addressClassProfile:
70
+ target:
71
+ type: direct
72
+ attribute:
73
+ attributeProfile:
74
+ cardinality:
75
+ min: 0
76
+ max: '*'
77
+
78
+ - target: ProfileCompliantAddress
79
+ relationship:
80
+ source:
81
+ attribute:
82
+ profile:
83
+ cardinality:
84
+ min: 1
85
+ max: 1
86
+ target:
87
+ type: direct
88
+ action:
89
+ verb: compliesWith
90
+ direction: source