stepmod-utils 0.3.7 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/stepmod-extract-terms +69 -11
- data/lib/stepmod/utils/concept.rb +27 -4
- data/lib/stepmod/utils/converters/a.rb +0 -4
- data/lib/stepmod/utils/converters/express_ref.rb +1 -1
- data/lib/stepmod/utils/converters/module_ref.rb +1 -1
- data/lib/stepmod/utils/converters/ol.rb +6 -4
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +15 -2
- data/lib/stepmod/utils/converters/strong.rb +4 -2
- data/lib/stepmod/utils/converters/term.rb +11 -2
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +2 -3
- metadata +12 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5d62b153f828f24d5e128e84ffcf18acdeaff96a8fb472e8d78432dce0eb7b0
|
4
|
+
data.tar.gz: 3eff53e916039c898332294e2f6ae6b61195ff0eca6d6e26b8551f7c753b35a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47ca986f76df9da95c7acd5b6716311b7575f570a47ded6d27099f28ccf1ada59e9065825909df8a9e07932fba4e76c81a7746cbc93970fc4c451b90816d1f5e
|
7
|
+
data.tar.gz: 96e624ef8e1223e4a09a6969e04aff34ef2ac75575f532f27da090a89b13ee5366b1b2d22bd2c319ba430aa5ac7f9a13c2513db391b005df55eb1b13b4bf3032
|
data/exe/stepmod-extract-terms
CHANGED
@@ -33,7 +33,7 @@ part_modules = Stepmod::Utils::TermsExtractor.call(stepmod_dir)
|
|
33
33
|
def part_to_title(bibdata)
|
34
34
|
case bibdata.part.to_i
|
35
35
|
when 41
|
36
|
-
"
|
36
|
+
"Fundamentals of product description and support"
|
37
37
|
when 42
|
38
38
|
"Geometric and topological representation"
|
39
39
|
when 43
|
@@ -41,7 +41,7 @@ def part_to_title(bibdata)
|
|
41
41
|
when 44
|
42
42
|
"Product structure, concept and configuration"
|
43
43
|
when 45
|
44
|
-
"
|
44
|
+
"Material and other engineering properties"
|
45
45
|
when 46
|
46
46
|
"Visual presentation"
|
47
47
|
when 47
|
@@ -53,6 +53,22 @@ def part_to_title(bibdata)
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
IMAGE_REPLACEMENTS = {
|
57
|
+
'image::eq01.gif[]' => 'stem:[H(A,B) = max {h(A, B), h(B,A)}]',
|
58
|
+
'image::eq02.gif[]' => 'stem:[max_{a in A} { min_{b in B} d(a,b) }]',
|
59
|
+
'image::vector_z_c.gif[]' => 'stem:[bar z_{c}]',
|
60
|
+
'image::one_direction_repeat_factor_expression.gif[]' => 'stem:[I + k cdot R; k = -1, 1]',
|
61
|
+
'image::two_direction_repeat_factor_expression.gif[]' => 'stem:[I + k_1 cdot R_1 + k_2 cdot R_2; k_1, k_2 = -1, 0, 1, k^2_1 + k^2_2 != 0]'
|
62
|
+
}
|
63
|
+
|
64
|
+
def replace_images(content)
|
65
|
+
IMAGE_REPLACEMENTS.each_pair do |k, v|
|
66
|
+
content.gsub!(k, v)
|
67
|
+
end
|
68
|
+
|
69
|
+
content
|
70
|
+
end
|
71
|
+
|
56
72
|
def log(message)
|
57
73
|
puts "[stepmod-utils] #{message}"
|
58
74
|
end
|
@@ -64,11 +80,22 @@ part_concepts.each do |(bibdata, current_part_concepts)|
|
|
64
80
|
fn = "03x-stepmod-#{bibdata.part}.adoc"
|
65
81
|
File.open(fn, "w") do |file|
|
66
82
|
file.puts("== #{part_to_title(bibdata)}\n\n")
|
67
|
-
file.puts(current_part_concepts.map(&:to_mn_adoc).join("\n"))
|
83
|
+
file.puts(replace_images(current_part_concepts.map(&:to_mn_adoc).join("\n")))
|
68
84
|
end
|
69
85
|
log "INFO: written to: #{fn}"
|
70
86
|
end
|
71
87
|
|
88
|
+
File.open("03x-stepmod.adoc", "w") do |file|
|
89
|
+
part_concepts.sort_by do |(bibdata, current_part_concepts)|
|
90
|
+
bibdata.part.to_i
|
91
|
+
end.each do |(bibdata, current_part_concepts)|
|
92
|
+
fn = "03x-stepmod-#{bibdata.part}.adoc"
|
93
|
+
file.puts("\ninclude::#{fn}[]\n")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
log "INFO: written summary file to: 03x-stepmod.adoc"
|
98
|
+
|
72
99
|
part_resources.each do |(bibdata, current_part_resources)|
|
73
100
|
current_part_resources = current_part_resources.to_a.map do |n|
|
74
101
|
n.localizations["en"]
|
@@ -76,11 +103,22 @@ part_resources.each do |(bibdata, current_part_resources)|
|
|
76
103
|
fn = "04x-stepmod-entities-resources-#{bibdata.part}.adoc"
|
77
104
|
File.open(fn, "w") do |file|
|
78
105
|
file.puts("== #{part_to_title(bibdata)}\n\n")
|
79
|
-
file.puts(current_part_resources.map(&:to_mn_adoc).join("\n"))
|
106
|
+
file.puts(replace_images(current_part_resources.map(&:to_mn_adoc).join("\n")))
|
80
107
|
end
|
81
108
|
log "INFO: written to: #{fn}"
|
82
109
|
end
|
83
110
|
|
111
|
+
File.open("04x-stepmod-entities-resources.adoc", "w") do |file|
|
112
|
+
part_resources.sort_by do |(bibdata, current_part_resources)|
|
113
|
+
bibdata.part.to_i
|
114
|
+
end.each do |(bibdata, current_part_resources)|
|
115
|
+
fn = "04x-stepmod-entities-resources-#{bibdata.part}.adoc"
|
116
|
+
file.puts("\ninclude::#{fn}[]\n")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
log "INFO: written summary file to: 04x-stepmod-entities-resources.adoc"
|
121
|
+
|
84
122
|
part_modules.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
85
123
|
fn = "05x-stepmod-entities-modules-#{bibdata.part}.adoc"
|
86
124
|
File.open(fn, "w") do |file|
|
@@ -106,23 +144,43 @@ part_modules.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
|
106
144
|
n.localizations["en"]
|
107
145
|
end
|
108
146
|
file.puts("== #{schema_name}\n\n")
|
109
|
-
file.puts(concepts.map(&:to_mn_adoc).join("\n"))
|
147
|
+
file.puts(replace_images(concepts.map(&:to_mn_adoc).join("\n")))
|
110
148
|
end
|
111
149
|
end
|
112
150
|
log "INFO: written to: #{fn}"
|
113
151
|
end
|
114
152
|
|
153
|
+
File.open("05x-stepmod-entities-modules.adoc", "w") do |file|
|
154
|
+
part_modules.sort_by do |(bibdata, part_modules_arm, part_modules_mim)|
|
155
|
+
bibdata.part.to_i
|
156
|
+
end.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
157
|
+
fn = "05x-stepmod-entities-modules-#{bibdata.part}.adoc"
|
158
|
+
file.puts("\ninclude::#{fn}[]\n")
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
log "INFO: written summary file to: 05x-stepmod-entities-modules.adoc"
|
163
|
+
|
115
164
|
File.open("031-stepmod-general.adoc", "w") do |file|
|
116
|
-
file.puts(
|
117
|
-
|
118
|
-
|
165
|
+
file.puts(
|
166
|
+
replace_images(
|
167
|
+
general_concepts.to_a.map do |n|
|
168
|
+
n.localizations["en"]
|
169
|
+
end.map(&:to_mn_adoc).join("\n")
|
170
|
+
)
|
171
|
+
)
|
119
172
|
end
|
173
|
+
|
120
174
|
log "INFO: written to: 031-stepmod-general.adoc"
|
121
175
|
|
122
176
|
File.open("041-stepmod-entities-resources.adoc", "w") do |file|
|
123
|
-
file.puts(
|
124
|
-
|
125
|
-
|
177
|
+
file.puts(
|
178
|
+
replace_images(
|
179
|
+
resource_concepts.to_a.map do |n|
|
180
|
+
n.localizations["en"]
|
181
|
+
end.map(&:to_mn_adoc).join("\n")
|
182
|
+
)
|
183
|
+
)
|
126
184
|
end
|
127
185
|
log "INFO: written to: 041-stepmod-entities-resources.adoc"
|
128
186
|
|
@@ -31,7 +31,10 @@ module Stepmod
|
|
31
31
|
Reference <<#{reference_anchor}>> for the complete definition.
|
32
32
|
TEXT
|
33
33
|
end
|
34
|
+
|
34
35
|
# https://github.com/metanorma/stepmod-utils/issues/86
|
36
|
+
|
37
|
+
# TODO: This portion DOES NOT HANDLE the <synonym> element. WTF??
|
35
38
|
if definition_xml.name == "definition"
|
36
39
|
designation = definition_designation(definition_xml)
|
37
40
|
definition = definition_xml_definition(definition_xml,
|
@@ -40,6 +43,7 @@ module Stepmod
|
|
40
43
|
designation, definition
|
41
44
|
).strip
|
42
45
|
end
|
46
|
+
|
43
47
|
new(
|
44
48
|
designations: [designation],
|
45
49
|
definition: definition,
|
@@ -53,20 +57,36 @@ module Stepmod
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def definition_designation(definition_xml)
|
56
|
-
|
60
|
+
# We take the <p> that is an alternative term (length<=20).
|
61
|
+
# Add in the <synonym> elements.
|
62
|
+
alts = definition_xml.xpath(".//synonym").map(&:text) +
|
63
|
+
definition_xml.xpath(".//def/p").map(&:text).reject do |text|
|
64
|
+
text.length > 20
|
65
|
+
end
|
66
|
+
|
67
|
+
term = Stepmod::Utils::Converters::Term
|
68
|
+
.new
|
69
|
+
.convert(
|
70
|
+
definition_xml.xpath(".//term").first
|
71
|
+
)
|
72
|
+
|
57
73
|
{
|
58
|
-
|
74
|
+
# [4..-1] because we want to skip the initial `=== {title}`
|
75
|
+
accepted: term[4..-1],
|
59
76
|
alt: alts,
|
60
77
|
}
|
61
78
|
end
|
62
79
|
|
63
80
|
def definition_xml_definition(definition_xml, reference_anchor)
|
81
|
+
# We reject the <p> that was considered an alternative term (length<=20)
|
64
82
|
text_nodes = definition_xml
|
65
83
|
.xpath(".//def")
|
66
84
|
.first
|
67
85
|
.children
|
68
|
-
.reject { |n| n.name == "p" }
|
86
|
+
.reject { |n| n.name == "p" && n.text.length <= 20 }
|
87
|
+
|
69
88
|
wrapper = "<def>#{text_nodes.map(&:to_s).join}</def>"
|
89
|
+
|
70
90
|
Stepmod::Utils::Converters::Def
|
71
91
|
.new
|
72
92
|
.convert(
|
@@ -83,15 +103,18 @@ module Stepmod
|
|
83
103
|
if designation[:alt].length.positive?
|
84
104
|
alt_notation = "alt:[#{designation[:alt].map(&:strip).join(',')}]"
|
85
105
|
end
|
106
|
+
|
86
107
|
result = <<~TEXT
|
87
|
-
=== #{designation[:accepted]}
|
108
|
+
=== #{designation[:accepted].strip}
|
88
109
|
TEXT
|
110
|
+
|
89
111
|
if alt_notation
|
90
112
|
result += <<~TEXT
|
91
113
|
|
92
114
|
#{alt_notation}
|
93
115
|
TEXT
|
94
116
|
end
|
117
|
+
|
95
118
|
<<~TEXT
|
96
119
|
#{result}
|
97
120
|
#{definition}
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "uri"
|
4
|
-
|
5
3
|
module Stepmod
|
6
4
|
module Utils
|
7
5
|
module Converters
|
@@ -31,9 +29,7 @@ module Stepmod
|
|
31
29
|
name = title if name.empty?
|
32
30
|
href = "link:#{href}" unless href.to_s&.match?(URI::DEFAULT_PARSER.make_regexp)
|
33
31
|
link = "#{href}[#{name}]"
|
34
|
-
# link.prepend(' ')
|
35
32
|
" #{link}"
|
36
|
-
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -5,7 +5,7 @@ module Stepmod
|
|
5
5
|
module Converters
|
6
6
|
class ExpressRef < ReverseAdoc::Converters::Base
|
7
7
|
def convert(node, _state = {})
|
8
|
-
" *#{node['linkend'].to_s.split('.').last}*"
|
8
|
+
" *#{node['linkend'].to_s.split('.').last}* "
|
9
9
|
end
|
10
10
|
end
|
11
11
|
ReverseAdoc::Converters.register :express_ref, ExpressRef.new
|
@@ -9,10 +9,12 @@ module Stepmod
|
|
9
9
|
anchor = id ? "[[#{id}]]\n" : ""
|
10
10
|
ol_count = state.fetch(:ol_count, 0) + 1
|
11
11
|
attrs = ol_attrs(node)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
children_s = treat_children(node, state.merge(
|
13
|
+
ol_count: ol_count,
|
14
|
+
tdsinglepara: true,
|
15
|
+
))
|
16
|
+
|
17
|
+
"\n\n#{anchor}#{attrs}#{children_s}\n"
|
16
18
|
# Why do we add this?
|
17
19
|
# res = "\n" + res if node.parent && node.parent.name == 'note'
|
18
20
|
end
|
@@ -13,8 +13,21 @@ module Stepmod
|
|
13
13
|
child_text = treat_children(node, state).strip
|
14
14
|
return nil if child_text.empty?
|
15
15
|
|
16
|
-
#
|
17
|
-
|
16
|
+
# Unless the first paragraph ends with "between" and is followed by a
|
17
|
+
# list, don't split
|
18
|
+
first_child = child_text.split("\n").first
|
19
|
+
|
20
|
+
unless (
|
21
|
+
first_child =~ /between:?\s*\Z/ ||
|
22
|
+
first_child =~ /include:?\s*\Z/ ||
|
23
|
+
first_child =~ /of:?\s*\Z/ ||
|
24
|
+
first_child =~ /[:;]\s*\Z/
|
25
|
+
) &&
|
26
|
+
child_text =~ /\n\n\*/
|
27
|
+
|
28
|
+
# Only taking the first paragraph of the definition
|
29
|
+
child_text = first_child
|
30
|
+
end
|
18
31
|
|
19
32
|
# # Only taking the first sentence
|
20
33
|
# if child_text.contains?(".")
|
@@ -11,8 +11,10 @@ module Stepmod
|
|
11
11
|
if content.strip.empty? || state[:already_strong]
|
12
12
|
content
|
13
13
|
else
|
14
|
-
handle_express_escape_seq(
|
15
|
-
|
14
|
+
handle_express_escape_seq(
|
15
|
+
node,
|
16
|
+
"#{content[/^\s*/]}*#{content.strip}*#{content[/\s*$/]}"
|
17
|
+
)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -6,10 +6,19 @@ module Stepmod
|
|
6
6
|
module Utils
|
7
7
|
module Converters
|
8
8
|
class Term < ReverseAdoc::Converters::Base
|
9
|
+
|
10
|
+
# We strip all the children in the case for "stem:[d]-manifold"
|
11
|
+
# vs "stem:[d] -manifold"
|
12
|
+
def treat_children(node, state)
|
13
|
+
res = node.children.map { |child| treat(child, state) }
|
14
|
+
res.map(&:strip).reject(&:empty?).join("")
|
15
|
+
end
|
16
|
+
|
9
17
|
def convert(node, state = {})
|
10
18
|
first_child = node.children.find do |child|
|
11
19
|
child.name == "text" && !child.text.to_s.strip.empty?
|
12
20
|
end
|
21
|
+
|
13
22
|
unless first_child &&
|
14
23
|
node.text.split(";").length == 2 &&
|
15
24
|
defined?(Stepmod::Utils::Converters::Synonym)
|
@@ -25,10 +34,10 @@ module Stepmod
|
|
25
34
|
private
|
26
35
|
|
27
36
|
def treat_acronym(term_def)
|
28
|
-
return term_def if term_def !~ /.+\(.+?\)$/
|
37
|
+
return term_def.strip if term_def !~ /.+\(.+?\)$/
|
29
38
|
|
30
39
|
_, term_text, term_acronym = term_def.match(/(.+?)(\(.+\))$/).to_a
|
31
|
-
"#{term_text}\nalt:[#{term_acronym.gsub(/\(|\)/, '')}]"
|
40
|
+
"#{term_text.strip}\nalt:[#{term_acronym.gsub(/\(|\)/, '')}]"
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
data/stepmod-utils.gemspec
CHANGED
@@ -34,10 +34,9 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_runtime_dependency "concurrent-ruby"
|
35
35
|
spec.add_runtime_dependency "glossarist", "~> 0.1.0"
|
36
36
|
spec.add_runtime_dependency "ptools"
|
37
|
-
spec.add_runtime_dependency "reverse_adoc", ">= 0.
|
37
|
+
spec.add_runtime_dependency "reverse_adoc", ">= 0.3.5"
|
38
38
|
spec.add_runtime_dependency "thor", ">= 0.20.3"
|
39
|
-
spec.add_development_dependency "
|
40
|
-
spec.add_development_dependency "rubocop", "1.12"
|
39
|
+
spec.add_development_dependency "rubocop"
|
41
40
|
spec.add_development_dependency "rubocop-performance"
|
42
41
|
spec.add_development_dependency "rubocop-rails"
|
43
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stepmod-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.3.5
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.3.5
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,34 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.20.3
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: byebug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '11.1'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '11.1'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: rubocop
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- -
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: rubocop-performance
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,7 +222,7 @@ homepage: https://github.com/metanorma/stepmod-utils
|
|
236
222
|
licenses:
|
237
223
|
- BSD-2-Clause
|
238
224
|
metadata: {}
|
239
|
-
post_install_message:
|
225
|
+
post_install_message:
|
240
226
|
rdoc_options: []
|
241
227
|
require_paths:
|
242
228
|
- lib
|
@@ -251,8 +237,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
237
|
- !ruby/object:Gem::Version
|
252
238
|
version: '0'
|
253
239
|
requirements: []
|
254
|
-
rubygems_version: 3.0.3
|
255
|
-
signing_key:
|
240
|
+
rubygems_version: 3.0.3.1
|
241
|
+
signing_key:
|
256
242
|
specification_version: 4
|
257
243
|
summary: Stepmod-utils is a toolkit that works on STEPmod data.
|
258
244
|
test_files: []
|