metanorma-document 0.2.5 → 0.2.7

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 (205) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +321 -45
  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 +245 -113
  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/admonition_drop.rb +2 -1
  74. data/lib/metanorma/html/drops/example_drop.rb +2 -11
  75. data/lib/metanorma/html/drops/figure_drop.rb +14 -5
  76. data/lib/metanorma/html/drops/formula_drop.rb +7 -2
  77. data/lib/metanorma/html/drops/note_drop.rb +2 -3
  78. data/lib/metanorma/html/drops/sourcecode_drop.rb +6 -2
  79. data/lib/metanorma/html/drops.rb +2 -1
  80. data/lib/metanorma/html/generator.rb +33 -16
  81. data/lib/metanorma/html/iec_renderer.rb +0 -1
  82. data/lib/metanorma/html/ieee_renderer.rb +0 -1
  83. data/lib/metanorma/html/ietf_renderer.rb +0 -1
  84. data/lib/metanorma/html/iho_renderer.rb +1 -2
  85. data/lib/metanorma/html/iso_renderer.rb +68 -23
  86. data/lib/metanorma/html/itu_renderer.rb +0 -1
  87. data/lib/metanorma/html/ogc_renderer.rb +0 -1
  88. data/lib/metanorma/html/oiml_renderer.rb +0 -1
  89. data/lib/metanorma/html/pdfa_renderer.rb +0 -1
  90. data/lib/metanorma/html/ribose_renderer.rb +0 -1
  91. data/lib/metanorma/html/standard_renderer.rb +61 -28
  92. data/lib/metanorma/html/theme.rb +2 -2
  93. data/lib/metanorma/html.rb +48 -1
  94. data/lib/metanorma/iec_document/root.rb +8 -47
  95. data/lib/metanorma/iec_document.rb +2 -3
  96. data/lib/metanorma/ieee_document/root.rb +14 -50
  97. data/lib/metanorma/ieee_document/sections/ieee_sections.rb +31 -0
  98. data/lib/metanorma/ieee_document/sections.rb +9 -0
  99. data/lib/metanorma/ieee_document.rb +3 -3
  100. data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -2
  101. data/lib/metanorma/ietf_document/metadata/ietf_bibliographic_item.rb +0 -2
  102. data/lib/metanorma/ietf_document/root.rb +14 -50
  103. data/lib/metanorma/ietf_document/sections/ietf_annex_section.rb +26 -0
  104. data/lib/metanorma/ietf_document/sections/ietf_clause_section.rb +26 -0
  105. data/lib/metanorma/ietf_document/sections/ietf_content_section.rb +25 -0
  106. data/lib/metanorma/ietf_document/sections/ietf_sections.rb +35 -0
  107. data/lib/metanorma/ietf_document/sections.rb +4 -23
  108. data/lib/metanorma/ietf_document.rb +4 -3
  109. data/lib/metanorma/iho_document/metadata/iho_bib_data_extension_type.rb +0 -2
  110. data/lib/metanorma/iho_document/root.rb +10 -50
  111. data/lib/metanorma/iho_document.rb +0 -3
  112. data/lib/metanorma/iso_document/annotation_container.rb +1 -10
  113. data/lib/metanorma/iso_document/boilerplate.rb +1 -11
  114. data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +2 -2
  115. data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +4 -3
  116. data/lib/metanorma/iso_document/metadata/metanorma_extension.rb +1 -12
  117. data/lib/metanorma/iso_document/root.rb +7 -73
  118. data/lib/metanorma/iso_document/sections/colophon.rb +1 -16
  119. data/lib/metanorma/iso_document/sections/iso_annex_section.rb +11 -133
  120. data/lib/metanorma/iso_document/sections/iso_clause_section.rb +9 -166
  121. data/lib/metanorma/iso_document/sections/iso_foreword_section.rb +15 -89
  122. data/lib/metanorma/iso_document/sections/iso_preface.rb +15 -21
  123. data/lib/metanorma/iso_document/sections/iso_sections.rb +19 -29
  124. data/lib/metanorma/iso_document/sections/iso_terms_section.rb +6 -9
  125. data/lib/metanorma/iso_document/terms/term_expression.rb +2 -47
  126. data/lib/metanorma/iso_document/terms/term_origin.rb +2 -24
  127. data/lib/metanorma/iso_document/terms/term_source.rb +4 -32
  128. data/lib/metanorma/iso_document.rb +2 -2
  129. data/lib/metanorma/itu_document/root.rb +10 -50
  130. data/lib/metanorma/itu_document.rb +0 -2
  131. data/lib/metanorma/jis_document/metadata/jis_bib_data_extension_type.rb +10 -0
  132. data/lib/metanorma/jis_document/metadata/jis_bibliographic_item.rb +15 -0
  133. data/lib/metanorma/jis_document/metadata.rb +12 -0
  134. data/lib/metanorma/jis_document/root.rb +29 -0
  135. data/lib/metanorma/jis_document/sections/jis_annex_section.rb +20 -0
  136. data/lib/metanorma/jis_document/sections.rb +9 -0
  137. data/lib/metanorma/jis_document.rb +11 -0
  138. data/lib/metanorma/m3d_document/metadata/m3d_bib_data_extension_type.rb +10 -0
  139. data/lib/metanorma/m3d_document/metadata/m3d_bibliographic_item.rb +15 -0
  140. data/lib/metanorma/m3d_document/metadata.rb +12 -0
  141. data/lib/metanorma/m3d_document/root.rb +29 -0
  142. data/lib/metanorma/m3d_document.rb +10 -0
  143. data/lib/metanorma/nist_document/metadata/nist_bib_data_extension_type.rb +10 -0
  144. data/lib/metanorma/nist_document/metadata/nist_bibliographic_item.rb +15 -0
  145. data/lib/metanorma/nist_document/metadata.rb +12 -0
  146. data/lib/metanorma/nist_document/root.rb +29 -0
  147. data/lib/metanorma/nist_document/sections/errata.rb +16 -0
  148. data/lib/metanorma/nist_document/sections/errata_clause.rb +20 -0
  149. data/lib/metanorma/nist_document/sections/errata_row.rb +22 -0
  150. data/lib/metanorma/nist_document/sections/nist_preface.rb +30 -0
  151. data/lib/metanorma/nist_document/sections.rb +12 -0
  152. data/lib/metanorma/nist_document.rb +11 -0
  153. data/lib/metanorma/ogc_document/root.rb +10 -50
  154. data/lib/metanorma/ogc_document.rb +0 -2
  155. data/lib/metanorma/oiml_document/root.rb +8 -47
  156. data/lib/metanorma/oiml_document.rb +2 -3
  157. data/lib/metanorma/plateau_document/metadata/plateau_bibliographic_item.rb +13 -0
  158. data/lib/metanorma/plateau_document/metadata.rb +10 -0
  159. data/lib/metanorma/plateau_document/root.rb +29 -0
  160. data/lib/metanorma/plateau_document.rb +10 -0
  161. data/lib/metanorma/registers/setup.rb +162 -0
  162. data/lib/metanorma/registers.rb +7 -0
  163. data/lib/metanorma/ribose_document/root.rb +10 -52
  164. data/lib/metanorma/ribose_document.rb +0 -2
  165. data/lib/metanorma/standard_document/annotation_container.rb +14 -0
  166. data/lib/metanorma/standard_document/block_attributes.rb +226 -0
  167. data/lib/metanorma/standard_document/blocks/passthrough.rb +1 -18
  168. data/lib/metanorma/standard_document/blocks/requirement_model.rb +18 -163
  169. data/lib/metanorma/standard_document/boilerplate.rb +14 -0
  170. data/lib/metanorma/standard_document/elements/add.rb +1 -17
  171. data/lib/metanorma/standard_document/elements/del.rb +1 -17
  172. data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +16 -0
  173. data/lib/metanorma/standard_document/metadata.rb +2 -0
  174. data/lib/metanorma/standard_document/refs/reference_to_term.rb +2 -1
  175. data/lib/metanorma/standard_document/root_attributes.rb +78 -0
  176. data/lib/metanorma/standard_document/sections/abstract.rb +1 -3
  177. data/lib/metanorma/standard_document/sections/acknowledgements.rb +1 -3
  178. data/lib/metanorma/standard_document/sections/annex_section.rb +81 -16
  179. data/lib/metanorma/standard_document/sections/bibliography_section.rb +1 -2
  180. data/lib/metanorma/standard_document/sections/clause_section.rb +102 -10
  181. data/lib/metanorma/standard_document/sections/colophon.rb +16 -0
  182. data/lib/metanorma/standard_document/sections/definition_section.rb +45 -42
  183. data/lib/metanorma/standard_document/sections/floating_section_title.rb +23 -0
  184. data/lib/metanorma/standard_document/sections/foreword.rb +1 -3
  185. data/lib/metanorma/standard_document/sections/introduction.rb +1 -4
  186. data/lib/metanorma/standard_document/sections/misc_container.rb +5 -2
  187. data/lib/metanorma/standard_document/sections/preface.rb +36 -0
  188. data/lib/metanorma/standard_document/sections/sections.rb +40 -0
  189. data/lib/metanorma/standard_document/sections/standard_content_section.rb +42 -9
  190. data/lib/metanorma/standard_document/sections/terms_section.rb +52 -10
  191. data/lib/metanorma/standard_document/sections.rb +6 -2
  192. data/lib/metanorma/standard_document/terms/designation.rb +1 -1
  193. data/lib/metanorma/standard_document/terms/term_expression.rb +51 -0
  194. data/lib/metanorma/standard_document/terms.rb +1 -0
  195. data/lib/metanorma/standard_document.rb +7 -2
  196. data/lib/metanorma/un_document/metadata/un_bib_data_extension_type.rb +10 -0
  197. data/lib/metanorma/un_document/metadata/un_bibliographic_item.rb +15 -0
  198. data/lib/metanorma/un_document/metadata.rb +12 -0
  199. data/lib/metanorma/un_document/root.rb +29 -0
  200. data/lib/metanorma/un_document/sections/un_preface.rb +23 -0
  201. data/lib/metanorma/un_document/sections/un_sections.rb +24 -0
  202. data/lib/metanorma/un_document/sections.rb +10 -0
  203. data/lib/metanorma/un_document.rb +11 -0
  204. metadata +77 -3
  205. 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,226 @@
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
+ # Adds XML element mappings for block-level content to a mapping builder.
55
+ # Call inside an `xml do` block:
56
+ #
57
+ # xml do
58
+ # element "clause"
59
+ # ordered
60
+ # BlockXmlMapping.apply_block_mappings(self)
61
+ # # ... additional mappings
62
+ # end
63
+ module BlockXmlMapping
64
+ BLOCK_MAPPINGS = {
65
+ "p" => :paragraphs,
66
+ "ul" => :unordered_lists,
67
+ "ol" => :ordered_lists,
68
+ "table" => :tables,
69
+ "figure" => :figures,
70
+ "formula" => :formulas,
71
+ "example" => :examples,
72
+ "note" => :notes,
73
+ "admonition" => :admonitions,
74
+ "sourcecode" => :sourcecode_blocks,
75
+ "quote" => :quote_blocks,
76
+ "dl" => :definition_lists,
77
+ }.freeze
78
+
79
+ def self.apply_block_mappings(mapping)
80
+ BLOCK_MAPPINGS.each do |element_name, attr_name|
81
+ mapping.map_element(element_name, to: attr_name)
82
+ end
83
+ end
84
+ end
85
+
86
+ # Shared XML mapping helpers for section-level elements.
87
+ # Extracts the common attribute/element mappings duplicated across
88
+ # ClauseSection, AnnexSection, and their flavor-specific subclasses.
89
+ module SectionXmlMapping
90
+ # Common XML attribute mappings for clause sections.
91
+ def self.apply_clause_attributes(mapping)
92
+ mapping.map_attribute "id", to: :id
93
+ mapping.map_attribute "anchor", to: :anchor
94
+ mapping.map_attribute "type", to: :type
95
+ mapping.map_attribute "number", to: :number
96
+ mapping.map_attribute "obligation", to: :obligation
97
+ mapping.map_attribute "inline-header", to: :inline_header
98
+ mapping.map_attribute "unnumbered", to: :unnumbered
99
+ mapping.map_attribute "toc", to: :toc
100
+ mapping.map_attribute "class", to: :class_attr
101
+ mapping.map_attribute "semx-id", to: :semx_id
102
+ mapping.map_attribute "autonum", to: :autonum
103
+ mapping.map_attribute "displayorder", to: :displayorder
104
+ end
105
+
106
+ # Common XML element mappings for clause sections.
107
+ def self.apply_clause_elements(mapping)
108
+ mapping.map_element "title", to: :title
109
+ mapping.map_element "variant-title", to: :variant_title
110
+ mapping.map_element "fmt-title", to: :fmt_title
111
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
112
+
113
+ BlockXmlMapping.apply_block_mappings(mapping)
114
+
115
+ mapping.map_element "amend", to: :amend
116
+ mapping.map_element "clause", to: :clause
117
+ mapping.map_element "terms", to: :terms
118
+ mapping.map_element "definitions", to: :definitions
119
+ mapping.map_element "references", to: :references
120
+ mapping.map_element "floating-title", to: :floating_title
121
+ mapping.map_element "form", to: :form
122
+ mapping.map_element "requirement", to: :requirement
123
+ mapping.map_element "recommendation", to: :recommendation
124
+ mapping.map_element "permission", to: :permission
125
+ mapping.map_element "pagebreak", to: :pagebreak
126
+ mapping.map_element "bookmark", to: :bookmark
127
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
128
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
129
+ end
130
+
131
+ # Common XML attribute mappings for annex sections.
132
+ def self.apply_annex_attributes(mapping)
133
+ mapping.map_attribute "id", to: :id
134
+ mapping.map_attribute "number", to: :number
135
+ mapping.map_attribute "obligation", to: :obligation,
136
+ render_empty: true
137
+ mapping.map_attribute "unnumbered", to: :unnumbered
138
+ mapping.map_attribute "toc", to: :toc
139
+ mapping.map_attribute "anchor", to: :anchor
140
+ mapping.map_attribute "semx-id", to: :semx_id
141
+ mapping.map_attribute "autonum", to: :autonum
142
+ mapping.map_attribute "displayorder", to: :displayorder
143
+ mapping.map_attribute "inline-header", to: :inline_header
144
+ mapping.map_attribute "language", to: :language, render_empty: true
145
+ mapping.map_attribute "script", to: :script, render_empty: true
146
+ end
147
+
148
+ # Common XML element mappings for annex sections.
149
+ def self.apply_annex_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 "clause", to: :clause
158
+ mapping.map_element "appendix", to: :appendix
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 "pagebreak", to: :pagebreak
164
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
165
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
166
+ end
167
+
168
+ # Common XML element/attribute mappings for the sections container.
169
+ def self.apply_sections_elements(mapping)
170
+ mapping.map_element "clause", to: :clause
171
+ mapping.map_element "terms", to: :terms
172
+ mapping.map_element "definitions", to: :definitions
173
+ mapping.map_element "floating-title", to: :floating_title
174
+ mapping.map_element "references", to: :references
175
+ end
176
+
177
+ def self.apply_sections_attributes(mapping)
178
+ mapping.map_attribute "semx-id", to: :semx_id
179
+ mapping.map_attribute "displayorder", to: :displayorder
180
+ end
181
+
182
+ # Common XML element/attribute mappings for preface containers.
183
+ def self.apply_preface_elements(mapping)
184
+ mapping.map_element "abstract", to: :abstract
185
+ mapping.map_element "foreword", to: :foreword
186
+ mapping.map_element "introduction", to: :introduction
187
+ mapping.map_element "acknowledgements", to: :acknowledgements
188
+ mapping.map_element "executivesummary", to: :executivesummary
189
+ end
190
+
191
+ def self.apply_preface_attributes(mapping)
192
+ mapping.map_attribute "semx-id", to: :semx_id
193
+ mapping.map_attribute "displayorder", to: :displayorder
194
+ end
195
+
196
+ # Common XML attribute/element mappings for ContentSection subclasses.
197
+ def self.apply_content_section_attributes(mapping)
198
+ mapping.map_attribute "id", to: :id
199
+ mapping.map_attribute "anchor", to: :anchor
200
+ mapping.map_attribute "type", to: :type
201
+ mapping.map_attribute "number", to: :number
202
+ mapping.map_attribute "obligation", to: :obligation
203
+ mapping.map_attribute "inline-header", to: :inline_header
204
+ mapping.map_attribute "unnumbered", to: :unnumbered
205
+ mapping.map_attribute "toc", to: :toc
206
+ mapping.map_attribute "class", to: :class_attr
207
+ mapping.map_attribute "semx-id", to: :semx_id
208
+ mapping.map_attribute "autonum", to: :autonum
209
+ mapping.map_attribute "displayorder", to: :displayorder
210
+ end
211
+
212
+ def self.apply_content_section_elements(mapping)
213
+ mapping.map_element "title", to: :title
214
+ mapping.map_element "variant-title", to: :variant_title
215
+ mapping.map_element "fmt-title", to: :fmt_title
216
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
217
+
218
+ BlockXmlMapping.apply_block_mappings(mapping)
219
+
220
+ mapping.map_element "clause", to: :subsection
221
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
222
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
223
+ end
224
+ end
225
+ end
226
+ 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