metanorma-document 0.2.6 → 0.2.8

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 (202) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +41 -168
  3. data/Gemfile +2 -0
  4. data/lib/metanorma/basic_document/ancillary_blocks/figure_block.rb +3 -1
  5. data/lib/metanorma/basic_document/blocks/basic_block.rb +5 -1
  6. data/lib/metanorma/basic_document/blocks/note_block.rb +5 -0
  7. data/lib/metanorma/basic_document/blocks.rb +3 -24
  8. data/lib/metanorma/basic_document/lists/list.rb +2 -1
  9. data/lib/metanorma/basic_document/lists/list_item.rb +17 -0
  10. data/lib/metanorma/basic_document/lists.rb +1 -0
  11. data/lib/metanorma/basic_document/paragraphs/paragraph_with_footnote.rb +3 -1
  12. data/lib/metanorma/basic_document/reference_elements/callout.rb +1 -1
  13. data/lib/metanorma/basic_document/reference_elements/footnote.rb +1 -1
  14. data/lib/metanorma/basic_document/text_elements/mathml.rb +1 -1
  15. data/lib/metanorma/bipm_document/root.rb +10 -50
  16. data/lib/metanorma/bipm_document.rb +0 -2
  17. data/lib/metanorma/bsi_document/metadata/bsi_bib_data_extension_type.rb +10 -0
  18. data/lib/metanorma/bsi_document/metadata/bsi_bibliographic_item.rb +15 -0
  19. data/lib/metanorma/bsi_document/metadata.rb +12 -0
  20. data/lib/metanorma/bsi_document/root.rb +29 -0
  21. data/lib/metanorma/bsi_document/sections/bsi_annex_section.rb +25 -0
  22. data/lib/metanorma/bsi_document/sections/bsi_clause_section.rb +25 -0
  23. data/lib/metanorma/bsi_document/sections/bsi_sections.rb +27 -0
  24. data/lib/metanorma/bsi_document/sections.rb +11 -0
  25. data/lib/metanorma/bsi_document.rb +11 -0
  26. data/lib/metanorma/cc_document/root.rb +10 -50
  27. data/lib/metanorma/cc_document.rb +0 -2
  28. data/lib/metanorma/collection.rb +0 -2
  29. data/lib/metanorma/document/components/ancillary_blocks/example_block.rb +3 -3
  30. data/lib/metanorma/document/components/ancillary_blocks/figure_block.rb +2 -0
  31. data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +2 -0
  32. data/lib/metanorma/document/components/blocks/passthrough.rb +21 -0
  33. data/lib/metanorma/document/components/blocks/requirement_model.rb +159 -0
  34. data/lib/metanorma/document/components/blocks.rb +10 -0
  35. data/lib/metanorma/document/components/contrib_metadata/contribution_element_metadata.rb +3 -1
  36. data/lib/metanorma/document/components/id_elements/image.rb +2 -0
  37. data/lib/metanorma/document/components/inline/xref_element.rb +8 -0
  38. data/lib/metanorma/document/components/lists/definition_list.rb +6 -0
  39. data/lib/metanorma/document/components/lists/list_item.rb +1 -1
  40. data/lib/metanorma/document/components/lists/ordered_list.rb +6 -0
  41. data/lib/metanorma/document/components/lists/unordered_list.rb +8 -0
  42. data/lib/metanorma/document/components/multi_paragraph/admonition_block.rb +8 -0
  43. data/lib/metanorma/document/components/multi_paragraph/review_block.rb +3 -0
  44. data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +6 -2
  45. data/lib/metanorma/document/components/reference_elements/source_element.rb +57 -0
  46. data/lib/metanorma/document/components/reference_elements.rb +6 -0
  47. data/lib/metanorma/document/components/sections/references_section.rb +1 -1
  48. data/lib/metanorma/document/components/tables/table_block.rb +10 -0
  49. data/lib/metanorma/document/components/tables/table_cell.rb +2 -1
  50. data/lib/metanorma/document/data_types.rb +0 -4
  51. data/lib/metanorma/document/elements/add.rb +18 -0
  52. data/lib/metanorma/document/elements/del.rb +18 -0
  53. data/lib/metanorma/document/elements.rb +10 -0
  54. data/lib/metanorma/document/relaton/address.rb +16 -0
  55. data/lib/metanorma/document/root.rb +1 -3
  56. data/lib/metanorma/document/version.rb +1 -1
  57. data/lib/metanorma/document.rb +11 -2
  58. data/lib/metanorma/gb_document/metadata/gb_bib_data_extension_type.rb +10 -0
  59. data/lib/metanorma/gb_document/metadata/gb_bibliographic_item.rb +15 -0
  60. data/lib/metanorma/gb_document/metadata.rb +12 -0
  61. data/lib/metanorma/gb_document/root.rb +29 -0
  62. data/lib/metanorma/gb_document.rb +10 -0
  63. data/lib/metanorma/generic_document/root.rb +31 -0
  64. data/lib/metanorma/generic_document.rb +7 -0
  65. data/lib/metanorma/html/base_renderer.rb +206 -120
  66. data/lib/metanorma/html/bipm_renderer.rb +16 -8
  67. data/lib/metanorma/html/cc_renderer.rb +0 -1
  68. data/lib/metanorma/html/component/base.rb +5 -1
  69. data/lib/metanorma/html/component/footnote_collector.rb +3 -3
  70. data/lib/metanorma/html/component/index_section.rb +27 -9
  71. data/lib/metanorma/html/component/index_term_collector.rb +8 -3
  72. data/lib/metanorma/html/component.rb +2 -1
  73. data/lib/metanorma/html/drops/figure_drop.rb +14 -5
  74. data/lib/metanorma/html/drops/formula_drop.rb +7 -2
  75. data/lib/metanorma/html/drops/sourcecode_drop.rb +6 -2
  76. data/lib/metanorma/html/drops.rb +2 -1
  77. data/lib/metanorma/html/generator.rb +16 -6
  78. data/lib/metanorma/html/iec_renderer.rb +0 -1
  79. data/lib/metanorma/html/ieee_renderer.rb +0 -1
  80. data/lib/metanorma/html/ietf_renderer.rb +0 -1
  81. data/lib/metanorma/html/iho_renderer.rb +1 -2
  82. data/lib/metanorma/html/iso_renderer.rb +68 -23
  83. data/lib/metanorma/html/itu_renderer.rb +0 -1
  84. data/lib/metanorma/html/ogc_renderer.rb +0 -1
  85. data/lib/metanorma/html/oiml_renderer.rb +0 -1
  86. data/lib/metanorma/html/pdfa_renderer.rb +0 -1
  87. data/lib/metanorma/html/ribose_renderer.rb +0 -1
  88. data/lib/metanorma/html/standard_renderer.rb +61 -28
  89. data/lib/metanorma/html/theme.rb +2 -2
  90. data/lib/metanorma/html.rb +48 -1
  91. data/lib/metanorma/iec_document/root.rb +8 -47
  92. data/lib/metanorma/iec_document.rb +2 -3
  93. data/lib/metanorma/ieee_document/root.rb +14 -50
  94. data/lib/metanorma/ieee_document/sections/ieee_sections.rb +31 -0
  95. data/lib/metanorma/ieee_document/sections.rb +9 -0
  96. data/lib/metanorma/ieee_document.rb +3 -3
  97. data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -2
  98. data/lib/metanorma/ietf_document/metadata/ietf_bibliographic_item.rb +0 -2
  99. data/lib/metanorma/ietf_document/root.rb +14 -50
  100. data/lib/metanorma/ietf_document/sections/ietf_annex_section.rb +26 -0
  101. data/lib/metanorma/ietf_document/sections/ietf_clause_section.rb +26 -0
  102. data/lib/metanorma/ietf_document/sections/ietf_content_section.rb +25 -0
  103. data/lib/metanorma/ietf_document/sections/ietf_sections.rb +35 -0
  104. data/lib/metanorma/ietf_document/sections.rb +4 -23
  105. data/lib/metanorma/ietf_document.rb +4 -3
  106. data/lib/metanorma/iho_document/metadata/iho_bib_data_extension_type.rb +0 -2
  107. data/lib/metanorma/iho_document/root.rb +10 -50
  108. data/lib/metanorma/iho_document.rb +0 -3
  109. data/lib/metanorma/iso_document/annotation_container.rb +1 -10
  110. data/lib/metanorma/iso_document/boilerplate.rb +1 -11
  111. data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +2 -2
  112. data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +4 -3
  113. data/lib/metanorma/iso_document/metadata/metanorma_extension.rb +1 -12
  114. data/lib/metanorma/iso_document/root.rb +7 -73
  115. data/lib/metanorma/iso_document/sections/colophon.rb +1 -16
  116. data/lib/metanorma/iso_document/sections/iso_annex_section.rb +11 -133
  117. data/lib/metanorma/iso_document/sections/iso_clause_section.rb +9 -166
  118. data/lib/metanorma/iso_document/sections/iso_foreword_section.rb +5 -90
  119. data/lib/metanorma/iso_document/sections/iso_preface.rb +15 -21
  120. data/lib/metanorma/iso_document/sections/iso_sections.rb +19 -29
  121. data/lib/metanorma/iso_document/sections/iso_terms_section.rb +9 -22
  122. data/lib/metanorma/iso_document/terms/term_expression.rb +2 -47
  123. data/lib/metanorma/iso_document/terms/term_origin.rb +2 -24
  124. data/lib/metanorma/iso_document/terms/term_source.rb +4 -32
  125. data/lib/metanorma/iso_document.rb +2 -2
  126. data/lib/metanorma/itu_document/root.rb +10 -50
  127. data/lib/metanorma/itu_document.rb +0 -2
  128. data/lib/metanorma/jis_document/metadata/jis_bib_data_extension_type.rb +10 -0
  129. data/lib/metanorma/jis_document/metadata/jis_bibliographic_item.rb +15 -0
  130. data/lib/metanorma/jis_document/metadata.rb +12 -0
  131. data/lib/metanorma/jis_document/root.rb +29 -0
  132. data/lib/metanorma/jis_document/sections/jis_annex_section.rb +20 -0
  133. data/lib/metanorma/jis_document/sections.rb +9 -0
  134. data/lib/metanorma/jis_document.rb +11 -0
  135. data/lib/metanorma/m3d_document/metadata/m3d_bib_data_extension_type.rb +10 -0
  136. data/lib/metanorma/m3d_document/metadata/m3d_bibliographic_item.rb +15 -0
  137. data/lib/metanorma/m3d_document/metadata.rb +12 -0
  138. data/lib/metanorma/m3d_document/root.rb +29 -0
  139. data/lib/metanorma/m3d_document.rb +10 -0
  140. data/lib/metanorma/nist_document/metadata/nist_bib_data_extension_type.rb +10 -0
  141. data/lib/metanorma/nist_document/metadata/nist_bibliographic_item.rb +15 -0
  142. data/lib/metanorma/nist_document/metadata.rb +12 -0
  143. data/lib/metanorma/nist_document/root.rb +29 -0
  144. data/lib/metanorma/nist_document/sections/errata.rb +16 -0
  145. data/lib/metanorma/nist_document/sections/errata_clause.rb +20 -0
  146. data/lib/metanorma/nist_document/sections/errata_row.rb +22 -0
  147. data/lib/metanorma/nist_document/sections/nist_preface.rb +30 -0
  148. data/lib/metanorma/nist_document/sections.rb +12 -0
  149. data/lib/metanorma/nist_document.rb +11 -0
  150. data/lib/metanorma/ogc_document/root.rb +10 -50
  151. data/lib/metanorma/ogc_document.rb +0 -2
  152. data/lib/metanorma/oiml_document/root.rb +8 -47
  153. data/lib/metanorma/oiml_document.rb +2 -3
  154. data/lib/metanorma/plateau_document/metadata/plateau_bibliographic_item.rb +13 -0
  155. data/lib/metanorma/plateau_document/metadata.rb +10 -0
  156. data/lib/metanorma/plateau_document/root.rb +29 -0
  157. data/lib/metanorma/plateau_document.rb +10 -0
  158. data/lib/metanorma/registers/setup.rb +162 -0
  159. data/lib/metanorma/registers.rb +7 -0
  160. data/lib/metanorma/ribose_document/root.rb +10 -52
  161. data/lib/metanorma/ribose_document.rb +0 -2
  162. data/lib/metanorma/standard_document/annotation_container.rb +14 -0
  163. data/lib/metanorma/standard_document/block_attributes.rb +268 -0
  164. data/lib/metanorma/standard_document/blocks/passthrough.rb +1 -18
  165. data/lib/metanorma/standard_document/blocks/requirement_model.rb +18 -163
  166. data/lib/metanorma/standard_document/boilerplate.rb +14 -0
  167. data/lib/metanorma/standard_document/elements/add.rb +1 -17
  168. data/lib/metanorma/standard_document/elements/del.rb +1 -17
  169. data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +16 -0
  170. data/lib/metanorma/standard_document/metadata.rb +2 -0
  171. data/lib/metanorma/standard_document/refs/reference_to_term.rb +2 -1
  172. data/lib/metanorma/standard_document/root_attributes.rb +78 -0
  173. data/lib/metanorma/standard_document/sections/abstract.rb +1 -3
  174. data/lib/metanorma/standard_document/sections/acknowledgements.rb +1 -3
  175. data/lib/metanorma/standard_document/sections/annex_section.rb +56 -19
  176. data/lib/metanorma/standard_document/sections/bibliography_section.rb +1 -2
  177. data/lib/metanorma/standard_document/sections/clause_section.rb +75 -13
  178. data/lib/metanorma/standard_document/sections/colophon.rb +16 -0
  179. data/lib/metanorma/standard_document/sections/definition_section.rb +43 -46
  180. data/lib/metanorma/standard_document/sections/floating_section_title.rb +23 -0
  181. data/lib/metanorma/standard_document/sections/foreword.rb +1 -3
  182. data/lib/metanorma/standard_document/sections/introduction.rb +1 -4
  183. data/lib/metanorma/standard_document/sections/misc_container.rb +5 -2
  184. data/lib/metanorma/standard_document/sections/preface.rb +36 -0
  185. data/lib/metanorma/standard_document/sections/sections.rb +40 -0
  186. data/lib/metanorma/standard_document/sections/standard_content_section.rb +26 -12
  187. data/lib/metanorma/standard_document/sections/terms_section.rb +45 -13
  188. data/lib/metanorma/standard_document/sections.rb +6 -2
  189. data/lib/metanorma/standard_document/terms/designation.rb +1 -1
  190. data/lib/metanorma/standard_document/terms/term_expression.rb +51 -0
  191. data/lib/metanorma/standard_document/terms.rb +1 -0
  192. data/lib/metanorma/standard_document.rb +10 -2
  193. data/lib/metanorma/un_document/metadata/un_bib_data_extension_type.rb +10 -0
  194. data/lib/metanorma/un_document/metadata/un_bibliographic_item.rb +15 -0
  195. data/lib/metanorma/un_document/metadata.rb +12 -0
  196. data/lib/metanorma/un_document/root.rb +29 -0
  197. data/lib/metanorma/un_document/sections/un_preface.rb +23 -0
  198. data/lib/metanorma/un_document/sections/un_sections.rb +24 -0
  199. data/lib/metanorma/un_document/sections.rb +10 -0
  200. data/lib/metanorma/un_document.rb +11 -0
  201. metadata +77 -3
  202. data/lib/metanorma/html/whitespace_patch.rb +0 -47
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module PlateauDocument
5
+ module Metadata
6
+ autoload :PlateauBibliographicItem,
7
+ "#{__dir__}/metadata/plateau_bibliographic_item"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module PlateauDocument
5
+ class Root < Lutaml::Model::Serializable
6
+ include Metanorma::StandardDocument::RootAttributes
7
+
8
+ def self.lutaml_default_register
9
+ :plateau_document
10
+ end
11
+
12
+ attribute :bibdata, Metadata::PlateauBibliographicItem
13
+ attribute :preface,
14
+ Metanorma::IsoDocument::Sections::IsoPreface
15
+ attribute :sections,
16
+ Metanorma::IsoDocument::Sections::IsoSections
17
+ attribute :annex,
18
+ Metanorma::JisDocument::Sections::JisAnnexSection,
19
+ collection: true
20
+
21
+ xml do
22
+ element "metanorma"
23
+ namespace Metanorma::StandardDocument::Namespace
24
+
25
+ Metanorma::StandardDocument::RootXmlMapping.apply(self)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module PlateauDocument
5
+ autoload :Metadata, "metanorma/plateau_document/metadata"
6
+ autoload :Root, "metanorma/plateau_document/root"
7
+ end
8
+ end
9
+
10
+ Metanorma::Registers::Setup.setup_plateau_register
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module Registers
5
+ module Setup
6
+ class << self
7
+ # ============================================================
8
+ # ISO-family registers — fallback to :iso_document
9
+ # ============================================================
10
+
11
+ def setup_iso_register
12
+ sd = Metanorma::StandardDocument
13
+ iso = Metanorma::IsoDocument
14
+ reg = Lutaml::Model::Register.new(:iso_document)
15
+ Lutaml::Model::GlobalRegister.register(reg)
16
+
17
+ reg.register_global_type_substitution(
18
+ from_type: sd::Sections::ClauseSection,
19
+ to_type: iso::Sections::IsoClauseSection,
20
+ )
21
+ reg.register_global_type_substitution(
22
+ from_type: sd::Sections::AnnexSection,
23
+ to_type: iso::Sections::IsoAnnexSection,
24
+ )
25
+ reg.register_global_type_substitution(
26
+ from_type: sd::Sections::Sections,
27
+ to_type: iso::Sections::IsoSections,
28
+ )
29
+ reg.register_global_type_substitution(
30
+ from_type: sd::Sections::Preface,
31
+ to_type: iso::Sections::IsoPreface,
32
+ )
33
+ end
34
+
35
+ def setup_iec_register
36
+ reg = Lutaml::Model::Register.new(:iec_document,
37
+ fallback: [:iso_document])
38
+ Lutaml::Model::GlobalRegister.register(reg)
39
+ end
40
+
41
+ def setup_oiml_register
42
+ reg = Lutaml::Model::Register.new(:oiml_document,
43
+ fallback: [:iso_document])
44
+ Lutaml::Model::GlobalRegister.register(reg)
45
+ end
46
+
47
+ def setup_bsi_register
48
+ iso = Metanorma::IsoDocument
49
+ reg = Lutaml::Model::Register.new(:bsi_document,
50
+ fallback: [:iso_document])
51
+ Lutaml::Model::GlobalRegister.register(reg)
52
+
53
+ reg.register_global_type_substitution(
54
+ from_type: iso::Sections::IsoSections,
55
+ to_type: Metanorma::BsiDocument::Sections::BsiSections,
56
+ )
57
+ reg.register_global_type_substitution(
58
+ from_type: iso::Sections::IsoClauseSection,
59
+ to_type: Metanorma::BsiDocument::Sections::BsiClauseSection,
60
+ )
61
+ reg.register_global_type_substitution(
62
+ from_type: iso::Sections::IsoAnnexSection,
63
+ to_type: Metanorma::BsiDocument::Sections::BsiAnnexSection,
64
+ )
65
+ end
66
+
67
+ def setup_jis_register
68
+ iso = Metanorma::IsoDocument
69
+ reg = Lutaml::Model::Register.new(:jis_document,
70
+ fallback: [:iso_document])
71
+ Lutaml::Model::GlobalRegister.register(reg)
72
+
73
+ reg.register_global_type_substitution(
74
+ from_type: iso::Sections::IsoAnnexSection,
75
+ to_type: Metanorma::JisDocument::Sections::JisAnnexSection,
76
+ )
77
+ end
78
+
79
+ def setup_gb_register
80
+ reg = Lutaml::Model::Register.new(:gb_document,
81
+ fallback: [:iso_document])
82
+ Lutaml::Model::GlobalRegister.register(reg)
83
+ end
84
+
85
+ def setup_m3d_register
86
+ reg = Lutaml::Model::Register.new(:m3d_document)
87
+ Lutaml::Model::GlobalRegister.register(reg)
88
+ end
89
+
90
+ def setup_plateau_register
91
+ reg = Lutaml::Model::Register.new(:plateau_document,
92
+ fallback: [:jis_document])
93
+ Lutaml::Model::GlobalRegister.register(reg)
94
+ end
95
+
96
+ # ============================================================
97
+ # Isodoc-family registers — no ISO fallback
98
+ # ============================================================
99
+
100
+ def setup_ieee_register
101
+ sd = Metanorma::StandardDocument
102
+ reg = Lutaml::Model::Register.new(:ieee_document)
103
+ Lutaml::Model::GlobalRegister.register(reg)
104
+
105
+ reg.register_global_type_substitution(
106
+ from_type: sd::Sections::Sections,
107
+ to_type: Metanorma::IeeeDocument::Sections::IeeeSections,
108
+ )
109
+ end
110
+
111
+ def setup_ietf_register
112
+ sd = Metanorma::StandardDocument
113
+ reg = Lutaml::Model::Register.new(:ietf_document)
114
+ Lutaml::Model::GlobalRegister.register(reg)
115
+
116
+ reg.register_global_type_substitution(
117
+ from_type: sd::Sections::Sections,
118
+ to_type: Metanorma::IetfDocument::Sections::IetfSections,
119
+ )
120
+ reg.register_global_type_substitution(
121
+ from_type: sd::Sections::ContentSection,
122
+ to_type: Metanorma::IetfDocument::Sections::IetfContentSection,
123
+ )
124
+ reg.register_global_type_substitution(
125
+ from_type: sd::Sections::ClauseSection,
126
+ to_type: Metanorma::IetfDocument::Sections::IetfClauseSection,
127
+ )
128
+ reg.register_global_type_substitution(
129
+ from_type: sd::Sections::AnnexSection,
130
+ to_type: Metanorma::IetfDocument::Sections::IetfAnnexSection,
131
+ )
132
+ end
133
+
134
+ def setup_nist_register
135
+ sd = Metanorma::StandardDocument
136
+ reg = Lutaml::Model::Register.new(:nist_document)
137
+ Lutaml::Model::GlobalRegister.register(reg)
138
+
139
+ reg.register_global_type_substitution(
140
+ from_type: sd::Sections::Preface,
141
+ to_type: Metanorma::NistDocument::Sections::NistPreface,
142
+ )
143
+ end
144
+
145
+ def setup_un_register
146
+ sd = Metanorma::StandardDocument
147
+ reg = Lutaml::Model::Register.new(:un_document)
148
+ Lutaml::Model::GlobalRegister.register(reg)
149
+
150
+ reg.register_global_type_substitution(
151
+ from_type: sd::Sections::Sections,
152
+ to_type: Metanorma::UnDocument::Sections::UnSections,
153
+ )
154
+ reg.register_global_type_substitution(
155
+ from_type: sd::Sections::Preface,
156
+ to_type: Metanorma::UnDocument::Sections::UnPreface,
157
+ )
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module Registers
5
+ autoload :Setup, "#{__dir__}/registers/setup"
6
+ end
7
+ end
@@ -1,67 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "metanorma/standard_document"
4
- require "metanorma/iso_document"
5
-
6
3
  module Metanorma
