metanorma-document 0.5.1 → 0.5.2.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +81 -0
- data/Rakefile +3 -7
- data/data/themes/ogc.yaml +5 -0
- data/lib/metanorma/basic_document/ancillary_blocks/figure_block.rb +2 -2
- data/lib/metanorma/basic_document/multi_paragraph/admonition_block.rb +2 -2
- data/lib/metanorma/document/cli.rb +134 -0
- data/lib/metanorma/document/components/ancillary_blocks/figure_block.rb +5 -0
- data/lib/metanorma/document/components/ancillary_blocks/fmt_figure_element.rb +47 -0
- data/lib/metanorma/document/components/ancillary_blocks/formula_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/imagemap_element.rb +73 -0
- data/lib/metanorma/document/components/ancillary_blocks/literal_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/svg_target_element.rb +27 -0
- data/lib/metanorma/document/components/ancillary_blocks/svgmap_element.rb +28 -0
- data/lib/metanorma/document/components/ancillary_blocks.rb +4 -0
- data/lib/metanorma/document/components/bib_data/bibliographic_item.rb +4 -0
- data/lib/metanorma/document/components/blocks/fmt_provision.rb +25 -0
- data/lib/metanorma/document/components/blocks/note_block.rb +8 -0
- data/lib/metanorma/document/components/blocks/permission_model.rb +9 -0
- data/lib/metanorma/document/components/blocks/recommendation_model.rb +9 -0
- data/lib/metanorma/document/components/blocks/requirement_base.rb +12 -0
- data/lib/metanorma/document/components/blocks/requirement_import.rb +23 -0
- data/lib/metanorma/document/components/blocks/requirement_measurement_target.rb +23 -0
- data/lib/metanorma/document/components/blocks/requirement_model.rb +9 -0
- data/lib/metanorma/document/components/blocks/requirement_specification.rb +23 -0
- data/lib/metanorma/document/components/blocks/requirement_verification.rb +23 -0
- data/lib/metanorma/document/components/blocks.rb +8 -0
- data/lib/metanorma/document/components/data_types/formatted_string.rb +9 -0
- data/lib/metanorma/document/components/id_elements/image.rb +4 -0
- data/lib/metanorma/document/components/inline/columnbreak_element.rb +17 -0
- data/lib/metanorma/document/components/inline/concept_element.rb +18 -0
- data/lib/metanorma/document/components/inline/date_element.rb +29 -0
- data/lib/metanorma/document/components/inline/display_text_element.rb +2 -0
- data/lib/metanorma/document/components/inline/em_raw_element.rb +6 -7
- data/lib/metanorma/document/components/inline/eref_element.rb +48 -22
- data/lib/metanorma/document/components/inline/eref_stack.rb +23 -0
- data/lib/metanorma/document/components/inline/error_message.rb +28 -0
- data/lib/metanorma/document/components/inline/fmt_date_element.rb +28 -0
- data/lib/metanorma/document/components/inline/fmt_date_inline_element.rb +26 -0
- data/lib/metanorma/document/components/inline/fmt_eref_element.rb +25 -0
- data/lib/metanorma/document/components/inline/fmt_origin_element.rb +24 -0
- data/lib/metanorma/document/components/inline/fmt_preferred_element.rb +3 -0
- data/lib/metanorma/document/components/inline/fmt_source_element.rb +31 -0
- data/lib/metanorma/document/components/inline/fn_element.rb +11 -0
- data/lib/metanorma/document/components/inline/link_element.rb +8 -0
- data/lib/metanorma/document/components/inline/name_with_id_element.rb +2 -0
- data/lib/metanorma/document/components/inline/refterm_element.rb +21 -0
- data/lib/metanorma/document/components/inline/semx_element.rb +22 -0
- data/lib/metanorma/document/components/inline/sourcelocality_stack_element.rb +27 -0
- data/lib/metanorma/document/components/inline/span_element.rb +2 -0
- data/lib/metanorma/document/components/inline/stem_inline_element.rb +2 -0
- data/lib/metanorma/document/components/inline/strong_raw_element.rb +6 -9
- data/lib/metanorma/document/components/inline/sub_element.rb +2 -0
- data/lib/metanorma/document/components/inline/termref_element.rb +24 -0
- data/lib/metanorma/document/components/inline/title_with_annotation_element.rb +10 -31
- data/lib/metanorma/document/components/inline/variant_title_element.rb +2 -0
- data/lib/metanorma/document/components/inline/vocabulary.rb +36 -0
- data/lib/metanorma/document/components/inline.rb +23 -0
- data/lib/metanorma/document/components/lists/dd_element.rb +6 -1
- data/lib/metanorma/document/components/lists/definition.rb +2 -0
- data/lib/metanorma/document/components/lists/definition_list.rb +3 -0
- data/lib/metanorma/document/components/lists/dt_element.rb +3 -0
- data/lib/metanorma/document/components/lists/fmt_list_element.rb +73 -0
- data/lib/metanorma/document/components/lists/list_item.rb +3 -0
- data/lib/metanorma/document/components/lists/ordered_list.rb +4 -2
- data/lib/metanorma/document/components/lists/unordered_list.rb +2 -0
- data/lib/metanorma/document/components/lists.rb +2 -0
- data/lib/metanorma/document/components/multi_paragraph/quote_block.rb +16 -0
- data/lib/metanorma/document/components/multi_paragraph/review_block.rb +2 -2
- data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +15 -0
- data/lib/metanorma/document/components/reference_elements/citation.rb +7 -0
- data/lib/metanorma/document/components/reference_elements/source_element.rb +4 -0
- data/lib/metanorma/document/components/semantic/node.rb +46 -0
- data/lib/metanorma/document/components/semantic.rb +11 -0
- data/lib/metanorma/document/components/tables/header_table_cell.rb +1 -0
- data/lib/metanorma/document/components/tables/table_cell.rb +70 -44
- data/lib/metanorma/document/components/tables/text_table_cell.rb +1 -0
- data/lib/metanorma/document/components/tables/text_table_row.rb +2 -0
- data/lib/metanorma/document/components/text_elements/ruby_annotation_element.rb +26 -0
- data/lib/metanorma/document/components/text_elements/ruby_element.rb +41 -6
- data/lib/metanorma/document/components/text_elements/ruby_pronunciation_element.rb +25 -0
- data/lib/metanorma/document/components/text_elements/strike_element.rb +3 -0
- data/lib/metanorma/document/components/text_elements/underline_element.rb +3 -0
- data/lib/metanorma/document/components/text_elements.rb +2 -0
- data/lib/metanorma/document/components.rb +1 -0
- data/lib/metanorma/document/grammar_vocabulary.rb +109 -0
- data/lib/metanorma/document/mirror_seed.rb +253 -0
- data/lib/metanorma/document/mko/collection.rb +168 -0
- data/lib/metanorma/document/mko/exporter.rb +17 -0
- data/lib/metanorma/document/mko/project.rb +1110 -0
- data/lib/metanorma/document/mko.rb +122 -0
- data/lib/metanorma/document/model_access.rb +44 -0
- data/lib/metanorma/document/native_models.rb +319 -0
- data/lib/metanorma/document/plain_text.rb +39 -0
- data/lib/metanorma/document/relaton/version_info.rb +4 -0
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +19 -26
- data/lib/metanorma/{collection → document_collection}/directive.rb +1 -1
- data/lib/metanorma/{collection → document_collection}/doc_container.rb +6 -2
- data/lib/metanorma/{collection → document_collection}/entry.rb +2 -2
- data/lib/metanorma/{collection → document_collection}/root.rb +2 -2
- data/lib/metanorma/document_collection.rb +10 -0
- data/lib/metanorma/html/base_renderer.rb +94 -25
- data/lib/metanorma/html/component/footnote_collector.rb +21 -20
- data/lib/metanorma/html/concerns/metadata_extraction.rb +8 -3
- data/lib/metanorma/html/concerns/presentation_validation.rb +1 -2
- data/lib/metanorma/html/concerns/text_extraction.rb +154 -35
- data/lib/metanorma/html/concerns.rb +19 -0
- data/lib/metanorma/html/drops/admonition_drop.rb +1 -1
- data/lib/metanorma/html/drops/footnote_drop.rb +1 -1
- data/lib/metanorma/html/drops/sourcecode_drop.rb +22 -4
- data/lib/metanorma/html/generator.rb +11 -187
- data/lib/metanorma/html/renderer_delegation.rb +2 -2
- data/lib/metanorma/html/renderers/block_renderer.rb +206 -46
- data/lib/metanorma/html/renderers/inline_renderer.rb +144 -17
- data/lib/metanorma/html/renderers/section_renderer.rb +12 -2
- data/lib/metanorma/html/renderers/semantic_renderer.rb +487 -0
- data/lib/metanorma/html/renderers.rb +2 -0
- data/lib/metanorma/html/standard_renderer.rb +732 -76
- data/lib/metanorma/html/templates/_agency_cover.html.liquid +30 -0
- data/lib/metanorma/html/templates/_columnbreak.html.liquid +1 -0
- data/lib/metanorma/html/templates/_cover.html.liquid +3 -0
- data/lib/metanorma/html/templates/_main_content.html.liquid +1 -1
- data/lib/metanorma/html/templates/_ruby.html.liquid +1 -0
- data/lib/metanorma/html/templates/_sourcecode.html.liquid +4 -3
- data/lib/metanorma/html/templates/_standard_cover.html.liquid +54 -3
- data/lib/metanorma/html.rb +30 -15
- data/tasks/flavors.rake +116 -0
- data/tasks/grammar.rake +28 -0
- data/tasks/roundtrip_samples.rake +48 -34
- metadata +121 -416
- data/frontend/dist/app.css +0 -1
- data/frontend/dist/app.iife.js +0 -24
- data/lib/metanorma/bipm_document/metadata/bipm_bib_data_extension_type.rb +0 -20
- data/lib/metanorma/bipm_document/metadata/bipm_bibliographic_item.rb +0 -17
- data/lib/metanorma/bipm_document/metadata/bipm_structured_identifier.rb +0 -21
- data/lib/metanorma/bipm_document/metadata/depiction_element.rb +0 -18
- data/lib/metanorma/bipm_document/metadata.rb +0 -15
- data/lib/metanorma/bipm_document/root.rb +0 -25
- data/lib/metanorma/bipm_document.rb +0 -8
- data/lib/metanorma/bsi_document/metadata/bsi_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/bsi_document/metadata/bsi_bibliographic_item.rb +0 -15
- data/lib/metanorma/bsi_document/metadata.rb +0 -12
- data/lib/metanorma/bsi_document/root.rb +0 -29
- data/lib/metanorma/bsi_document/sections/bsi_annex_section.rb +0 -25
- data/lib/metanorma/bsi_document/sections/bsi_clause_section.rb +0 -25
- data/lib/metanorma/bsi_document/sections/bsi_sections.rb +0 -27
- data/lib/metanorma/bsi_document/sections.rb +0 -11
- data/lib/metanorma/bsi_document.rb +0 -11
- data/lib/metanorma/cc_document/metadata/cc_bib_data_extension_type.rb +0 -12
- data/lib/metanorma/cc_document/metadata/cc_bibliographic_item.rb +0 -17
- data/lib/metanorma/cc_document/metadata.rb +0 -11
- data/lib/metanorma/cc_document/root.rb +0 -25
- data/lib/metanorma/cc_document.rb +0 -8
- data/lib/metanorma/collection.rb +0 -10
- data/lib/metanorma/csa_document/root.rb +0 -27
- data/lib/metanorma/csa_document.rb +0 -9
- data/lib/metanorma/gb_document/metadata/gb_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/gb_document/metadata/gb_bibliographic_item.rb +0 -15
- data/lib/metanorma/gb_document/metadata.rb +0 -12
- data/lib/metanorma/gb_document/root.rb +0 -29
- data/lib/metanorma/gb_document.rb +0 -10
- data/lib/metanorma/generic_document/root.rb +0 -31
- data/lib/metanorma/generic_document.rb +0 -7
- data/lib/metanorma/html/bipm_renderer.rb +0 -23
- data/lib/metanorma/html/cc_renderer.rb +0 -9
- data/lib/metanorma/html/csa_renderer.rb +0 -9
- data/lib/metanorma/html/flavor.rb +0 -50
- data/lib/metanorma/html/flavor_registry.rb +0 -49
- data/lib/metanorma/html/icc_renderer.rb +0 -10
- data/lib/metanorma/html/iec_renderer.rb +0 -9
- data/lib/metanorma/html/ieee_renderer.rb +0 -9
- data/lib/metanorma/html/ietf_renderer.rb +0 -9
- data/lib/metanorma/html/iho_renderer.rb +0 -9
- data/lib/metanorma/html/iso_renderer.rb +0 -535
- data/lib/metanorma/html/itu_renderer.rb +0 -9
- data/lib/metanorma/html/ogc_renderer.rb +0 -23
- data/lib/metanorma/html/pdfa_renderer.rb +0 -10
- data/lib/metanorma/html/ribose_renderer.rb +0 -9
- data/lib/metanorma/html/templates/_bipm_cover.html.liquid +0 -27
- data/lib/metanorma/html/templates/_iso_cover.html.liquid +0 -31
- data/lib/metanorma/html/templates/_iso_doc_title.html.liquid +0 -3
- data/lib/metanorma/iec_document/root.rb +0 -27
- data/lib/metanorma/iec_document.rb +0 -9
- data/lib/metanorma/ieee_document/metadata/ieee_bib_data_extension_type.rb +0 -18
- data/lib/metanorma/ieee_document/metadata/ieee_bibliographic_item.rb +0 -20
- data/lib/metanorma/ieee_document/metadata/ieee_structured_identifier.rb +0 -25
- data/lib/metanorma/ieee_document/metadata.rb +0 -14
- data/lib/metanorma/ieee_document/root.rb +0 -29
- data/lib/metanorma/ieee_document/sections/ieee_sections.rb +0 -31
- data/lib/metanorma/ieee_document/sections.rb +0 -9
- data/lib/metanorma/ieee_document.rb +0 -11
- data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -31
- data/lib/metanorma/ietf_document/metadata/ietf_bibliographic_item.rb +0 -51
- data/lib/metanorma/ietf_document/metadata/ietf_editorial_group.rb +0 -17
- data/lib/metanorma/ietf_document/metadata/pi_settings.rb +0 -32
- data/lib/metanorma/ietf_document/metadata.rb +0 -16
- data/lib/metanorma/ietf_document/root.rb +0 -30
- data/lib/metanorma/ietf_document/sections/ietf_annex_section.rb +0 -26
- data/lib/metanorma/ietf_document/sections/ietf_clause_section.rb +0 -26
- data/lib/metanorma/ietf_document/sections/ietf_content_section.rb +0 -25
- data/lib/metanorma/ietf_document/sections/ietf_sections.rb +0 -35
- data/lib/metanorma/ietf_document/sections.rb +0 -12
- data/lib/metanorma/ietf_document.rb +0 -11
- data/lib/metanorma/iho_document/metadata/iho_bib_data_extension_type.rb +0 -23
- data/lib/metanorma/iho_document/metadata/iho_bibliographic_item.rb +0 -20
- data/lib/metanorma/iho_document/metadata/iho_editorial_group.rb +0 -19
- data/lib/metanorma/iho_document/metadata/iho_series.rb +0 -22
- data/lib/metanorma/iho_document/metadata/iho_sub_group.rb +0 -18
- data/lib/metanorma/iho_document/metadata.rb +0 -15
- data/lib/metanorma/iho_document/root.rb +0 -25
- data/lib/metanorma/iho_document.rb +0 -8
- data/lib/metanorma/iso_document/annotation_container.rb +0 -7
- data/lib/metanorma/iso_document/blocks/iso_admonition_block.rb +0 -27
- data/lib/metanorma/iso_document/blocks/iso_admonition_type.rb +0 -25
- data/lib/metanorma/iso_document/blocks.rb +0 -12
- data/lib/metanorma/iso_document/boilerplate.rb +0 -7
- data/lib/metanorma/iso_document/metadata/abstract_title.rb +0 -36
- data/lib/metanorma/iso_document/metadata/doc_identifier.rb +0 -26
- data/lib/metanorma/iso_document/metadata/doctype_element.rb +0 -20
- data/lib/metanorma/iso_document/metadata/ics.rb +0 -19
- data/lib/metanorma/iso_document/metadata/iec_document_category.rb +0 -23
- data/lib/metanorma/iso_document/metadata/iso_bib_data_extension_type.rb +0 -38
- data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +0 -103
- data/lib/metanorma/iso_document/metadata/iso_document_id.rb +0 -46
- data/lib/metanorma/iso_document/metadata/iso_document_stage_codes.rb +0 -26
- data/lib/metanorma/iso_document/metadata/iso_document_status.rb +0 -26
- data/lib/metanorma/iso_document/metadata/iso_document_substage_codes.rb +0 -26
- data/lib/metanorma/iso_document/metadata/iso_document_type.rb +0 -25
- data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +0 -61
- data/lib/metanorma/iso_document/metadata/iso_project_group.rb +0 -32
- data/lib/metanorma/iso_document/metadata/iso_sub_group.rb +0 -38
- data/lib/metanorma/iso_document/metadata/language_element.rb +0 -18
- data/lib/metanorma/iso_document/metadata/metanorma_extension.rb +0 -9
- data/lib/metanorma/iso_document/metadata/project_number.rb +0 -22
- data/lib/metanorma/iso_document/metadata/script_element.rb +0 -18
- data/lib/metanorma/iso_document/metadata/stage_element.rb +0 -26
- data/lib/metanorma/iso_document/metadata/stagename_element.rb +0 -18
- data/lib/metanorma/iso_document/metadata/structured_identifier.rb +0 -16
- data/lib/metanorma/iso_document/metadata/title_amd.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_amendment_prefix.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_collection.rb +0 -47
- data/lib/metanorma/iso_document/metadata/title_full.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_intro.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_main.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_part.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_part_prefix.rb +0 -12
- data/lib/metanorma/iso_document/metadata.rb +0 -44
- data/lib/metanorma/iso_document/root.rb +0 -26
- data/lib/metanorma/iso_document/sections/colophon.rb +0 -3
- data/lib/metanorma/iso_document/sections/iso_abstract_section.rb +0 -15
- data/lib/metanorma/iso_document/sections/iso_amendment_clause.rb +0 -24
- data/lib/metanorma/iso_document/sections/iso_annex_section.rb +0 -50
- data/lib/metanorma/iso_document/sections/iso_clause_section.rb +0 -49
- data/lib/metanorma/iso_document/sections/iso_foreword_section.rb +0 -33
- data/lib/metanorma/iso_document/sections/iso_preface.rb +0 -51
- data/lib/metanorma/iso_document/sections/iso_sections.rb +0 -51
- data/lib/metanorma/iso_document/sections/iso_terms_section.rb +0 -76
- data/lib/metanorma/iso_document/sections.rb +0 -17
- data/lib/metanorma/iso_document/terms/iso_term.rb +0 -71
- data/lib/metanorma/iso_document/terms/iso_term_collection.rb +0 -20
- data/lib/metanorma/iso_document/terms/term_definition.rb +0 -30
- data/lib/metanorma/iso_document/terms/term_designation.rb +0 -44
- data/lib/metanorma/iso_document/terms/term_domain_element.rb +0 -18
- data/lib/metanorma/iso_document/terms/term_example.rb +0 -40
- data/lib/metanorma/iso_document/terms/term_expression.rb +0 -10
- data/lib/metanorma/iso_document/terms/term_note.rb +0 -42
- data/lib/metanorma/iso_document/terms/term_origin.rb +0 -4
- data/lib/metanorma/iso_document/terms/term_source.rb +0 -21
- data/lib/metanorma/iso_document/terms/verbal_definition.rb +0 -42
- data/lib/metanorma/iso_document/terms.rb +0 -21
- data/lib/metanorma/iso_document.rb +0 -15
- data/lib/metanorma/itu_document/metadata/itu_bib_data_extension_type.rb +0 -26
- data/lib/metanorma/itu_document/metadata/itu_bibliographic_item.rb +0 -21
- data/lib/metanorma/itu_document/metadata/itu_series.rb +0 -22
- data/lib/metanorma/itu_document/metadata/itu_structured_identifier.rb +0 -23
- data/lib/metanorma/itu_document/metadata/meeting_date.rb +0 -18
- data/lib/metanorma/itu_document/metadata/meeting_element.rb +0 -18
- data/lib/metanorma/itu_document/metadata/study_period.rb +0 -18
- data/lib/metanorma/itu_document/metadata.rb +0 -18
- data/lib/metanorma/itu_document/root.rb +0 -25
- data/lib/metanorma/itu_document.rb +0 -8
- data/lib/metanorma/jis_document/metadata/jis_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/jis_document/metadata/jis_bibliographic_item.rb +0 -15
- data/lib/metanorma/jis_document/metadata.rb +0 -12
- data/lib/metanorma/jis_document/root.rb +0 -29
- data/lib/metanorma/jis_document/sections/jis_annex_section.rb +0 -20
- data/lib/metanorma/jis_document/sections.rb +0 -9
- data/lib/metanorma/jis_document.rb +0 -11
- data/lib/metanorma/m3d_document/metadata/m3d_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/m3d_document/metadata/m3d_bibliographic_item.rb +0 -15
- data/lib/metanorma/m3d_document/metadata.rb +0 -12
- data/lib/metanorma/m3d_document/root.rb +0 -29
- data/lib/metanorma/m3d_document.rb +0 -10
- data/lib/metanorma/mirror/default_registry.rb +0 -191
- data/lib/metanorma/mirror/handler_registry.rb +0 -60
- data/lib/metanorma/mirror/handler_result.rb +0 -37
- data/lib/metanorma/mirror/handlers/admonition.rb +0 -18
- data/lib/metanorma/mirror/handlers/example.rb +0 -21
- data/lib/metanorma/mirror/handlers/figure.rb +0 -53
- data/lib/metanorma/mirror/handlers/formula.rb +0 -35
- data/lib/metanorma/mirror/handlers/inline/catalog.rb +0 -52
- data/lib/metanorma/mirror/handlers/inline/rich_html_renderer.rb +0 -158
- data/lib/metanorma/mirror/handlers/inline/text_extractor.rb +0 -116
- data/lib/metanorma/mirror/handlers/inline.rb +0 -226
- data/lib/metanorma/mirror/handlers/list.rb +0 -110
- data/lib/metanorma/mirror/handlers/note.rb +0 -26
- data/lib/metanorma/mirror/handlers/paragraph.rb +0 -19
- data/lib/metanorma/mirror/handlers/quote.rb +0 -16
- data/lib/metanorma/mirror/handlers/review.rb +0 -19
- data/lib/metanorma/mirror/handlers/section.rb +0 -149
- data/lib/metanorma/mirror/handlers/sourcecode.rb +0 -27
- data/lib/metanorma/mirror/handlers/structural.rb +0 -68
- data/lib/metanorma/mirror/handlers/table.rb +0 -81
- data/lib/metanorma/mirror/handlers/term.rb +0 -100
- data/lib/metanorma/mirror/handlers.rb +0 -60
- data/lib/metanorma/mirror/id_strategy/positional.rb +0 -166
- data/lib/metanorma/mirror/id_strategy/preserve.rb +0 -12
- data/lib/metanorma/mirror/id_strategy.rb +0 -34
- data/lib/metanorma/mirror/math_util.rb +0 -53
- data/lib/metanorma/mirror/metadata.rb +0 -37
- data/lib/metanorma/mirror/model/container.rb +0 -47
- data/lib/metanorma/mirror/model/factory.rb +0 -52
- data/lib/metanorma/mirror/model/guide.rb +0 -26
- data/lib/metanorma/mirror/model/leaf.rb +0 -17
- data/lib/metanorma/mirror/model/mark.rb +0 -53
- data/lib/metanorma/mirror/model/node.rb +0 -47
- data/lib/metanorma/mirror/model/soft_break.rb +0 -33
- data/lib/metanorma/mirror/model/text.rb +0 -34
- data/lib/metanorma/mirror/model.rb +0 -16
- data/lib/metanorma/mirror/output/builder.rb +0 -39
- data/lib/metanorma/mirror/output/formats/base_format.rb +0 -90
- data/lib/metanorma/mirror/output/formats/inline_format.rb +0 -142
- data/lib/metanorma/mirror/output/formats.rb +0 -53
- data/lib/metanorma/mirror/output/pipeline.rb +0 -93
- data/lib/metanorma/mirror/output/pipeline_context.rb +0 -22
- data/lib/metanorma/mirror/output.rb +0 -12
- data/lib/metanorma/mirror/rewriter.rb +0 -123
- data/lib/metanorma/mirror/safe_attr.rb +0 -16
- data/lib/metanorma/mirror/serialization/json_serializer.rb +0 -25
- data/lib/metanorma/mirror/serialization/yaml_serializer.rb +0 -20
- data/lib/metanorma/mirror/serialization.rb +0 -10
- data/lib/metanorma/mirror/transformer.rb +0 -110
- data/lib/metanorma/mirror.rb +0 -31
- data/lib/metanorma/nist_document/metadata/nist_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/nist_document/metadata/nist_bibliographic_item.rb +0 -15
- data/lib/metanorma/nist_document/metadata.rb +0 -12
- data/lib/metanorma/nist_document/root.rb +0 -29
- data/lib/metanorma/nist_document/sections/errata.rb +0 -16
- data/lib/metanorma/nist_document/sections/errata_clause.rb +0 -20
- data/lib/metanorma/nist_document/sections/errata_row.rb +0 -22
- data/lib/metanorma/nist_document/sections/nist_preface.rb +0 -30
- data/lib/metanorma/nist_document/sections.rb +0 -12
- data/lib/metanorma/nist_document.rb +0 -11
- data/lib/metanorma/ogc_document/metadata/ogc_bib_data_extension_type.rb +0 -12
- data/lib/metanorma/ogc_document/metadata/ogc_bibliographic_item.rb +0 -19
- data/lib/metanorma/ogc_document/metadata.rb +0 -12
- data/lib/metanorma/ogc_document/root.rb +0 -25
- data/lib/metanorma/ogc_document.rb +0 -8
- data/lib/metanorma/plateau_document/metadata/plateau_bibliographic_item.rb +0 -13
- data/lib/metanorma/plateau_document/metadata.rb +0 -10
- data/lib/metanorma/plateau_document/root.rb +0 -29
- data/lib/metanorma/plateau_document.rb +0 -10
- data/lib/metanorma/registers/setup.rb +0 -166
- data/lib/metanorma/registers.rb +0 -7
- data/lib/metanorma/ribose_document/metadata/ribose_bib_data_extension_type.rb +0 -20
- data/lib/metanorma/ribose_document/metadata/ribose_bibliographic_item.rb +0 -18
- data/lib/metanorma/ribose_document/metadata.rb +0 -12
- data/lib/metanorma/ribose_document/root.rb +0 -26
- data/lib/metanorma/ribose_document.rb +0 -8
- data/lib/metanorma/standard_document/annotation_container.rb +0 -39
- data/lib/metanorma/standard_document/block_attributes.rb +0 -281
- data/lib/metanorma/standard_document/blocks/amend_block.rb +0 -50
- data/lib/metanorma/standard_document/blocks/amend_content_block.rb +0 -35
- data/lib/metanorma/standard_document/blocks/auto_number.rb +0 -20
- data/lib/metanorma/standard_document/blocks/block_source.rb +0 -22
- data/lib/metanorma/standard_document/blocks/change_type.rb +0 -21
- data/lib/metanorma/standard_document/blocks/element_name.rb +0 -22
- data/lib/metanorma/standard_document/blocks/form.rb +0 -38
- data/lib/metanorma/standard_document/blocks/image_map_area_type.rb +0 -24
- data/lib/metanorma/standard_document/blocks/image_map_area_type_type.rb +0 -21
- data/lib/metanorma/standard_document/blocks/image_map_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/image_map_coords.rb +0 -19
- data/lib/metanorma/standard_document/blocks/image_map_radius.rb +0 -19
- data/lib/metanorma/standard_document/blocks/multilingual_rendering_type.rb +0 -21
- data/lib/metanorma/standard_document/blocks/passthrough.rb +0 -3
- data/lib/metanorma/standard_document/blocks/requirement_model.rb +0 -20
- data/lib/metanorma/standard_document/blocks/source_origin_element.rb +0 -23
- data/lib/metanorma/standard_document/blocks/standard_admonition_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/standard_block.rb +0 -28
- data/lib/metanorma/standard_document/blocks/standard_block_no_notes.rb +0 -34
- data/lib/metanorma/standard_document/blocks/standard_example_block.rb +0 -30
- data/lib/metanorma/standard_document/blocks/standard_figure_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/standard_formula_block.rb +0 -30
- data/lib/metanorma/standard_document/blocks/standard_note_block.rb +0 -64
- data/lib/metanorma/standard_document/blocks/standard_paragraph_block.rb +0 -25
- data/lib/metanorma/standard_document/blocks/standard_quote_block.rb +0 -29
- data/lib/metanorma/standard_document/blocks/standard_sourcecode_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/standard_table_block.rb +0 -39
- data/lib/metanorma/standard_document/blocks/svg_map_block.rb +0 -23
- data/lib/metanorma/standard_document/blocks/svg_target_type.rb +0 -20
- data/lib/metanorma/standard_document/blocks/table_col.rb +0 -16
- data/lib/metanorma/standard_document/blocks/to_c.rb +0 -17
- data/lib/metanorma/standard_document/blocks.rb +0 -60
- data/lib/metanorma/standard_document/boilerplate.rb +0 -32
- data/lib/metanorma/standard_document/elements/add.rb +0 -3
- data/lib/metanorma/standard_document/elements/del.rb +0 -3
- data/lib/metanorma/standard_document/elements/form_input.rb +0 -27
- data/lib/metanorma/standard_document/elements/input.rb +0 -12
- data/lib/metanorma/standard_document/elements/input_type.rb +0 -27
- data/lib/metanorma/standard_document/elements/label.rb +0 -19
- data/lib/metanorma/standard_document/elements/option.rb +0 -27
- data/lib/metanorma/standard_document/elements/orientation_type.rb +0 -27
- data/lib/metanorma/standard_document/elements/select.rb +0 -32
- data/lib/metanorma/standard_document/elements/standard_page_break_element.rb +0 -22
- data/lib/metanorma/standard_document/elements/textarea.rb +0 -25
- data/lib/metanorma/standard_document/elements.rb +0 -20
- data/lib/metanorma/standard_document/lists/standard_definition.rb +0 -24
- data/lib/metanorma/standard_document/lists/standard_definition_list.rb +0 -30
- data/lib/metanorma/standard_document/lists/standard_definition_term.rb +0 -27
- data/lib/metanorma/standard_document/lists/standard_unordered_list.rb +0 -28
- data/lib/metanorma/standard_document/lists/unordered_checkable_list_item.rb +0 -26
- data/lib/metanorma/standard_document/lists.rb +0 -17
- data/lib/metanorma/standard_document/metadata/editorial_group_type.rb +0 -25
- data/lib/metanorma/standard_document/metadata/ics_type.rb +0 -26
- data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +0 -26
- data/lib/metanorma/standard_document/metadata/presentation_metadata.rb +0 -107
- data/lib/metanorma/standard_document/metadata/semantic_metadata.rb +0 -18
- data/lib/metanorma/standard_document/metadata/standard_bib_data.rb +0 -25
- data/lib/metanorma/standard_document/metadata/standard_bib_data_extension_type.rb +0 -37
- data/lib/metanorma/standard_document/metadata/structured_identifier_type.rb +0 -48
- data/lib/metanorma/standard_document/metadata/technical_committee_type.rb +0 -27
- data/lib/metanorma/standard_document/metadata/unitsml/amount_of_substance.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/base_quantity.rb +0 -34
- data/lib/metanorma/standard_document/metadata/unitsml/dimension.rb +0 -39
- data/lib/metanorma/standard_document/metadata/unitsml/dimension_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/electric_current.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/enumerated_root_unit.rb +0 -23
- data/lib/metanorma/standard_document/metadata/unitsml/length.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/luminous_intensity.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/mass.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/namespace.rb +0 -17
- data/lib/metanorma/standard_document/metadata/unitsml/plane_angle.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/prefix.rb +0 -30
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_name.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_symbol.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/quantity.rb +0 -28
- data/lib/metanorma/standard_document/metadata/unitsml/quantity_name.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/quantity_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/root_units.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/thermodynamic_temperature.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/time.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/unit.rb +0 -32
- data/lib/metanorma/standard_document/metadata/unitsml/unit_name.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/unit_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/unit_symbol.rb +0 -36
- data/lib/metanorma/standard_document/metadata/unitsml/unit_system.rb +0 -23
- data/lib/metanorma/standard_document/metadata/unitsml/unitsml_root.rb +0 -28
- data/lib/metanorma/standard_document/metadata/unitsml.rb +0 -39
- data/lib/metanorma/standard_document/metadata.rb +0 -23
- data/lib/metanorma/standard_document/namespace.rb +0 -11
- data/lib/metanorma/standard_document/refs/reference_to_term.rb +0 -26
- data/lib/metanorma/standard_document/refs/reference_to_termbase.rb +0 -27
- data/lib/metanorma/standard_document/refs/standoc_locality_stack.rb +0 -24
- data/lib/metanorma/standard_document/refs/standoc_reference_to_citation_element.rb +0 -27
- data/lib/metanorma/standard_document/refs/standoc_reference_to_id_element.rb +0 -36
- data/lib/metanorma/standard_document/refs/xref_case_type.rb +0 -27
- data/lib/metanorma/standard_document/refs/xref_connective_type.rb +0 -27
- data/lib/metanorma/standard_document/refs/xref_target_type.rb +0 -25
- data/lib/metanorma/standard_document/refs.rb +0 -18
- data/lib/metanorma/standard_document/root.rb +0 -10
- data/lib/metanorma/standard_document/root_attributes.rb +0 -78
- data/lib/metanorma/standard_document/sections/abstract.rb +0 -19
- data/lib/metanorma/standard_document/sections/acknowledgements.rb +0 -19
- data/lib/metanorma/standard_document/sections/annex_section.rb +0 -69
- data/lib/metanorma/standard_document/sections/bibliography_section.rb +0 -20
- data/lib/metanorma/standard_document/sections/boilerplate_type.rb +0 -32
- data/lib/metanorma/standard_document/sections/clause_hierarchical_section.rb +0 -32
- data/lib/metanorma/standard_document/sections/clause_section.rb +0 -91
- data/lib/metanorma/standard_document/sections/colophon.rb +0 -16
- data/lib/metanorma/standard_document/sections/definition_section.rb +0 -72
- data/lib/metanorma/standard_document/sections/floating_section_title.rb +0 -23
- data/lib/metanorma/standard_document/sections/floating_title.rb +0 -27
- data/lib/metanorma/standard_document/sections/foreword.rb +0 -19
- data/lib/metanorma/standard_document/sections/introduction.rb +0 -20
- data/lib/metanorma/standard_document/sections/misc_container.rb +0 -31
- data/lib/metanorma/standard_document/sections/normative_type.rb +0 -29
- data/lib/metanorma/standard_document/sections/preface.rb +0 -36
- data/lib/metanorma/standard_document/sections/sections.rb +0 -47
- data/lib/metanorma/standard_document/sections/standard_content_section.rb +0 -41
- data/lib/metanorma/standard_document/sections/standard_hierarchical_section.rb +0 -30
- data/lib/metanorma/standard_document/sections/standard_references_section.rb +0 -74
- data/lib/metanorma/standard_document/sections/standard_section.rb +0 -39
- data/lib/metanorma/standard_document/sections/terms_section.rb +0 -61
- data/lib/metanorma/standard_document/sections.rb +0 -34
- data/lib/metanorma/standard_document/standard_document_type.rb +0 -15
- data/lib/metanorma/standard_document/terms/abbreviation_type.rb +0 -27
- data/lib/metanorma/standard_document/terms/concept.rb +0 -42
- data/lib/metanorma/standard_document/terms/definition_collection.rb +0 -24
- data/lib/metanorma/standard_document/terms/designation.rb +0 -31
- data/lib/metanorma/standard_document/terms/expression_designation.rb +0 -38
- data/lib/metanorma/standard_document/terms/expression_type.rb +0 -27
- data/lib/metanorma/standard_document/terms/grammar_gender.rb +0 -27
- data/lib/metanorma/standard_document/terms/grammar_info.rb +0 -36
- data/lib/metanorma/standard_document/terms/graphical_symbol_designation.rb +0 -25
- data/lib/metanorma/standard_document/terms/letter_symbol_designation.rb +0 -27
- data/lib/metanorma/standard_document/terms/non_verbal_representation.rb +0 -33
- data/lib/metanorma/standard_document/terms/related_term.rb +0 -31
- data/lib/metanorma/standard_document/terms/related_term_type.rb +0 -28
- data/lib/metanorma/standard_document/terms/term.rb +0 -66
- data/lib/metanorma/standard_document/terms/term_collection.rb +0 -24
- data/lib/metanorma/standard_document/terms/term_definition.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_expression.rb +0 -20
- data/lib/metanorma/standard_document/terms/term_name_element.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_source.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_source_status.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_source_type.rb +0 -21
- data/lib/metanorma/standard_document/terms/verbal_expression.rb +0 -35
- data/lib/metanorma/standard_document/terms.rb +0 -33
- data/lib/metanorma/standard_document.rb +0 -27
- data/lib/metanorma/un_document/blocks/un_admonition_block.rb +0 -86
- data/lib/metanorma/un_document/blocks.rb +0 -9
- data/lib/metanorma/un_document/metadata/un_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/un_document/metadata/un_bibliographic_item.rb +0 -15
- data/lib/metanorma/un_document/metadata.rb +0 -12
- data/lib/metanorma/un_document/root.rb +0 -37
- data/lib/metanorma/un_document/sections/un_abstract_section.rb +0 -48
- data/lib/metanorma/un_document/sections/un_preface.rb +0 -40
- data/lib/metanorma/un_document/sections/un_sections.rb +0 -24
- data/lib/metanorma/un_document/sections.rb +0 -11
- data/lib/metanorma/un_document/un_text_element.rb +0 -116
- data/lib/metanorma/un_document.rb +0 -13
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "metanorma/mko"
|
|
4
|
+
require "metanorma-core"
|
|
5
|
+
require "nokogiri"
|
|
6
|
+
|
|
7
|
+
module Metanorma
|
|
8
|
+
# The MODEL side of MKO (MN 116), reopening the format gem's module:
|
|
9
|
+
# the projection walk (Project), collection orchestration
|
|
10
|
+
# (Collection), the compile-pipeline exporter, flavor resolution and
|
|
11
|
+
# registry seeding, and the export entry points. The wire contract —
|
|
12
|
+
# schema, bundle layout, assets, diffs, alignment, JSON Schemas, the
|
|
13
|
+
# MCP server — lives in the metanorma-mko gem.
|
|
14
|
+
module Mko
|
|
15
|
+
autoload :Project, "metanorma/document/mko/project"
|
|
16
|
+
autoload :Collection, "metanorma/document/mko/collection"
|
|
17
|
+
autoload :Exporter, "metanorma/document/mko/exporter"
|
|
18
|
+
|
|
19
|
+
class << self
|
|
20
|
+
# Export a document model (or semantic/presentation XML string)
|
|
21
|
+
# as an MKO bundle directory (or .mko.zip with zip: true).
|
|
22
|
+
# Returns an Export (path + projection Result); the Export
|
|
23
|
+
# ducktypes as the bundle path String for existing callers.
|
|
24
|
+
def export(source, to:, presentation_xml: nil, zip: false,
|
|
25
|
+
assets_from: nil)
|
|
26
|
+
seed_flavors!
|
|
27
|
+
model = source.is_a?(String) ? model_from_xml(source) : source
|
|
28
|
+
presentation = case presentation_xml
|
|
29
|
+
when String then model_from_xml(presentation_xml)
|
|
30
|
+
when nil then nil
|
|
31
|
+
else presentation_xml
|
|
32
|
+
end
|
|
33
|
+
projection = Project.call(model, presentation: presentation,
|
|
34
|
+
assets: Assets.new(source_dir: assets_from))
|
|
35
|
+
Export.new(Writer.write(projection, to: to, zip: zip), projection)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# The format adapter over the central flavor registry (mirrors
|
|
39
|
+
# Html::Generator): a flavor entry may register its own :mko
|
|
40
|
+
# renderer; with none, the harness Exporter serves any model tree
|
|
41
|
+
# — the walk is class/attribute-driven, zero flavor knowledge.
|
|
42
|
+
def generate(document, **)
|
|
43
|
+
seed_flavors!
|
|
44
|
+
renderer_for(document, **)
|
|
45
|
+
.new.generate_full_document(document, **)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def renderer_for(document, **)
|
|
49
|
+
seed_flavors!
|
|
50
|
+
Metanorma::Core::Flavors.renderer_for(document, format: :mko,
|
|
51
|
+
**) || Exporter
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def model_from_xml(xml)
|
|
57
|
+
root = Nokogiri::XML(xml).root
|
|
58
|
+
flavor = root["flavor"]
|
|
59
|
+
klass = nil
|
|
60
|
+
Metanorma::Core::Flavors.table.reverse_each do |entry|
|
|
61
|
+
next if entry.taste?
|
|
62
|
+
|
|
63
|
+
candidate = entry.model_root_class or next
|
|
64
|
+
name = entry.name.to_s
|
|
65
|
+
next if flavor && !flavor.empty? && name != flavor
|
|
66
|
+
|
|
67
|
+
klass = candidate
|
|
68
|
+
break
|
|
69
|
+
end
|
|
70
|
+
unless klass
|
|
71
|
+
raise ArgumentError,
|
|
72
|
+
"no document model registered for flavor #{flavor.inspect}; " \
|
|
73
|
+
"require the flavor gem (metanorma-standoc or a flavor) " \
|
|
74
|
+
"before exporting"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
klass.from_xml(xml)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Same seeding pattern as Html in html.rb: contribute the mko
|
|
82
|
+
# renderer for the two harness model trees. Flavor models do not
|
|
83
|
+
# subclass the harness roots (they include RootAttributes), so
|
|
84
|
+
# renderer resolution for :mko goes through .renderer_for below with
|
|
85
|
+
# a harness fallback — the Html::Generator pattern. Core::Flavors
|
|
86
|
+
# has no add_renderer API yet — attach to the entry html.rb
|
|
87
|
+
# registered when present, register a standalone entry otherwise
|
|
88
|
+
# (mko loaded without html); delete the attach branch when core
|
|
89
|
+
# gains the mutator.
|
|
90
|
+
SEED_MODEL_ROOTS = {
|
|
91
|
+
document: Metanorma::Document::Root,
|
|
92
|
+
standoc: "Metanorma::Standoc::Document::Root",
|
|
93
|
+
}.freeze
|
|
94
|
+
|
|
95
|
+
# Lazy: seeding touches the core flavor registry, which only the
|
|
96
|
+
# flavor-table line of metanorma-core defines. Requiring this gem
|
|
97
|
+
# must never depend on it — seeds on first use, no-op without it.
|
|
98
|
+
class << self
|
|
99
|
+
def seed_flavors!
|
|
100
|
+
return unless defined?(Metanorma::Core::Flavors)
|
|
101
|
+
return if @flavors_seeded
|
|
102
|
+
|
|
103
|
+
@flavors_seeded = true
|
|
104
|
+
SEED_MODEL_ROOTS.each do |seed, model_root|
|
|
105
|
+
entry = Metanorma::Core::Flavors.find(seed)
|
|
106
|
+
if entry
|
|
107
|
+
entry.renderers[:mko] ||= Exporter
|
|
108
|
+
else
|
|
109
|
+
Metanorma::Core::Flavors.register(Metanorma::Core::Flavor.new(
|
|
110
|
+
name: seed,
|
|
111
|
+
model_root: model_root,
|
|
112
|
+
renderers: { mko: Exporter },
|
|
113
|
+
))
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# document.rb keeps the lazy entry that pulls the model side in
|
|
121
|
+
Document.autoload :MkoIntegration, "metanorma/document/mko" if false
|
|
122
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Document
|
|
5
|
+
# Attribute-keyed access to typed model objects — the one shared
|
|
6
|
+
# vocabulary for walking both model trees. Flavor classes may omit
|
|
7
|
+
# attributes the base trees carry (or rename them), so every read
|
|
8
|
+
# is keyed on the class's lutaml declarations, never on
|
|
9
|
+
# respond_to?. Included by the model-layer decomposition
|
|
10
|
+
# (NativeModels) and the MKO projection alike.
|
|
11
|
+
module ModelAccess
|
|
12
|
+
# The attribute's value, or nil when the object does not declare
|
|
13
|
+
# the attribute (or is not a typed model object at all).
|
|
14
|
+
def val(obj, name)
|
|
15
|
+
return nil unless serializable?(obj)
|
|
16
|
+
|
|
17
|
+
obj.class.attributes.key?(name) ? obj.public_send(name) : nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Collection form: always an Array.
|
|
21
|
+
def vals(obj, name)
|
|
22
|
+
Array(val(obj, name))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def serializable?(obj)
|
|
26
|
+
obj.is_a?(Lutaml::Model::Serializable)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# A bibdata's document identifiers; flavor trees rename the
|
|
30
|
+
# attribute (:docidentifier vs :doc_identifier).
|
|
31
|
+
def docids(bib)
|
|
32
|
+
out = vals(bib, :docidentifier)
|
|
33
|
+
out = vals(bib, :doc_identifier) if out.empty?
|
|
34
|
+
out.compact
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The identifier's text: the base tree maps content to :id; iso
|
|
38
|
+
# declares :value.
|
|
39
|
+
def docid_text(docid)
|
|
40
|
+
val(docid, :id) || val(docid, :value)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "glossarist"
|
|
4
|
+
require "relaton/bib"
|
|
5
|
+
require "pubid"
|
|
6
|
+
|
|
7
|
+
module Metanorma
|
|
8
|
+
module Document
|
|
9
|
+
# Decomposition of a typed document model into the native object
|
|
10
|
+
# models of the Metanorma ecosystem: Glossarist concepts from term
|
|
11
|
+
# entries, Relaton bibdata from the bibliographic record, Pubid
|
|
12
|
+
# identifiers from document identifiers.
|
|
13
|
+
#
|
|
14
|
+
# This is a MODEL-layer capability, available to any consumer; the
|
|
15
|
+
# MKO serialization is one of them. All objects returned are the
|
|
16
|
+
# native gems' own classes, serialized by their own frameworks —
|
|
17
|
+
# never re-flattened into a parallel schema. Traversal dispatches on
|
|
18
|
+
# class/attribute declarations only (both model trees; zero flavor
|
|
19
|
+
# knowledge).
|
|
20
|
+
module NativeModels
|
|
21
|
+
class << self
|
|
22
|
+
include Metanorma::Document::ModelAccess
|
|
23
|
+
|
|
24
|
+
# Term entries as Glossarist::Concept objects (native to_json).
|
|
25
|
+
# lang/date are derivable defaults, overridable by callers that
|
|
26
|
+
# already computed them.
|
|
27
|
+
def glossarist_concepts(root, lang: nil, date: nil)
|
|
28
|
+
lang ||= first_lang(root)
|
|
29
|
+
date ||= published_on(root)
|
|
30
|
+
entries(root).map do |term|
|
|
31
|
+
concept_for(term, lang: lang, date: date)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# The bibliographic record as a native Relaton::Bib item. The
|
|
36
|
+
# model's bibdata is serialized to Relaton XML (its native
|
|
37
|
+
# schema) and parsed back by the relaton monogem — both
|
|
38
|
+
# directions are framework serialization.
|
|
39
|
+
def relaton_bibdata(root)
|
|
40
|
+
bib = val(root, :bibdata)
|
|
41
|
+
return nil unless bib
|
|
42
|
+
|
|
43
|
+
::Relaton::Bib::Item.from_xml(bib.to_xml)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Document identifiers parsed by the pubid monogem. Each entry
|
|
47
|
+
# carries the original text, its primary flag, and the native
|
|
48
|
+
# Pubid::Identifier (nil when no pubid flavor covers it).
|
|
49
|
+
def pubid_identifiers(root)
|
|
50
|
+
bib = val(root, :bibdata)
|
|
51
|
+
docids(bib).map do |d|
|
|
52
|
+
text = docid_text(d)
|
|
53
|
+
{ original: text, type: val(d, :type),
|
|
54
|
+
primary: val(d, :primary), pubid: parse_pubid(text) }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# One bibliography entry: the reference unit's key, the citeas
|
|
59
|
+
# string, and the NATIVE objects behind the cited document — a
|
|
60
|
+
# Relaton::Bib item and, when a pubid flavor covers it, a
|
|
61
|
+
# Pubid::Identifier. This is what makes citation edges resolvable
|
|
62
|
+
# objects instead of dangling strings.
|
|
63
|
+
class BibliographyEntry
|
|
64
|
+
attr_reader :key, :citeas, :pubid, :item
|
|
65
|
+
|
|
66
|
+
def initialize(key:, citeas:, pubid:, item:)
|
|
67
|
+
@key = key
|
|
68
|
+
@citeas = citeas
|
|
69
|
+
@pubid = pubid
|
|
70
|
+
@item = item
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Bibliography entries as native Relaton items. Every <bibitem>
|
|
75
|
+
# in every references section round-trips: model XML (the
|
|
76
|
+
# Relaton schema) parsed back by the relaton monogem.
|
|
77
|
+
def relaton_bibliography(root)
|
|
78
|
+
entries = []
|
|
79
|
+
Array(val(root, :bibliography)).each do |bib_section|
|
|
80
|
+
vals(bib_section, :references).each do |refs|
|
|
81
|
+
items = vals(refs, :bibitem)
|
|
82
|
+
items = vals(refs, :references) if items.empty?
|
|
83
|
+
items.each { |i| entries << bibliography_entry(i) }
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
entries
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def bibliography_entry(item)
|
|
90
|
+
key = val(item, :anchor) || val(item, :id)
|
|
91
|
+
citeas = docid_text(vals(item, :docidentifier).first) ||
|
|
92
|
+
PlainText.call(val(item, :formatted_ref))
|
|
93
|
+
BibliographyEntry.new(
|
|
94
|
+
key: key, citeas: citeas,
|
|
95
|
+
pubid: parse_pubid(citeas),
|
|
96
|
+
item: begin
|
|
97
|
+
::Relaton::Bib::Item.from_xml(item.to_xml)
|
|
98
|
+
rescue StandardError
|
|
99
|
+
nil
|
|
100
|
+
end
|
|
101
|
+
)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# A content block's native JSON object: the Mirror node tree —
|
|
105
|
+
# the lossless JSON serialization this gem's JS ecosystem
|
|
106
|
+
# renders from (same handlers the to-mirror CLI uses). This is
|
|
107
|
+
# the blocks' native serialization; the lutaml key-value path
|
|
108
|
+
# cannot serialize content blocks on 0.8.x.
|
|
109
|
+
def mirror_object(block)
|
|
110
|
+
transformer = ::Metanorma::Mirror::Transformer.new
|
|
111
|
+
result = ::Metanorma::Mirror.default_registry.handle(
|
|
112
|
+
block, context: transformer
|
|
113
|
+
)
|
|
114
|
+
Array(result.nodes).each do |node|
|
|
115
|
+
parsed = JSON.parse(
|
|
116
|
+
::Metanorma::Mirror::Serialization::JsonSerializer
|
|
117
|
+
.serialize(node),
|
|
118
|
+
)
|
|
119
|
+
return parsed if parsed.is_a?(Hash)
|
|
120
|
+
end
|
|
121
|
+
nil
|
|
122
|
+
rescue StandardError
|
|
123
|
+
nil
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Parsed identity [series, number, part] via the native pubid
|
|
127
|
+
# parse — the single identity parser. OIML's series letter
|
|
128
|
+
# lives in the pubid type (recommendation → R, document → D,
|
|
129
|
+
# basic publication → B, guide → G, expert report → E,
|
|
130
|
+
# vocabulary → V); publishers without a series letter (ISO,
|
|
131
|
+
# IEC) yield nil series. Returns nil when no flavor covers the
|
|
132
|
+
# identifier — callers fall back, never guess.
|
|
133
|
+
OIML_SERIES = {
|
|
134
|
+
"recommendation" => "R", "document" => "D",
|
|
135
|
+
"basic-publication" => "B", "basic_publication" => "B",
|
|
136
|
+
"guide" => "G", "expert-report" => "E", "expert_report" => "E",
|
|
137
|
+
"vocabulary" => "V"
|
|
138
|
+
}.freeze
|
|
139
|
+
|
|
140
|
+
def pubid_identity(text)
|
|
141
|
+
pubid = parse_pubid(text)
|
|
142
|
+
return nil unless pubid
|
|
143
|
+
|
|
144
|
+
native = JSON.parse(pubid.to_json)
|
|
145
|
+
series = if native["_type"].to_s.start_with?("pubid:oiml:")
|
|
146
|
+
OIML_SERIES[native["_type"].split(":").last]
|
|
147
|
+
end
|
|
148
|
+
[series, native["number"]&.to_s, native["part"]&.to_s]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Formula as a native Plurimath::Math::Formula. Plurimath is the
|
|
152
|
+
# Metanorma math ecosystem: parse from the stem's AsciiMath, or
|
|
153
|
+
# from its MathML (the mml model's own XML serialization) when
|
|
154
|
+
# only that is present. Plurimath 0.11 has no data-producing
|
|
155
|
+
# to_json — its native serializations are the to_* forms
|
|
156
|
+
# (asciimath, latex, mathml, omml, unicodemath), which is what
|
|
157
|
+
# consumers get.
|
|
158
|
+
def plurimath_formula(formula_block)
|
|
159
|
+
require "plurimath"
|
|
160
|
+
stem = val(formula_block, :stem)
|
|
161
|
+
return nil unless stem
|
|
162
|
+
|
|
163
|
+
expr = val(stem, :asciimath)&.value
|
|
164
|
+
unless expr.to_s.empty?
|
|
165
|
+
return Plurimath::Math.parse(expr.to_s, :asciimath)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
math = val(stem, :math)
|
|
169
|
+
Plurimath::Math.parse(math.to_xml, :mathml) if math
|
|
170
|
+
rescue StandardError, LoadError
|
|
171
|
+
nil
|
|
172
|
+
end
|
|
173
|
+
# "OIML" engages the day the flavor ships (pubid/pubid#342);
|
|
174
|
+
# until then Pubid::Oiml is undefined and parses nil.
|
|
175
|
+
PUBID_FLAVORS = {
|
|
176
|
+
"ISO" => :Iso, "IEC" => :Iec, "ITU" => :Itu, "BSI" => :Bsi,
|
|
177
|
+
"BS" => :Bsi, "OGC" => :Ogc, "NIST" => :Nist, "IEEE" => :Ieee,
|
|
178
|
+
"OIML" => :Oiml
|
|
179
|
+
}.freeze
|
|
180
|
+
|
|
181
|
+
# ISO 639-1 → 639-2/B for Glossarist language codes.
|
|
182
|
+
GLOSSARIST_LANG = {
|
|
183
|
+
"en" => "eng", "fr" => "fre", "de" => "ger", "es" => "spa",
|
|
184
|
+
"ar" => "ara", "ru" => "rus", "zh" => "zho", "ja" => "jpn",
|
|
185
|
+
"ko" => "kor"
|
|
186
|
+
}.freeze
|
|
187
|
+
|
|
188
|
+
private
|
|
189
|
+
|
|
190
|
+
# -- publisher → pubid flavor --------------------------------
|
|
191
|
+
|
|
192
|
+
def parse_pubid(text)
|
|
193
|
+
return nil if text.nil? || text.empty?
|
|
194
|
+
|
|
195
|
+
flavor = PUBID_FLAVORS[text[/\A([A-Za-z]+)/, 1].to_s.upcase]
|
|
196
|
+
return nil unless flavor
|
|
197
|
+
|
|
198
|
+
Pubid.const_get(flavor).parse(text)
|
|
199
|
+
rescue StandardError
|
|
200
|
+
nil
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# -- glossarist construction ---------------------------------
|
|
204
|
+
|
|
205
|
+
def concept_for(term, lang:, date:)
|
|
206
|
+
g_lang = GLOSSARIST_LANG.fetch(lang, lang)
|
|
207
|
+
designations = vals(term, :preferred)
|
|
208
|
+
.map { |d| PlainText.call(d) }.reject(&:empty?)
|
|
209
|
+
admitted = vals(term, :admitted)
|
|
210
|
+
.map { |d| PlainText.call(d) }.reject(&:empty?)
|
|
211
|
+
deprecated = vals(term, :deprecates)
|
|
212
|
+
.map { |d| PlainText.call(d) }.reject(&:empty?)
|
|
213
|
+
definition = PlainText.call(val(term, :definition))
|
|
214
|
+
sources = vals(term, :source).filter_map do |src|
|
|
215
|
+
citeas = begin
|
|
216
|
+
vals(src, :origin).first&.citeas
|
|
217
|
+
rescue StandardError
|
|
218
|
+
nil
|
|
219
|
+
end
|
|
220
|
+
citeas = PlainText.call(citeas) if citeas
|
|
221
|
+
if citeas && !citeas.empty?
|
|
222
|
+
Glossarist::ConceptSource.new(
|
|
223
|
+
type: "authoritative",
|
|
224
|
+
origin: { "ref" => { "source" => citeas } },
|
|
225
|
+
)
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
dates = if date
|
|
229
|
+
[Glossarist::ConceptDate.new(
|
|
230
|
+
date: date, type: "accepted",
|
|
231
|
+
)]
|
|
232
|
+
else
|
|
233
|
+
[]
|
|
234
|
+
end
|
|
235
|
+
Glossarist::Concept.new(
|
|
236
|
+
id: anchor_of(term),
|
|
237
|
+
data: Glossarist::ConceptData.new(
|
|
238
|
+
id: "#{anchor_of(term)}-#{g_lang}",
|
|
239
|
+
language_code: g_lang,
|
|
240
|
+
terms: [
|
|
241
|
+
["preferred", designations],
|
|
242
|
+
["admitted", admitted],
|
|
243
|
+
["deprecated", deprecated],
|
|
244
|
+
].flat_map do |status, terms|
|
|
245
|
+
terms.map do |designation|
|
|
246
|
+
Glossarist::Designation::Expression.new(
|
|
247
|
+
designation: designation, normative_status: status,
|
|
248
|
+
)
|
|
249
|
+
end
|
|
250
|
+
end,
|
|
251
|
+
definition: [Glossarist::DetailedDefinition.new(
|
|
252
|
+
content: definition,
|
|
253
|
+
)],
|
|
254
|
+
sources: sources,
|
|
255
|
+
dates: dates,
|
|
256
|
+
entry_status: "valid",
|
|
257
|
+
),
|
|
258
|
+
)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# -- term-entry traversal (both trees) -----------------------
|
|
262
|
+
#
|
|
263
|
+
# The iso tree declares entries as :term inside terms sections;
|
|
264
|
+
# the standoc tree maps them to :terms. Terms sections are
|
|
265
|
+
# recognizable by the :term declaration.
|
|
266
|
+
|
|
267
|
+
def entries(root)
|
|
268
|
+
out = []
|
|
269
|
+
collect_entries(val(root, :sections), out)
|
|
270
|
+
collect_entries(val(root, :preface), out)
|
|
271
|
+
# amendments keep their terms in annexes (e.g. OIML R 60/A1)
|
|
272
|
+
vals(root, :annex).each { |a| collect_entries(a, out) }
|
|
273
|
+
out
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def collect_entries(container, out)
|
|
277
|
+
return unless container
|
|
278
|
+
|
|
279
|
+
vals(container, :terms).each do |tsec|
|
|
280
|
+
term_entries(tsec).each { |t| out << t }
|
|
281
|
+
vals(tsec, :terms).each { |nested| collect_terms(nested, out) }
|
|
282
|
+
end
|
|
283
|
+
vals(container, :clause).each { |c| collect_entries(c, out) }
|
|
284
|
+
vals(container, :subsections).each { |c| collect_entries(c, out) }
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def collect_terms(tsec, out)
|
|
288
|
+
term_entries(tsec).each { |t| out << t }
|
|
289
|
+
vals(tsec, :terms).each { |nested| collect_terms(nested, out) }
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
def term_entries(tsec)
|
|
293
|
+
entries_ = vals(tsec, :term)
|
|
294
|
+
entries_ = vals(tsec, :terms) if entries_.empty?
|
|
295
|
+
entries_
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def anchor_of(element)
|
|
299
|
+
anchor = val(element, :anchor)
|
|
300
|
+
return anchor if anchor && !anchor.empty?
|
|
301
|
+
|
|
302
|
+
id = val(element, :id)
|
|
303
|
+
id && !id.empty? ? id : nil
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def first_lang(root)
|
|
307
|
+
bib = val(root, :bibdata)
|
|
308
|
+
PlainText.call(vals(bib, :language).first).to_s[0, 2]
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def published_on(root)
|
|
312
|
+
bib = val(root, :bibdata)
|
|
313
|
+
vals(bib, :date).filter_map { |d| PlainText.call(val(d, :on)) }
|
|
314
|
+
.first
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Document
|
|
5
|
+
# Extracts plain display text from typed model elements. Delegates to
|
|
6
|
+
# the canonical model-walking extractor shared with the HTML renderer
|
|
7
|
+
# (element_order resolution + typed attributes) — never Nokogiri over
|
|
8
|
+
# XML, never regex over HTML.
|
|
9
|
+
module PlainText
|
|
10
|
+
class Extractor
|
|
11
|
+
include Metanorma::Html::Concerns::TextExtraction
|
|
12
|
+
|
|
13
|
+
def safe_attr(obj, name)
|
|
14
|
+
return nil unless obj.is_a?(Lutaml::Model::Serializable) &&
|
|
15
|
+
obj.class.attributes.key?(name)
|
|
16
|
+
|
|
17
|
+
obj.public_send(name)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
EXTRACTOR = Extractor.new
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
# Whitespace-squashed on the way out: document text carries
|
|
25
|
+
# non-breaking spaces (U+00A0) that break exact matching; Ruby's
|
|
26
|
+
# \s is ASCII-only, so use the Unicode-aware POSIX class.
|
|
27
|
+
def call(element)
|
|
28
|
+
return squash(EXTRACTOR.extract_plain_text(element).to_s) unless element.is_a?(Array)
|
|
29
|
+
|
|
30
|
+
element.map { |e| call(e) }.reject(&:empty?).join(" ")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def squash(text)
|
|
34
|
+
text.gsub(/[[:space:]]+/, " ").strip
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -12,11 +12,15 @@ module Metanorma
|
|
|
12
12
|
class VersionInfo < Lutaml::Model::Serializable
|
|
13
13
|
attribute :revision_date, :string
|
|
14
14
|
attribute :draft, :string
|
|
15
|
+
# Legacy presentation XML states the version as bare text
|
|
16
|
+
# (<version>2018-01-17</version>), e.g. the BIPM draft date.
|
|
17
|
+
attribute :content, :string
|
|
15
18
|
|
|
16
19
|
xml do
|
|
17
20
|
element "version"
|
|
18
21
|
map_element "revision-date", to: :revision_date
|
|
19
22
|
map_element "draft", to: :draft
|
|
23
|
+
map_content to: :content
|
|
20
24
|
end
|
|
21
25
|
end
|
|
22
26
|
end
|
data/lib/metanorma/document.rb
CHANGED
|
@@ -16,8 +16,16 @@ module Metanorma
|
|
|
16
16
|
# for a seamless migration from/to those.
|
|
17
17
|
module Document
|
|
18
18
|
autoload :Components, "metanorma/document/components"
|
|
19
|
+
# Mirror: the format lives in the metanorma-mirror gem; this gem
|
|
20
|
+
# registers its model knowledge (handlers, mark tables, id
|
|
21
|
+
# categories) through the gem's seams.
|
|
22
|
+
autoload :MirrorSeed, "metanorma/document/mirror_seed"
|
|
19
23
|
autoload :DataTypes, "metanorma/document/data_types"
|
|
20
24
|
autoload :Elements, "metanorma/document/elements"
|
|
25
|
+
autoload :GrammarVocabulary, "metanorma/document/grammar_vocabulary"
|
|
26
|
+
autoload :ModelAccess, "metanorma/document/model_access"
|
|
27
|
+
autoload :NativeModels, "metanorma/document/native_models"
|
|
28
|
+
autoload :PlainText, "metanorma/document/plain_text"
|
|
21
29
|
autoload :Relaton, "metanorma/document/relaton"
|
|
22
30
|
autoload :Root, "metanorma/document/root"
|
|
23
31
|
autoload :Version, "metanorma/document/version"
|
|
@@ -30,37 +38,22 @@ module Metanorma
|
|
|
30
38
|
# For now, we cannot parse arbitrary XML into Lutaml models without knowing
|
|
31
39
|
# the target class. This will be addressed in a future refactoring.
|
|
32
40
|
# BasicDocument does not have XML root mapping and cannot be used to parse
|
|
33
|
-
# documents directly. Use
|
|
41
|
+
# documents directly. Use a flavor document model for specific flavors.
|
|
34
42
|
raise NotImplementedError,
|
|
35
43
|
"BasicDocument cannot parse XML directly. " \
|
|
36
|
-
"Use
|
|
37
|
-
"or implement a custom parser
|
|
44
|
+
"Use a flavor document model (e.g. Metanorma::Standoc::Document::Root " \
|
|
45
|
+
"from metanorma-standoc), or implement a custom parser."
|
|
38
46
|
end
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
autoload :BasicDocument, "#{__dir__}/basic_document"
|
|
42
|
-
autoload :
|
|
43
|
-
autoload :IsoDocument, "metanorma/iso_document"
|
|
44
|
-
autoload :IecDocument, "metanorma/iec_document"
|
|
45
|
-
autoload :IeeeDocument, "metanorma/ieee_document"
|
|
46
|
-
autoload :IetfDocument, "metanorma/ietf_document"
|
|
47
|
-
autoload :IhoDocument, "metanorma/iho_document"
|
|
48
|
-
autoload :CcDocument, "metanorma/cc_document"
|
|
49
|
-
autoload :CsaDocument, "metanorma/csa_document"
|
|
50
|
-
autoload :BipmDocument, "metanorma/bipm_document"
|
|
51
|
-
autoload :BsiDocument, "metanorma/bsi_document"
|
|
52
|
-
autoload :GbDocument, "metanorma/gb_document"
|
|
53
|
-
autoload :GenericDocument, "metanorma/generic_document"
|
|
54
|
-
autoload :ItuDocument, "metanorma/itu_document"
|
|
55
|
-
autoload :JisDocument, "metanorma/jis_document"
|
|
56
|
-
autoload :M3dDocument, "metanorma/m3d_document"
|
|
57
|
-
autoload :NistDocument, "metanorma/nist_document"
|
|
58
|
-
autoload :OgcDocument, "metanorma/ogc_document"
|
|
59
|
-
autoload :PlateauDocument, "metanorma/plateau_document"
|
|
60
|
-
autoload :Registers, "metanorma/registers"
|
|
61
|
-
autoload :RiboseDocument, "metanorma/ribose_document"
|
|
62
|
-
autoload :UnDocument, "metanorma/un_document"
|
|
63
|
-
autoload :Collection, "metanorma/collection"
|
|
50
|
+
autoload :DocumentCollection, "metanorma/document_collection"
|
|
64
51
|
autoload :Html, "metanorma/html"
|
|
65
|
-
|
|
52
|
+
# Mko: the format lives in the metanorma-mko gem; Metanorma::Mko is
|
|
53
|
+
# REOPENED by the model side (document/mko.rb) with the projection
|
|
54
|
+
# walk and export entry points.
|
|
55
|
+
autoload :Mko, "metanorma/document/mko"
|
|
66
56
|
end
|
|
57
|
+
|
|
58
|
+
require "metanorma/mirror"
|
|
59
|
+
Metanorma::Document::MirrorSeed.register
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Metanorma
|
|
4
|
-
module
|
|
4
|
+
module DocumentCollection
|
|
5
5
|
# A key-value directive in a metanorma-collection.
|
|
6
6
|
# Directives control collection behavior (e.g., documents-inline, flavor).
|
|
7
7
|
class Directive < Lutaml::Model::Serializable
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Metanorma
|
|
4
|
-
module
|
|
4
|
+
module DocumentCollection
|
|
5
5
|
# A container for an embedded document within a metanorma-collection.
|
|
6
6
|
# Each doc-container holds one <metanorma> document identified by its id attribute.
|
|
7
7
|
class DocContainer < Lutaml::Model::Serializable
|
|
8
8
|
attribute :id, :string
|
|
9
|
-
|
|
9
|
+
# Embedded documents belong to whichever flavor authored them; the
|
|
10
|
+
# harness carries only the neutral base root. Flavor-faithful parsing
|
|
11
|
+
# arrives with lutaml polymorphic differentiators (subclass roots
|
|
12
|
+
# declaring polymorphic_class: true), not by typing against a flavor.
|
|
13
|
+
attribute :document, Metanorma::Document::Root
|
|
10
14
|
|
|
11
15
|
xml do
|
|
12
16
|
element "doc-container"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Metanorma
|
|
4
|
-
module
|
|
4
|
+
module DocumentCollection
|
|
5
5
|
# An entry in a metanorma-collection manifest.
|
|
6
6
|
# Entries are recursive — a top-level entry can contain nested entries,
|
|
7
7
|
# each representing a document in the collection.
|
|
@@ -13,7 +13,7 @@ module Metanorma
|
|
|
13
13
|
attribute :type, :string
|
|
14
14
|
attribute :title, :string
|
|
15
15
|
attribute :format, :string, collection: true
|
|
16
|
-
attribute :bibdata, Metanorma::
|
|
16
|
+
attribute :bibdata, Metanorma::Document::Components::BibData::BibliographicItem
|
|
17
17
|
attribute :entry, Entry, collection: true
|
|
18
18
|
|
|
19
19
|
xml do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Metanorma
|
|
4
|
-
module
|
|
4
|
+
module DocumentCollection
|
|
5
5
|
# Root model for <metanorma-collection> XML.
|
|
6
6
|
# Represents a collection of Metanorma documents bundled together,
|
|
7
7
|
# with shared metadata, directives, and a manifest of entries.
|
|
@@ -10,7 +10,7 @@ module Metanorma
|
|
|
10
10
|
# (presentation). Embedded <metanorma> documents inside doc-containers use
|
|
11
11
|
# the standoc namespace (https://www.metanorma.org/ns/standoc).
|
|
12
12
|
class Root < Lutaml::Model::Serializable
|
|
13
|
-
attribute :bibdata, Metanorma::
|
|
13
|
+
attribute :bibdata, Metanorma::Document::Components::BibData::BibliographicItem
|
|
14
14
|
attribute :directive, Directive, collection: true
|
|
15
15
|
attribute :entry, Entry
|
|
16
16
|
attribute :format, :string, collection: true
|