stepmod-utils 0.6.8 → 0.6.10.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/.github/workflows/rake.yml +8 -3
- data/.github/workflows/test-concept-generation.yml +1 -1
- data/.rubocop.yml +1 -1
- data/Gemfile +6 -3
- data/exe/stepmod-convert-express-description +1 -1
- data/exe/stepmod-convert-express-resource +1 -1
- data/lib/stepmod/utils/cleaner.rb +4 -3
- data/lib/stepmod/utils/concept.rb +33 -17
- data/lib/stepmod/utils/converters/a.rb +1 -1
- data/lib/stepmod/utils/converters/arm.rb +1 -1
- data/lib/stepmod/utils/converters/base.rb +3 -3
- data/lib/stepmod/utils/converters/clause_ref.rb +1 -1
- data/lib/stepmod/utils/converters/comment.rb +1 -1
- data/lib/stepmod/utils/converters/dd.rb +1 -1
- data/lib/stepmod/utils/converters/def.rb +2 -2
- data/lib/stepmod/utils/converters/definition.rb +1 -1
- data/lib/stepmod/utils/converters/description.rb +1 -1
- data/lib/stepmod/utils/converters/dl.rb +1 -1
- data/lib/stepmod/utils/converters/dt.rb +1 -1
- data/lib/stepmod/utils/converters/em.rb +2 -2
- data/lib/stepmod/utils/converters/em_express_description.rb +5 -1
- data/lib/stepmod/utils/converters/eqn.rb +2 -2
- data/lib/stepmod/utils/converters/example.rb +1 -1
- data/lib/stepmod/utils/converters/express_figure.rb +2 -1
- data/lib/stepmod/utils/converters/express_g.rb +1 -1
- data/lib/stepmod/utils/converters/express_note.rb +1 -1
- data/lib/stepmod/utils/converters/express_ref.rb +1 -1
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +2 -1
- data/lib/stepmod/utils/converters/ext_description.rb +2 -1
- data/lib/stepmod/utils/converters/ext_descriptions.rb +2 -1
- data/lib/stepmod/utils/converters/figure.rb +2 -2
- data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
- data/lib/stepmod/utils/converters/introduction.rb +1 -1
- data/lib/stepmod/utils/converters/li.rb +2 -2
- data/lib/stepmod/utils/converters/module_ref.rb +1 -1
- data/lib/stepmod/utils/converters/module_ref_express_description.rb +2 -2
- data/lib/stepmod/utils/converters/note.rb +1 -1
- data/lib/stepmod/utils/converters/ol.rb +2 -2
- data/lib/stepmod/utils/converters/resource.rb +1 -1
- data/lib/stepmod/utils/converters/schema.rb +1 -1
- data/lib/stepmod/utils/converters/schema_diag.rb +1 -1
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +2 -1
- data/lib/stepmod/utils/converters/strong.rb +2 -2
- data/lib/stepmod/utils/converters/sub.rb +8 -3
- data/lib/stepmod/utils/converters/sup.rb +8 -3
- data/lib/stepmod/utils/converters/synonym.rb +1 -1
- data/lib/stepmod/utils/converters/table.rb +2 -2
- data/lib/stepmod/utils/converters/term.rb +1 -1
- data/lib/stepmod/utils/converters/text.rb +2 -2
- data/lib/stepmod/utils/converters/tr.rb +2 -2
- data/lib/stepmod/utils/smrl_description_converter.rb +2 -2
- data/lib/stepmod/utils/smrl_resource_converter.rb +2 -2
- data/lib/stepmod/utils/stepmod_definition_converter.rb +2 -2
- data/lib/stepmod/utils/stepmod_file_annotator.rb +12 -12
- data/lib/stepmod/utils/term.rb +36 -14
- data/lib/stepmod/utils/terms_extractor.rb +18 -14
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +16 -17
- metadata +25 -71
- data/.hound.yml +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8b65cef0a5a325ab2e28a21e5dcd38be81535e4cac5662b2dd4bc4244ce1d40
|
|
4
|
+
data.tar.gz: 8259f12eb5f6f2e4df159be483c36335e7b715aad8793943ea61a60523e812f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8b84ea4e01a4c46c105c3be24bac8aedccb38ba41bb1bc0a60f43cd12f53a64895714c70824cc7cec4d82261135e38eef82871bd7e2c0df3c0124730c1b53e7
|
|
7
|
+
data.tar.gz: f1fabfe7cf7da21378c85563996da2d262a950c951936a530db0d650b32b8188a36f929429f986a90a30c7f43c2267e180bd3cead1450aead8765b921aa8916e
|
data/.github/workflows/rake.yml
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# Formerly cimas-managed. Now consumer-owned per metanorma/cimas#68
|
|
2
|
+
# (workflow-file conversion from cimas-synced copied stubs to reusable-workflow
|
|
3
|
+
# references). Pins metanorma/ci reusable at @v1 (moving major, three-tier
|
|
4
|
+
# tagging discipline per metanorma/ci#372).
|
|
3
5
|
name: rake
|
|
4
6
|
|
|
5
7
|
on:
|
|
@@ -8,8 +10,11 @@ on:
|
|
|
8
10
|
tags: [ v* ]
|
|
9
11
|
pull_request:
|
|
10
12
|
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write
|
|
15
|
+
|
|
11
16
|
jobs:
|
|
12
17
|
rake:
|
|
13
|
-
uses: metanorma/ci/.github/workflows/generic-rake.yml@
|
|
18
|
+
uses: metanorma/ci/.github/workflows/generic-rake.yml@v1
|
|
14
19
|
secrets:
|
|
15
20
|
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -5,7 +5,10 @@ source "https://rubygems.org"
|
|
|
5
5
|
gemspec
|
|
6
6
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
7
7
|
|
|
8
|
-
gem "concurrent-ruby"
|
|
8
|
+
gem "concurrent-ruby"
|
|
9
9
|
gem "pry"
|
|
10
|
-
gem "rake"
|
|
11
|
-
gem "rspec"
|
|
10
|
+
gem "rake"
|
|
11
|
+
gem "rspec"
|
|
12
|
+
gem "rubocop"
|
|
13
|
+
gem "rubocop-performance"
|
|
14
|
+
gem "rubocop-rails"
|
|
@@ -11,7 +11,7 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
|
11
11
|
require "bundler/setup"
|
|
12
12
|
require "stepmod/utils/smrl_description_converter"
|
|
13
13
|
|
|
14
|
-
Coradoc::Input::
|
|
14
|
+
Coradoc::Input::Html.config.unknown_tags = :bypass
|
|
15
15
|
|
|
16
16
|
input_content = ARGF.read
|
|
17
17
|
|
|
@@ -11,7 +11,7 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
|
11
11
|
require "bundler/setup"
|
|
12
12
|
require "stepmod/utils/smrl_resource_converter"
|
|
13
13
|
|
|
14
|
-
Coradoc::Input::
|
|
14
|
+
Coradoc::Input::Html.config.unknown_tags = :bypass
|
|
15
15
|
|
|
16
16
|
input_content = ARGF.read
|
|
17
17
|
|
|
@@ -2,13 +2,13 @@ require "coradoc/input/html/cleaner"
|
|
|
2
2
|
|
|
3
3
|
module Stepmod
|
|
4
4
|
module Utils
|
|
5
|
-
class Cleaner < Coradoc::Input::
|
|
5
|
+
class Cleaner < Coradoc::Input::Html::Cleaner
|
|
6
6
|
def tidy(string)
|
|
7
7
|
super
|
|
8
8
|
.gsub(/^ +/, "")
|
|
9
9
|
.gsub(/\*\s([,.])/, '*\1') # remove space between * and comma or dot.
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
# Find non-asterisk content that is enclosed by two or
|
|
13
13
|
# more asterisks. Ensure that only one whitespace occurs
|
|
14
14
|
# in the border area.
|
|
@@ -23,7 +23,8 @@ module Stepmod
|
|
|
23
23
|
result = string.dup
|
|
24
24
|
patterns.each do |pattern, value|
|
|
25
25
|
result = result.gsub(pattern) do |match|
|
|
26
|
-
preserve_border_whitespaces(match,
|
|
26
|
+
preserve_border_whitespaces(match,
|
|
27
|
+
default_border: Coradoc::Input::Html.config.tag_border) do
|
|
27
28
|
match.strip.sub(" #{value}", value).sub("#{value} ", value)
|
|
28
29
|
end
|
|
29
30
|
end
|
|
@@ -3,16 +3,17 @@ require "glossarist"
|
|
|
3
3
|
module Stepmod
|
|
4
4
|
module Utils
|
|
5
5
|
class Concept < Glossarist::LocalizedConcept
|
|
6
|
-
|
|
6
|
+
CUSTOM_ATTRIBUTES = %w(
|
|
7
7
|
reference_clause
|
|
8
8
|
reference_anchor
|
|
9
9
|
converted_definition
|
|
10
10
|
file_path
|
|
11
11
|
schema
|
|
12
12
|
part
|
|
13
|
-
domain
|
|
14
13
|
document
|
|
15
|
-
)
|
|
14
|
+
).freeze
|
|
15
|
+
|
|
16
|
+
attr_accessor(*CUSTOM_ATTRIBUTES)
|
|
16
17
|
|
|
17
18
|
# TODO: converted_definition is not supposed to be an attribute, it is
|
|
18
19
|
# supposed to be a method!
|
|
@@ -45,14 +46,20 @@ file_path:, language_code: "eng")
|
|
|
45
46
|
# TODO: `designations:` should include the `alt:[...]` terms here,
|
|
46
47
|
# they are now only included in definition_xml_converted_definition.
|
|
47
48
|
new(
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
data: Glossarist::ConceptData.new(
|
|
50
|
+
{
|
|
51
|
+
terms: designation,
|
|
52
|
+
definition: [
|
|
53
|
+
Glossarist::DetailedDefinition.new({ content: definition }),
|
|
54
|
+
],
|
|
55
|
+
language_code: language_code,
|
|
56
|
+
},
|
|
57
|
+
),
|
|
50
58
|
converted_definition: converted_definition,
|
|
51
59
|
id: "#{reference_anchor}.#{reference_clause}",
|
|
52
60
|
reference_anchor: reference_anchor,
|
|
53
61
|
reference_clause: reference_clause,
|
|
54
62
|
file_path: file_path,
|
|
55
|
-
language_code: language_code,
|
|
56
63
|
)
|
|
57
64
|
end
|
|
58
65
|
|
|
@@ -80,7 +87,9 @@ file_path:, language_code: "eng")
|
|
|
80
87
|
designations << { "designation" => alt, "type" => "expression" }
|
|
81
88
|
end
|
|
82
89
|
|
|
83
|
-
designations
|
|
90
|
+
designations.map do |des|
|
|
91
|
+
Glossarist::Designation::Base.from_yaml(des.to_yaml)
|
|
92
|
+
end
|
|
84
93
|
end
|
|
85
94
|
|
|
86
95
|
def definition_xml_definition(definition_xml, reference_anchor)
|
|
@@ -106,24 +115,19 @@ file_path:, language_code: "eng")
|
|
|
106
115
|
end
|
|
107
116
|
|
|
108
117
|
def definition_xml_converted_definition(designation, definition)
|
|
109
|
-
accepted_designation = designation.select
|
|
110
|
-
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
alt_designations = designation.reject do |des|
|
|
114
|
-
des["normative_status"] == "preferred"
|
|
115
|
-
end
|
|
118
|
+
accepted_designation = designation.select(&:preferred?)
|
|
119
|
+
alt_designations = designation.reject(&:preferred?)
|
|
116
120
|
|
|
117
121
|
if alt_designations.length.positive?
|
|
118
122
|
alt_designations_text = alt_designations.map do |d|
|
|
119
|
-
d
|
|
123
|
+
d.designation.strip
|
|
120
124
|
end.join(",")
|
|
121
125
|
|
|
122
126
|
alt_notation = "alt:[#{alt_designations_text}]"
|
|
123
127
|
end
|
|
124
128
|
|
|
125
129
|
result = <<~TEXT
|
|
126
|
-
=== #{accepted_designation.map { |d| d
|
|
130
|
+
=== #{accepted_designation.map { |d| d.designation.strip }.join(',')}
|
|
127
131
|
TEXT
|
|
128
132
|
|
|
129
133
|
if alt_notation
|
|
@@ -140,6 +144,14 @@ file_path:, language_code: "eng")
|
|
|
140
144
|
end
|
|
141
145
|
end
|
|
142
146
|
|
|
147
|
+
def initialize(hash = {})
|
|
148
|
+
super(hash)
|
|
149
|
+
|
|
150
|
+
CUSTOM_ATTRIBUTES.each do |attr|
|
|
151
|
+
public_send("#{attr}=", hash[attr] || hash[attr.to_sym])
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
143
155
|
def to_h
|
|
144
156
|
super.merge({
|
|
145
157
|
"domain" => domain,
|
|
@@ -149,9 +161,13 @@ file_path:, language_code: "eng")
|
|
|
149
161
|
}.compact)
|
|
150
162
|
end
|
|
151
163
|
|
|
164
|
+
def domain
|
|
165
|
+
data.domain
|
|
166
|
+
end
|
|
167
|
+
|
|
152
168
|
def to_mn_adoc
|
|
153
169
|
<<~TEXT
|
|
154
|
-
// STEPmod path:#{file_path.empty? ? '' : " #{file_path}"}
|
|
170
|
+
// STEPmod path:#{file_path.to_s.empty? ? '' : " #{file_path}"}
|
|
155
171
|
#{converted_definition}
|
|
156
172
|
|
|
157
173
|
[.source]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "coradoc"
|
|
2
|
+
require "coradoc/input/html"
|
|
3
3
|
|
|
4
4
|
module Stepmod
|
|
5
5
|
module Utils
|
|
6
6
|
module Converters
|
|
7
|
-
class Base < Coradoc::Input::
|
|
7
|
+
class Base < Coradoc::Input::Html::Converters::Base
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -78,8 +78,8 @@ module Stepmod
|
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
Coradoc::Input::
|
|
82
|
-
Coradoc::Input::
|
|
81
|
+
Coradoc::Input::Html::Converters.register :def, Def.new
|
|
82
|
+
Coradoc::Input::Html::Converters.register :description, Def.new
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -14,8 +14,8 @@ module Stepmod
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
Coradoc::Input::
|
|
18
|
-
Coradoc::Input::
|
|
17
|
+
Coradoc::Input::Html::Converters.register :em, Em.new
|
|
18
|
+
Coradoc::Input::Html::Converters.register :cite, Em.new
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -8,6 +8,10 @@ module Stepmod
|
|
|
8
8
|
italic_converted(node, state)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
def to_coradoc(node, state = {})
|
|
12
|
+
italic_converted(node, state)
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
private
|
|
12
16
|
|
|
13
17
|
def italic_converted(node, state)
|
|
@@ -44,7 +48,7 @@ module Stepmod
|
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
|
|
47
|
-
Coradoc::Input::
|
|
51
|
+
Coradoc::Input::Html::Converters.register :i, Em.new
|
|
48
52
|
end
|
|
49
53
|
end
|
|
50
54
|
end
|
|
@@ -123,8 +123,8 @@ module Stepmod
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
Coradoc::Input::
|
|
127
|
-
Coradoc::Input::
|
|
126
|
+
Coradoc::Input::Html::Converters.register :eqn, Eqn.new
|
|
127
|
+
Coradoc::Input::Html::Converters.register :bigeqn, Eqn.new
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
end
|
|
@@ -7,7 +7,8 @@ module Stepmod
|
|
|
7
7
|
"<<express:#{parts.join('.').strip},#{parts.last.strip}>>"
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
|
-
Coradoc::Input::
|
|
10
|
+
Coradoc::Input::Html::Converters.register :express_ref,
|
|
11
|
+
ExpressRefExpressDescription.new
|
|
11
12
|
end
|
|
12
13
|
end
|
|
13
14
|
end
|
|
@@ -5,7 +5,7 @@ require "coradoc/input/html/converters/figure"
|
|
|
5
5
|
module Stepmod
|
|
6
6
|
module Utils
|
|
7
7
|
module Converters
|
|
8
|
-
class Figure < Coradoc::Input::
|
|
8
|
+
class Figure < Coradoc::Input::Html::Converters::Figure
|
|
9
9
|
def self.pattern(state, id)
|
|
10
10
|
if state[:schema_and_entity].nil?
|
|
11
11
|
raise StandardError.new("[figure]: no state given, #{id}")
|
|
@@ -43,7 +43,7 @@ module Stepmod
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# This replaces the converter
|
|
46
|
-
Coradoc::Input::
|
|
46
|
+
Coradoc::Input::Html::Converters.register :figure, Figure.new
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Stepmod
|
|
4
4
|
module Utils
|
|
5
5
|
module Converters
|
|
6
|
-
class Li < Coradoc::Input::
|
|
6
|
+
class Li < Coradoc::Input::Html::Converters::Li
|
|
7
7
|
def to_coradoc(node, state = {})
|
|
8
8
|
li = super
|
|
9
9
|
li.content = li.content.map do |content|
|
|
@@ -14,7 +14,7 @@ module Stepmod
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
Coradoc::Input::
|
|
17
|
+
Coradoc::Input::Html::Converters.register :li, Li.new
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -45,8 +45,8 @@ module Stepmod
|
|
|
45
45
|
# puts "[module_ref] #{result}"
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
|
-
Coradoc::Input::
|
|
49
|
-
|
|
48
|
+
Coradoc::Input::Html::Converters.register :module_ref,
|
|
49
|
+
ModuleRefExpressDescription.new
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Stepmod
|
|
4
4
|
module Utils
|
|
5
5
|
module Converters
|
|
6
|
-
class Ol < Coradoc::Input::
|
|
6
|
+
class Ol < Coradoc::Input::Html::Converters::Ol
|
|
7
7
|
LIST_TAGS = ["ol", "ul", "dir"].freeze
|
|
8
8
|
|
|
9
9
|
def to_coradoc(node, state = {})
|
|
@@ -15,7 +15,7 @@ module Stepmod
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
Ol::LIST_TAGS.each do |tag|
|
|
18
|
-
Coradoc::Input::
|
|
18
|
+
Coradoc::Input::Html::Converters.register tag.to_sym, Ol.new
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -66,8 +66,8 @@ module Stepmod
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
Coradoc::Input::
|
|
70
|
-
Coradoc::Input::
|
|
69
|
+
Coradoc::Input::Html::Converters.register :strong, Strong.new
|
|
70
|
+
Coradoc::Input::Html::Converters.register :b, Strong.new
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
end
|