7
4
  module RiboseDocument
8
- # Most basic document flavor — uses StandardDocument metadata
9
- # but ISO document structure for sections/blocks.
10
- class Root < Metanorma::StandardDocument::Root
11
- attribute :version, :string
12
- attribute :type, :string
13
- attribute :schema_version, :string
14
- attribute :flavor, :string
5
+ class Root < Lutaml::Model::Serializable
6
+ include Metanorma::StandardDocument::RootAttributes
15
7
 
16
8
  attribute :bibdata,
17
9
  Metanorma::RiboseDocument::Metadata::RiboseBibliographicItem
18
-
19
- attribute :term_sources,
20
- Metanorma::Document::Components::ReferenceElements::Citation,
10
+ attribute :preface,
11
+ Metanorma::StandardDocument::Sections::Preface
12
+ attribute :sections,
13
+ Metanorma::StandardDocument::Sections::Sections
14
+ attribute :annex,
15
+ Metanorma::StandardDocument::Sections::AnnexSection,
21
16
  collection: true
22
17
 
23
- attribute :preface, Metanorma::IsoDocument::Sections::IsoPreface
24
- attribute :sections, Metanorma::IsoDocument::Sections::IsoSections
25
- attribute :annex, Metanorma::IsoDocument::Sections::IsoAnnexSection,
26
- collection: true
27
- attribute :bibliography,
28
- Metanorma::StandardDocument::Sections::BibliographySection
29
- attribute :boilerplate, Metanorma::IsoDocument::Boilerplate
30
- attribute :metanorma_extension,
31
- Metanorma::IsoDocument::Metadata::MetanormaExtension
32
- attribute :annotation_container, Metanorma::IsoDocument::AnnotationContainer
33
- attribute :indexsect,
34
- Metanorma::Document::Components::Sections::BasicSection
35
- attribute :autonum, :string
36
- attribute :fmt_xref_label, :string
37
- attribute :localized_strings,
38
- Metanorma::Document::Components::Inline::LocalizedStringsElement
39
- attribute :fmt_footnote_container,
40
- Metanorma::Document::Components::Inline::FmtFootnoteContainerElement
41
- attribute :colophon, Metanorma::IsoDocument::Sections::Colophon
42
-
43
18
  xml do
