metanorma-document 0.5.2 → 0.5.3
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/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +0 -4
- data/lib/metanorma/html.rb +1 -0
- metadata +3 -21
- data/lib/metanorma/document/mko/collection.rb +0 -168
- data/lib/metanorma/document/mko/exporter.rb +0 -17
- data/lib/metanorma/document/mko/project.rb +0 -1110
- data/lib/metanorma/document/mko.rb +0 -122
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 04e4e3d87a05bc01db83285af228b7090952df9373ba6b328ea32841c13866e9
|
|
4
|
+
data.tar.gz: c61eebc585cad21a0c225be99c2a3d8b6af9b20be445ea60939c4ece5a3a83ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f737792bf29a40e459a4e593f09a49223737e8c5bd0d9ce232e9666424e2702b49ff03840c6ce9d0830446180c85640c8ce2b381eef9cd029bbc4c4589e9324f
|
|
7
|
+
data.tar.gz: 9fa9a7ed0342e751f08202a28149981063ab8ffa63d2147fbc2fb96d0dcd6869d1dbce4494dfef631220b214b4dec732c1b5e4e5e87a29539eb8f850d9acaf06
|
data/lib/metanorma/document.rb
CHANGED
|
@@ -49,10 +49,6 @@ module Metanorma
|
|
|
49
49
|
autoload :BasicDocument, "#{__dir__}/basic_document"
|
|
50
50
|
autoload :DocumentCollection, "metanorma/document_collection"
|
|
51
51
|
autoload :Html, "metanorma/html"
|
|
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"
|
|
56
52
|
end
|
|
57
53
|
|
|
58
54
|
require "metanorma/mirror"
|
data/lib/metanorma/html.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Metanorma
|
|
|
18
18
|
autoload :Concerns, "metanorma/html/concerns"
|
|
19
19
|
autoload :Generator, "metanorma/html/generator"
|
|
20
20
|
autoload :RendererDelegation, "metanorma/html/renderer_delegation"
|
|
21
|
+
autoload :Renderers, "metanorma/html/renderers"
|
|
21
22
|
autoload :Theme, "metanorma/html/theme"
|
|
22
23
|
autoload :AssetPipeline, "metanorma/html/asset_pipeline"
|
|
23
24
|
autoload :Component, "metanorma/html/component"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-document
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
@@ -81,7 +81,7 @@ dependencies:
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '2.0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: relaton
|
|
84
|
+
name: relaton-cli
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
@@ -108,20 +108,6 @@ dependencies:
|
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '2.13'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: metanorma-mko
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - ">="
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: 1.0.0
|
|
118
|
-
type: :runtime
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - ">="
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: 1.0.0
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
112
|
name: plurimath
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -625,10 +611,6 @@ files:
|
|
|
625
611
|
- lib/metanorma/document/elements/input.rb
|
|
626
612
|
- lib/metanorma/document/grammar_vocabulary.rb
|
|
627
613
|
- lib/metanorma/document/mirror_seed.rb
|
|
628
|
-
- lib/metanorma/document/mko.rb
|
|
629
|
-
- lib/metanorma/document/mko/collection.rb
|
|
630
|
-
- lib/metanorma/document/mko/exporter.rb
|
|
631
|
-
- lib/metanorma/document/mko/project.rb
|
|
632
614
|
- lib/metanorma/document/model_access.rb
|
|
633
615
|
- lib/metanorma/document/native_models.rb
|
|
634
616
|
- lib/metanorma/document/plain_text.rb
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "yaml"
|
|
4
|
-
|
|
5
|
-
module Metanorma
|
|
6
|
-
module Mko
|
|
7
|
-
# Collection export (MN 116 §collections): a metanorma
|
|
8
|
-
# collection.yml declares a document family (OIML R 60 parts,
|
|
9
|
-
# amendments, R 129/138/144). Every member document exports as its
|
|
10
|
-
# own bundle (the document bundle is the unit of truth); the
|
|
11
|
-
# collection adds one small bundle with the membership contract:
|
|
12
|
-
# collection.json and the cross-document part_of edges binding the
|
|
13
|
-
# members to the family. Member identity comes from each member's
|
|
14
|
-
# exported document.json — the collection yml's identifiers are
|
|
15
|
-
# reference labels only.
|
|
16
|
-
class Collection
|
|
17
|
-
Member = Struct.new(:fileref, :xml_path, :identifier,
|
|
18
|
-
:bundle_path, :result, :skipped,
|
|
19
|
-
keyword_init: true)
|
|
20
|
-
|
|
21
|
-
class Result
|
|
22
|
-
attr_reader :collection_bundle, :members
|
|
23
|
-
|
|
24
|
-
def initialize(collection_bundle:, members:)
|
|
25
|
-
@collection_bundle = collection_bundle
|
|
26
|
-
@members = members
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def skipped
|
|
30
|
-
members.select(&:skipped)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class << self
|
|
35
|
-
def export(yml, to:, assets_from: nil, zip: false)
|
|
36
|
-
new(yml, to: to, assets_from: assets_from, zip: zip).export
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def initialize(yml, to:, assets_from: nil, zip: false)
|
|
41
|
-
@yml = if yml.is_a?(Hash)
|
|
42
|
-
yml
|
|
43
|
-
elsif File.exist?(yml.to_s)
|
|
44
|
-
YAML.safe_load_file(yml)
|
|
45
|
-
else
|
|
46
|
-
YAML.safe_load(yml)
|
|
47
|
-
end
|
|
48
|
-
@base = File.exist?(yml.to_s) ? File.dirname(File.expand_path(yml.to_s)) : Dir.pwd
|
|
49
|
-
@to = to
|
|
50
|
-
@assets_from = assets_from
|
|
51
|
-
@zip = zip
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def export
|
|
55
|
-
members = docrefs.filter_map do |ref|
|
|
56
|
-
member = resolve_member(ref)
|
|
57
|
-
next member if member.skipped
|
|
58
|
-
|
|
59
|
-
export = Mko.export(
|
|
60
|
-
File.read(member.xml_path), to: @to,
|
|
61
|
-
presentation_xml: presentation_for(member.xml_path),
|
|
62
|
-
assets_from: @assets_from || File.dirname(member.xml_path)
|
|
63
|
-
)
|
|
64
|
-
member.bundle_path = export.path
|
|
65
|
-
member.result = export.result
|
|
66
|
-
member
|
|
67
|
-
end
|
|
68
|
-
Result.new(collection_bundle: write_collection_bundle(members),
|
|
69
|
-
members: members)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
def docrefs
|
|
75
|
-
manifest = @yml["manifest"]
|
|
76
|
-
manifest = manifest.first if manifest.is_a?(Array)
|
|
77
|
-
Array(manifest.is_a?(Hash) ? manifest["docref"] : nil)
|
|
78
|
-
rescue StandardError
|
|
79
|
-
[]
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# The yml points members at .adoc sources; the compiled semantic
|
|
83
|
-
# XML sits beside them. Direct .xml filerefs work too.
|
|
84
|
-
def resolve_member(ref)
|
|
85
|
-
fileref = ref["fileref"].to_s
|
|
86
|
-
xml = fileref.end_with?(".xml") ? fileref : fileref.sub(/\.adoc$/, ".xml")
|
|
87
|
-
path = File.expand_path(xml, @base)
|
|
88
|
-
if File.file?(path)
|
|
89
|
-
Member.new(fileref: fileref, xml_path: path,
|
|
90
|
-
identifier: ref["identifier"])
|
|
91
|
-
else
|
|
92
|
-
Member.new(fileref: fileref, xml_path: path,
|
|
93
|
-
identifier: ref["identifier"], skipped: true)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def presentation_for(xml_path)
|
|
98
|
-
pres = xml_path.sub(/\.xml$/, ".presentation.xml")
|
|
99
|
-
File.file?(pres) ? File.read(pres) : nil
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def canonical
|
|
103
|
-
docid = @yml.dig("bibdata", "docid")
|
|
104
|
-
docid = docid.first if docid.is_a?(Array)
|
|
105
|
-
docid.is_a?(Hash) ? docid["id"].to_s : docid.to_s
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def title
|
|
109
|
-
t = @yml.dig("bibdata", "title")
|
|
110
|
-
t = t.first if t.is_a?(Array)
|
|
111
|
-
t.is_a?(Hash) ? t["content"].to_s : t.to_s
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def collection_short
|
|
115
|
-
Mko.slug(canonical.empty? ? "collection" : canonical)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Member identity from the export's own Result — the same truth
|
|
119
|
-
# the bundle was written from, never a read-back of our output.
|
|
120
|
-
def member_data(member)
|
|
121
|
-
document = member.result.document
|
|
122
|
-
{ "bundle" => "#{document.ids.short}.mko",
|
|
123
|
-
"docidentifier" => document.ids.canonical,
|
|
124
|
-
"identifier" => member.identifier,
|
|
125
|
-
"title" => document.titles.first&.text,
|
|
126
|
-
"edition" => document.edition }
|
|
127
|
-
rescue StandardError
|
|
128
|
-
nil
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def collection_member(member)
|
|
132
|
-
data = member_data(member) or return nil
|
|
133
|
-
|
|
134
|
-
Schema::CollectionMember.new(
|
|
135
|
-
bundle: data["bundle"], docidentifier: data["docidentifier"],
|
|
136
|
-
identifier: data["identifier"], title: data["title"],
|
|
137
|
-
edition: data["edition"]
|
|
138
|
-
)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def write_collection_bundle(members)
|
|
142
|
-
collection = Schema::Collection.new(
|
|
143
|
-
canonical: canonical, short: collection_short, title: title,
|
|
144
|
-
edition: @yml.dig("bibdata", "edition"),
|
|
145
|
-
members: members.filter_map { |m| collection_member(m) }
|
|
146
|
-
)
|
|
147
|
-
# A member whose identity collides with the family (e.g. a
|
|
148
|
-
# stale amendment bibdata — mn-samples-oiml#66) would emit a
|
|
149
|
-
# self-edge; skip those, they say nothing.
|
|
150
|
-
edges = collection.members.reject do |m|
|
|
151
|
-
m.docidentifier.to_s.empty? || m.docidentifier == collection.canonical
|
|
152
|
-
end.map do |m|
|
|
153
|
-
{ "from" => "doc:#{m.docidentifier}",
|
|
154
|
-
"to" => "doc:#{collection.canonical}",
|
|
155
|
-
"kind" => "part_of" }
|
|
156
|
-
end
|
|
157
|
-
bundle = Bundle.open(collection_short, @to)
|
|
158
|
-
bundle.flavor = nil
|
|
159
|
-
bundle.add_json("collection", "collection.json", collection)
|
|
160
|
-
bundle.add_lines("edges", "edges.jsonl", edges) do |edge|
|
|
161
|
-
JSON.generate(edge)
|
|
162
|
-
end
|
|
163
|
-
bundle.write_manifest
|
|
164
|
-
@zip ? bundle.zip! : bundle.dir
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mko
|
|
5
|
-
# Registry-facing exporter: quacks like a renderer (generate_full_document)
|
|
6
|
-
# so the Core::Flavors format table and the compile pipeline can select
|
|
7
|
-
# mko like any output format.
|
|
8
|
-
class Exporter
|
|
9
|
-
def generate_full_document(document, **options)
|
|
10
|
-
output = options[:output] || options[:output_filename] || "."
|
|
11
|
-
to = File.directory?(output) ? output : File.dirname(output)
|
|
12
|
-
Mko.export(document, to: to,
|
|
13
|
-
presentation_xml: options[:presentation_xml])
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|