44
19
  element "metanorma"
45
20
  namespace Metanorma::StandardDocument::Namespace
46
- map_attribute "type", to: :type
47
- map_attribute "version", to: :version
48
- map_attribute "schema-version", to: :schema_version
49
- map_attribute "flavor", to: :flavor
50
- map_element "bibdata", to: :bibdata
51
- map_element "termdocsource", to: :term_sources
52
- map_element "metanorma-extension", to: :metanorma_extension
53
- map_element "boilerplate", to: :boilerplate
54
- map_element "preface", to: :preface
55
- map_element "sections", to: :sections
56
- map_element "annex", to: :annex
57
- map_element "bibliography", to: :bibliography
58
- map_element "annotation-container", to: :annotation_container
59
- map_element "indexsect", to: :indexsect
60
- map_element "localized-strings", to: :localized_strings
61
- map_element "fmt-footnote-container", to: :fmt_footnote_container
62
- map_element "colophon", to: :colophon
63
- map_attribute "autonum", to: :autonum
64
- map_attribute "fmt-xref-label", to: :fmt_xref_label
21
+
22
+ Metanorma::StandardDocument::RootXmlMapping.apply(self)
65
23
  end
66
24
  end
67
25
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "metanorma/standard_document"
4
-
5
3
  module Metanorma
6
4
  module RiboseDocument
7
5
  autoload :Metadata, "metanorma/ribose_document/metadata"
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ class AnnotationContainer < Lutaml::Model::Serializable
6
+ attribute :content, :string
7
+
8
+ xml do
9
+ element "annotation-container"
10
+ map_all_content to: :content
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,268 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ # Mixin that declares individually-typed block collection attributes
6
+ # for section-level models (ClauseSection, AnnexSection, ContentSection, etc.).
7
+ #
8
+ # Include this module in any Serializable class that represents a section
9
+ # body containing heterogeneous block-level content (paragraphs, tables,
10
+ # figures, etc.).
11
+ module BlockAttributes
12
+ def self.included(base)
13
+ base.class_eval do
14
+ attribute :paragraphs,
15
+ Metanorma::Document::Components::Paragraphs::ParagraphBlock,
16
+ collection: true
17
+ attribute :unordered_lists,
18
+ Metanorma::Document::Components::Lists::UnorderedList,
19
+ collection: true
20
+ attribute :ordered_lists,
21
+ Metanorma::Document::Components::Lists::OrderedList,
22
+ collection: true
23
+ attribute :tables,
24
+ Metanorma::Document::Components::Tables::TableBlock,
25
+ collection: true
26
+ attribute :figures,
27
+ Metanorma::Document::Components::AncillaryBlocks::FigureBlock,
28
+ collection: true
29
+ attribute :formulas,
30
+ Metanorma::Document::Components::AncillaryBlocks::FormulaBlock,
31
+ collection: true
32
+ attribute :examples,
33
+ Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
34
+ collection: true
35
+ attribute :notes,
36
+ Metanorma::Document::Components::Blocks::NoteBlock,
37
+ collection: true
38
+ attribute :admonitions,
39
+ Metanorma::Document::Components::MultiParagraph::AdmonitionBlock,
40
+ collection: true
41
+ attribute :sourcecode_blocks,
42
+ Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock,
43
+ collection: true
44
+ attribute :quote_blocks,
45
+ Metanorma::Document::Components::MultiParagraph::QuoteBlock,
46
+ collection: true
47
+ attribute :definition_lists,
48
+ Metanorma::Document::Components::Lists::DefinitionList,
49
+ collection: true
50
+ end
51
+ end
52
+ end
53
+
54
+ # Provides `blocks` method for ordered-content section types.
55
+ # Returns child nodes in document order via `each_mixed_content`.
56
+ module OrderedContent
57
+ def blocks
58
+ @blocks ||=
59
+ begin
60
+ result = []
61
+ each_mixed_content do |node|
62
+ result << node unless node.is_a?(String)
63
+ end
64
+ result
65
+ end
66
+ end
67
+ end
68
+
69
+ # Presentation/formatting attributes shared by all section types.
70
+ # Include in any section class that supports presentation metadata.
71
+ module PresentationAttributes
72
+ def self.included(base)
73
+ base.class_eval do
74
+ attribute :anchor, :string
75
+ attribute :semx_id, :string
76
+ attribute :autonum, :string
77
+ attribute :displayorder, :integer
78
+ attribute :fmt_title,
79
+ Metanorma::Document::Components::Inline::FmtTitleElement
80
+ attribute :fmt_xref_label,
81
+ Metanorma::Document::Components::Inline::FmtXrefLabelElement,
82
+ collection: true
83
+ attribute :variant_title,
84
+ Metanorma::Document::Components::Inline::VariantTitleElement,
85
+ collection: true
86
+ attribute :fmt_annotation_start,
87
+ Metanorma::Document::Components::Inline::FmtAnnotationStartElement,
88
+ collection: true
89
+ attribute :fmt_annotation_end,
90
+ Metanorma::Document::Components::Inline::FmtAnnotationEndElement,
91
+ collection: true
92
+ end
93
+ end
94
+ end
95
+
96
+ # Adds XML element mappings for block-level content to a mapping builder.
97
+ # Call inside an `xml do` block:
98
+ #
99
+ # xml do
100
+ # element "clause"
101
+ # ordered
102
+ # BlockXmlMapping.apply_block_mappings(self)
103
+ # # ... additional mappings
104
+ # end
105
+ module BlockXmlMapping
106
+ BLOCK_MAPPINGS = {
107
+ "p" => :paragraphs,
108
+ "ul" => :unordered_lists,
109
+ "ol" => :ordered_lists,
110
+ "table" => :tables,
111
+ "figure" => :figures,
112
+ "formula" => :formulas,
113
+ "example" => :examples,
114
+ "note" => :notes,
115
+ "admonition" => :admonitions,
116
+ "sourcecode" => :sourcecode_blocks,
117
+ "quote" => :quote_blocks,
118
+ "dl" => :definition_lists,
119
+ }.freeze
120
+
121
+ def self.apply_block_mappings(mapping)
122
+ BLOCK_MAPPINGS.each do |element_name, attr_name|
123
+ mapping.map_element(element_name, to: attr_name)
124
+ end
125
+ end
126
+ end
127
+
128
+ # Shared XML mapping helpers for section-level elements.
129
+ # Extracts the common attribute/element mappings duplicated across
130
+ # ClauseSection, AnnexSection, and their flavor-specific subclasses.
131
+ module SectionXmlMapping
132
+ # Common XML attribute mappings for clause sections.
133
+ def self.apply_clause_attributes(mapping)
134
+ mapping.map_attribute "id", to: :id
135
+ mapping.map_attribute "anchor", to: :anchor
136
+ mapping.map_attribute "type", to: :type
137
+ mapping.map_attribute "number", to: :number
138
+ mapping.map_attribute "obligation", to: :obligation
139
+ mapping.map_attribute "inline-header", to: :inline_header
140
+ mapping.map_attribute "unnumbered", to: :unnumbered
141
+ mapping.map_attribute "toc", to: :toc
142
+ mapping.map_attribute "class", to: :class_attr
143
+ mapping.map_attribute "semx-id", to: :semx_id
144
+ mapping.map_attribute "autonum", to: :autonum
145
+ mapping.map_attribute "displayorder", to: :displayorder
146
+ end
147
+
148
+ # Common XML element mappings for clause sections.
149
+ def self.apply_clause_elements(mapping)
150
+ mapping.map_element "title", to: :title
151
+ mapping.map_element "variant-title", to: :variant_title
152
+ mapping.map_element "fmt-title", to: :fmt_title
153
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
154
+
155
+ BlockXmlMapping.apply_block_mappings(mapping)
156
+
157
+ mapping.map_element "amend", to: :amend
158
+ mapping.map_element "clause", to: :clause
159
+ mapping.map_element "terms", to: :terms
160
+ mapping.map_element "definitions", to: :definitions
161
+ mapping.map_element "references", to: :references
162
+ mapping.map_element "floating-title", to: :floating_title
163
+ mapping.map_element "form", to: :form
164
+ mapping.map_element "requirement", to: :requirement
165
+ mapping.map_element "recommendation", to: :recommendation
166
+ mapping.map_element "permission", to: :permission
167
+ mapping.map_element "pagebreak", to: :pagebreak
168
+ mapping.map_element "bookmark", to: :bookmark
169
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
170
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
171
+ end
172
+
173
+ # Common XML attribute mappings for annex sections.
174
+ def self.apply_annex_attributes(mapping)
175
+ mapping.map_attribute "id", to: :id
176
+ mapping.map_attribute "number", to: :number
177
+ mapping.map_attribute "obligation", to: :obligation,
178
+ render_empty: true
179
+ mapping.map_attribute "unnumbered", to: :unnumbered
180
+ mapping.map_attribute "toc", to: :toc
181
+ mapping.map_attribute "anchor", to: :anchor
182
+ mapping.map_attribute "semx-id", to: :semx_id
183
+ mapping.map_attribute "autonum", to: :autonum
184
+ mapping.map_attribute "displayorder", to: :displayorder
185
+ mapping.map_attribute "inline-header", to: :inline_header
186
+ mapping.map_attribute "language", to: :language, render_empty: true
187
+ mapping.map_attribute "script", to: :script, render_empty: true
188
+ end
189
+
190
+ # Common XML element mappings for annex sections.
191
+ def self.apply_annex_elements(mapping)
192
+ mapping.map_element "title", to: :title
193
+ mapping.map_element "variant-title", to: :variant_title
194
+ mapping.map_element "fmt-title", to: :fmt_title
195
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
196
+
197
+ BlockXmlMapping.apply_block_mappings(mapping)
198
+
199
+ mapping.map_element "clause", to: :clause
200
+ mapping.map_element "appendix", to: :appendix
201
+ mapping.map_element "terms", to: :terms
202
+ mapping.map_element "definitions", to: :definitions
203
+ mapping.map_element "references", to: :references
204
+ mapping.map_element "floating-title", to: :floating_title
205
+ mapping.map_element "pagebreak", to: :pagebreak
206
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
207
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
208
+ end
209
+
210
+ # Common XML element/attribute mappings for the sections container.
211
+ def self.apply_sections_elements(mapping)
212
+ mapping.map_element "clause", to: :clause
213
+ mapping.map_element "terms", to: :terms
214
+ mapping.map_element "definitions", to: :definitions
215
+ mapping.map_element "floating-title", to: :floating_title
216
+ mapping.map_element "references", to: :references
217
+ end
218
+
219
+ def self.apply_sections_attributes(mapping)
220
+ mapping.map_attribute "semx-id", to: :semx_id
221
+ mapping.map_attribute "displayorder", to: :displayorder
222
+ end
223
+
224
+ # Common XML element/attribute mappings for preface containers.
225
+ def self.apply_preface_elements(mapping)
226
+ mapping.map_element "abstract", to: :abstract
227
+ mapping.map_element "foreword", to: :foreword
228
+ mapping.map_element "introduction", to: :introduction
229
+ mapping.map_element "acknowledgements", to: :acknowledgements
230
+ mapping.map_element "executivesummary", to: :executivesummary
231
+ end
232
+
233
+ def self.apply_preface_attributes(mapping)
234
+ mapping.map_attribute "semx-id", to: :semx_id
235
+ mapping.map_attribute "displayorder", to: :displayorder
236
+ end
237
+
238
+ # Common XML attribute/element mappings for ContentSection subclasses.
239
+ def self.apply_content_section_attributes(mapping)
240
+ mapping.map_attribute "id", to: :id
241
+ mapping.map_attribute "anchor", to: :anchor
242
+ mapping.map_attribute "type", to: :type
243
+ mapping.map_attribute "number", to: :number
244
+ mapping.map_attribute "obligation", to: :obligation
245
+ mapping.map_attribute "inline-header", to: :inline_header
246
+ mapping.map_attribute "unnumbered", to: :unnumbered
247
+ mapping.map_attribute "toc", to: :toc
248
+ mapping.map_attribute "class", to: :class_attr
249
+ mapping.map_attribute "semx-id", to: :semx_id
250
+ mapping.map_attribute "autonum", to: :autonum
251
+ mapping.map_attribute "displayorder", to: :displayorder
252
+ end
253
+
254
+ def self.apply_content_section_elements(mapping)
255
+ mapping.map_element "title", to: :title
256
+ mapping.map_element "variant-title", to: :variant_title
257
+ mapping.map_element "fmt-title", to: :fmt_title
258
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
259
+
260
+ BlockXmlMapping.apply_block_mappings(mapping)
261
+
262
+ mapping.map_element "clause", to: :subsection
263
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
264
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
265
+ end
266
+ end
267
+ end
268
+ end
@@ -1,20 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Metanorma
4
- module StandardDocument
5
- module Blocks
6
- # Wrapper around raw markup to be transferred into one or more nominated output formats
7
- # during processing.
8
- class Passthrough < Metanorma::StandardDocument::Blocks::StandardBlockNoNotes
9
- attribute :formats, :string
10
- attribute :content, :string
11
-
12
- xml do
13
- element "passthrough"
14
- map_attribute "formats", to: :formats
15
- map_content to: :content
16
- end
17
- end
18
- end
19
- end
20
- end
3
+ Metanorma::StandardDocument::Blocks::Passthrough = Metanorma::Document::Components::Blocks::Passthrough