stepmod-utils 0.3.22 → 0.3.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/exe/stepmod-annotate-all +1 -1
- data/exe/stepmod-extract-terms +14 -6
- data/exe/stepmod-extract-yaml-terms +149 -0
- data/lib/stepmod/utils/concept.rb +42 -12
- data/lib/stepmod/utils/converters/express_figure.rb +25 -0
- data/lib/stepmod/utils/converters/express_table.rb +25 -0
- data/lib/stepmod/utils/converters/figure.rb +19 -1
- data/lib/stepmod/utils/converters/module_ref.rb +55 -17
- data/lib/stepmod/utils/converters/module_ref_express_description.rb +44 -2
- data/lib/stepmod/utils/converters/table.rb +14 -1
- data/lib/stepmod/utils/express_bibdata.rb +111 -0
- data/lib/stepmod/utils/smrl_description_converter.rb +1 -0
- data/lib/stepmod/utils/smrl_resource_converter.rb +2 -1
- data/lib/stepmod/utils/stepmod_definition_converter.rb +1 -0
- data/lib/stepmod/utils/stepmod_file_annotator.rb +236 -12
- data/lib/stepmod/utils/term.rb +18 -5
- data/lib/stepmod/utils/terms_extractor.rb +253 -298
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +2 -1
- metadata +25 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d04b3c30620d813fbff40cfa84ed809f0129440dd1f6be45c4206aaa44a12e
|
4
|
+
data.tar.gz: 54289d1067ccba3a61cd0ca07bd5455081efe70aae946811cf8028f6e77afb9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e83145314175c1797f8de0fe08bdbf3ba95e06346b49f80beb3cdadb31d1b2423cb60230d869b91850de3685b0fb6c805a2b4ddebbfd72ff2b55ffde234f4d9f
|
7
|
+
data.tar.gz: 309a341bead6e54225f14101c3bea989f2f7873409c4d8e1fedbc6e8b2144d3e21ed2034c5ebcfd76279d73234a84e8d0d67c86fb77e1e1b715f6f1ba2ad661b
|
data/.rubocop.yml
CHANGED
data/exe/stepmod-annotate-all
CHANGED
@@ -13,7 +13,7 @@ resource_docs_cache_file = `mktemp`
|
|
13
13
|
# annotate each file
|
14
14
|
files = `"#{File.join(__dir__,
|
15
15
|
"stepmod-find-express-files")}" "#{stepmod_dir}"`.strip.split("\n")
|
16
|
-
MAX_THREADS = [2, Concurrent.processor_count].max * 2
|
16
|
+
MAX_THREADS = 1 #[2, Concurrent.processor_count].max * 2
|
17
17
|
MAX_QUEUE_SIZE = MAX_THREADS * 4
|
18
18
|
# https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/thread_pools.md
|
19
19
|
pool = Concurrent::ThreadPoolExecutor.new(
|
data/exe/stepmod-extract-terms
CHANGED
@@ -94,14 +94,22 @@ IMAGE_REPLACEMENTS = {
|
|
94
94
|
'image::eq01.gif[]' => 'stem:[H(A,B) = max {h(A, B), h(B,A)}]',
|
95
95
|
'image::eq02.gif[]' => 'stem:[max_{a in A} { min_{b in B} d(a,b) }]',
|
96
96
|
'image::vector_z_c.gif[]' => 'stem:[bar z_{c}]',
|
97
|
-
'image::one_direction_repeat_factor_expression.gif[]' => 'stem:[I + k cdot R;
|
98
|
-
'image::two_direction_repeat_factor_expression.gif[]' => 'stem:[I + k_1 cdot R_1 + k_2 cdot R_2;
|
97
|
+
'image::one_direction_repeat_factor_expression.gif[]' => 'stem:[I + k cdot R; k = -1, 1]',
|
98
|
+
'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]',
|
99
99
|
}
|
100
100
|
|
101
|
-
|
101
|
+
TEXT_REPLACEMENTS = {
|
102
|
+
' (see <module_ref linkend="ply_orientation_specification:4_entities:figure:f2"> Figure 2</module_ref>)' => '',
|
103
|
+
' (see <module_ref linkend="ply_orientation_specification:4_entities:figure:f3"> Figure 3</module_ref>)' => ''
|
104
|
+
}
|
105
|
+
|
106
|
+
def replace_content(content)
|
102
107
|
IMAGE_REPLACEMENTS.each_pair do |k, v|
|
103
108
|
content.gsub!(k, v)
|
104
109
|
end
|
110
|
+
TEXT_REPLACEMENTS.each_pair do |k, v|
|
111
|
+
content.gsub!(k, v)
|
112
|
+
end
|
105
113
|
|
106
114
|
content
|
107
115
|
end
|
@@ -137,7 +145,7 @@ part_resources.each do |(bibdata, current_part_resources)|
|
|
137
145
|
fn = "04x-stepmod-entities-resources-#{bibdata.part}.adoc"
|
138
146
|
File.open(fn, "w") do |file|
|
139
147
|
# file.puts("== #{part_to_title(bibdata)}\n\n")
|
140
|
-
file.puts(
|
148
|
+
file.puts(replace_content(current_part_resources.map(&:to_mn_adoc).join("\n")))
|
141
149
|
end
|
142
150
|
log "INFO: written to: #{fn}"
|
143
151
|
end
|
@@ -181,7 +189,7 @@ end.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
|
181
189
|
n.localizations["en"]
|
182
190
|
end
|
183
191
|
file.puts("== #{schema_name}\n\n")
|
184
|
-
file.puts(
|
192
|
+
file.puts(replace_content(concepts.map(&:to_mn_adoc).join("\n")))
|
185
193
|
end
|
186
194
|
end
|
187
195
|
|
@@ -214,7 +222,7 @@ log "INFO: written summary file to: 05x-stepmod-entities-modules.adoc"
|
|
214
222
|
|
215
223
|
File.open("041-stepmod-entities-resources.adoc", "w") do |file|
|
216
224
|
file.puts(
|
217
|
-
|
225
|
+
replace_content(
|
218
226
|
resource_concepts.to_a.map do |n|
|
219
227
|
n.localizations["en"]
|
220
228
|
end.map(&:to_mn_adoc).join("\n")
|
@@ -0,0 +1,149 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require "pry"
|
5
|
+
# resolve bin path, ignoring symlinks
|
6
|
+
require "pathname"
|
7
|
+
bin_file = Pathname.new(__FILE__).realpath
|
8
|
+
|
9
|
+
# add self to libpath
|
10
|
+
$:.unshift File.expand_path("../../lib", bin_file)
|
11
|
+
|
12
|
+
# Fixes https://github.com/rubygems/rubygems/issues/1420
|
13
|
+
require "rubygems/specification"
|
14
|
+
|
15
|
+
module Gem
|
16
|
+
class Specification
|
17
|
+
def this; self; end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require "bundler/setup"
|
22
|
+
require_relative "../lib/stepmod/utils/terms_extractor"
|
23
|
+
require "optparse"
|
24
|
+
|
25
|
+
def log(message)
|
26
|
+
puts "[stepmod-utils] #{message}"
|
27
|
+
end
|
28
|
+
|
29
|
+
options = {}
|
30
|
+
OptionParser.new do |opts|
|
31
|
+
opts.banner = "Usage: #{$0} [options]"
|
32
|
+
|
33
|
+
opts.on(
|
34
|
+
"-p",
|
35
|
+
"--path STEPMOD_DATA_PATH",
|
36
|
+
String,
|
37
|
+
"Path to STEPmod data directory",
|
38
|
+
) do |path|
|
39
|
+
options[:stepmod_dir] = path
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on(
|
43
|
+
"-i",
|
44
|
+
"--index INDEX_PATH",
|
45
|
+
String,
|
46
|
+
"Path to repository_index.xml",
|
47
|
+
) do |path|
|
48
|
+
unless path.nil?
|
49
|
+
options[:index_path] = Pathname.new(path).to_s
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
54
|
+
puts opts
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
end.parse!
|
58
|
+
|
59
|
+
stepmod_dir = options[:stepmod_dir]
|
60
|
+
if stepmod_dir.nil?
|
61
|
+
raise StandardError.new(
|
62
|
+
"STEPmod data path not set, set with the `-p` option.",
|
63
|
+
)
|
64
|
+
else
|
65
|
+
log "STEPmod data path: `#{stepmod_dir}`"
|
66
|
+
end
|
67
|
+
|
68
|
+
default_index_path = File.join(stepmod_dir, "repository_index.xml")
|
69
|
+
index_path = options[:index_path] || default_index_path
|
70
|
+
if File.exists?(index_path)
|
71
|
+
log "Repository index path: `#{index_path}`"
|
72
|
+
else
|
73
|
+
raise StandardError.new(
|
74
|
+
"Index file not present at #{index_path}, set with the `-i` option.",
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
_general_concepts,
|
79
|
+
resource_concepts,
|
80
|
+
_parsed_bibliography,
|
81
|
+
_part_concepts,
|
82
|
+
part_resources,
|
83
|
+
part_modules = Stepmod::Utils::TermsExtractor.call(stepmod_dir, index_path)
|
84
|
+
|
85
|
+
def part_to_title(bibdata)
|
86
|
+
{
|
87
|
+
41 => "Fundamentals of product description and support",
|
88
|
+
42 => "Geometric and topological representation",
|
89
|
+
43 => "Foundation representation",
|
90
|
+
44 => "Product structure, concept and configuration",
|
91
|
+
45 => "Material and other engineering properties",
|
92
|
+
46 => "Visual presentation",
|
93
|
+
47 => "Shape tolerance",
|
94
|
+
51 => "Mathematical representation",
|
95
|
+
}[bibdata.part.to_i] || bibdata.title_en
|
96
|
+
end
|
97
|
+
|
98
|
+
# rubocop:disable Layout/LineLength
|
99
|
+
IMAGE_REPLACEMENTS = {
|
100
|
+
"image::eq01.gif[]" => "stem:[H(A,B) = max {h(A, B), h(B,A)}]",
|
101
|
+
"image::eq02.gif[]" => "stem:[max_{a in A} { min_{b in B} d(a,b) }]",
|
102
|
+
"image::vector_z_c.gif[]" => "stem:[bar z_{c}]",
|
103
|
+
"image::one_direction_repeat_factor_expression.gif[]" => "stem:[I + k cdot R; k = -1, 1]",
|
104
|
+
"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]",
|
105
|
+
}.freeze
|
106
|
+
|
107
|
+
TEXT_REPLACEMENTS = {
|
108
|
+
' (see <module_ref linkend="ply_orientation_specification:4_entities:figure:f2"> Figure 2</module_ref>)' => "",
|
109
|
+
' (see <module_ref linkend="ply_orientation_specification:4_entities:figure:f3"> Figure 3</module_ref>)' => "",
|
110
|
+
}.freeze
|
111
|
+
# rubocop:enable Layout/LineLength
|
112
|
+
|
113
|
+
def replace_content(content)
|
114
|
+
IMAGE_REPLACEMENTS.each_pair do |k, v|
|
115
|
+
content.gsub!(k, v)
|
116
|
+
end
|
117
|
+
TEXT_REPLACEMENTS.each_pair do |k, v|
|
118
|
+
content.gsub!(k, v)
|
119
|
+
end
|
120
|
+
|
121
|
+
content
|
122
|
+
end
|
123
|
+
|
124
|
+
part_resources.each do |(_bibdata, current_part_resources)|
|
125
|
+
current_part_resources.save_to_files("./")
|
126
|
+
end
|
127
|
+
log "INFO: part_resources written to yaml files"
|
128
|
+
|
129
|
+
|
130
|
+
log "INFO: written summary file to: 04x-stepmod-entities-resources.adoc"
|
131
|
+
part_modules.sort_by do |(bibdata, _part_modules_arm, _part_modules_mim)|
|
132
|
+
bibdata.part.to_i
|
133
|
+
end.each do |(_bibdata, part_modules_arm, part_modules_mim)|
|
134
|
+
unless part_modules_arm.empty?
|
135
|
+
part_modules_arm.values.map do |managed_concept|
|
136
|
+
managed_concept.save_to_files("./")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
unless part_modules_mim.empty?
|
141
|
+
part_modules_mim.values.map do |managed_concept|
|
142
|
+
managed_concept.save_to_files("./")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
log "INFO: part_modules written to yaml files"
|
147
|
+
|
148
|
+
resource_concepts.save_to_files("./")
|
149
|
+
log "INFO: resource_concepts written to yaml files"
|
@@ -8,6 +8,10 @@ module Stepmod
|
|
8
8
|
reference_anchor
|
9
9
|
converted_definition
|
10
10
|
file_path
|
11
|
+
schema
|
12
|
+
part
|
13
|
+
domain
|
14
|
+
document
|
11
15
|
)
|
12
16
|
|
13
17
|
# TODO: converted_definition is not supposed to be an attribute, it is
|
@@ -17,7 +21,7 @@ module Stepmod
|
|
17
21
|
converted_definition = Stepmod::Utils::StepmodDefinitionConverter.convert(
|
18
22
|
definition_xml,
|
19
23
|
{
|
20
|
-
# We don't want examples and
|
24
|
+
# We don't want examples, notes, figures and tables
|
21
25
|
no_notes_examples: true,
|
22
26
|
reference_anchor: reference_anchor,
|
23
27
|
},
|
@@ -40,8 +44,8 @@ module Stepmod
|
|
40
44
|
# TODO: `designations:` should include the `alt:[...]` terms here,
|
41
45
|
# they are now only included in definition_xml_converted_definition.
|
42
46
|
new(
|
43
|
-
designations:
|
44
|
-
definition: definition,
|
47
|
+
designations: designation,
|
48
|
+
definition: [definition],
|
45
49
|
converted_definition: converted_definition,
|
46
50
|
id: "#{reference_anchor}.#{reference_clause}",
|
47
51
|
reference_anchor: reference_anchor,
|
@@ -65,11 +69,16 @@ module Stepmod
|
|
65
69
|
definition_xml.xpath(".//term").first
|
66
70
|
)
|
67
71
|
|
68
|
-
{
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
# [4..-1] because we want to skip the initial `=== {title}`
|
73
|
+
designations = [
|
74
|
+
{ "designation" => term[4..-1], "type" => "expression", "normative_status" => "preferred" },
|
75
|
+
]
|
76
|
+
|
77
|
+
alts.each do |alt|
|
78
|
+
designations << { "designation" => alt, "type" => "expression" }
|
79
|
+
end
|
80
|
+
|
81
|
+
designations
|
73
82
|
end
|
74
83
|
|
75
84
|
def definition_xml_definition(definition_xml, reference_anchor)
|
@@ -87,7 +96,7 @@ module Stepmod
|
|
87
96
|
.convert(
|
88
97
|
Nokogiri::XML(wrapper).root,
|
89
98
|
{
|
90
|
-
# We don't want examples and
|
99
|
+
# We don't want examples, notes, figures and tables
|
91
100
|
no_notes_examples: true,
|
92
101
|
reference_anchor: reference_anchor,
|
93
102
|
},
|
@@ -95,12 +104,24 @@ module Stepmod
|
|
95
104
|
end
|
96
105
|
|
97
106
|
def definition_xml_converted_definition(designation, definition)
|
98
|
-
|
99
|
-
|
107
|
+
accepted_designation = designation.select do |des|
|
108
|
+
des["normative_status"] == "preferred"
|
109
|
+
end
|
110
|
+
|
111
|
+
alt_designations = designation.reject do |des|
|
112
|
+
des["normative_status"] == "preferred"
|
113
|
+
end
|
114
|
+
|
115
|
+
if alt_designations.length.positive?
|
116
|
+
alt_designations_text = alt_designations.map do |d|
|
117
|
+
d["designation"].strip
|
118
|
+
end.join(",")
|
119
|
+
|
120
|
+
alt_notation = "alt:[#{alt_designations_text}]"
|
100
121
|
end
|
101
122
|
|
102
123
|
result = <<~TEXT
|
103
|
-
=== #{designation
|
124
|
+
=== #{accepted_designation.map { |d| d['designation'].strip }.join(',')}
|
104
125
|
TEXT
|
105
126
|
|
106
127
|
if alt_notation
|
@@ -117,6 +138,15 @@ module Stepmod
|
|
117
138
|
end
|
118
139
|
end
|
119
140
|
|
141
|
+
def to_h
|
142
|
+
super.merge({
|
143
|
+
"domain" => domain,
|
144
|
+
"part" => part,
|
145
|
+
"schema" => schema,
|
146
|
+
"document" => document,
|
147
|
+
}.compact)
|
148
|
+
end
|
149
|
+
|
120
150
|
def to_mn_adoc
|
121
151
|
<<~TEXT
|
122
152
|
// STEPmod path:#{file_path.empty? ? '' : " #{file_path}"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "./figure"
|
3
|
+
|
4
|
+
module Stepmod
|
5
|
+
module Utils
|
6
|
+
module Converters
|
7
|
+
class ExpressFigure < Stepmod::Utils::Converters::Figure
|
8
|
+
|
9
|
+
# def self.pattern(state, id)
|
10
|
+
# "figure-exp-#{id}"
|
11
|
+
# end
|
12
|
+
|
13
|
+
def convert(node, state = {})
|
14
|
+
<<~TEMPLATE
|
15
|
+
(*"#{state[:schema_and_entity]}.__figure"
|
16
|
+
#{super(node, state.merge(no_notes_examples: nil)).strip}
|
17
|
+
*)
|
18
|
+
TEMPLATE
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
ReverseAdoc::Converters.register :express_figure, ExpressFigure.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "./table"
|
3
|
+
|
4
|
+
module Stepmod
|
5
|
+
module Utils
|
6
|
+
module Converters
|
7
|
+
class ExpressTable < Stepmod::Utils::Converters::Table
|
8
|
+
|
9
|
+
# def self.pattern(id)
|
10
|
+
# "table-exp-#{id}"
|
11
|
+
# end
|
12
|
+
|
13
|
+
def convert(node, state = {})
|
14
|
+
<<~TEMPLATE
|
15
|
+
(*"#{state[:schema_and_entity]}.__table"
|
16
|
+
#{super(node, state.merge(no_notes_examples: nil)).strip}
|
17
|
+
*)
|
18
|
+
TEMPLATE
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
ReverseAdoc::Converters.register :express_table, ExpressTable.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -6,13 +6,31 @@ module Stepmod
|
|
6
6
|
module Utils
|
7
7
|
module Converters
|
8
8
|
class Figure < ReverseAdoc::Converters::Figure
|
9
|
+
|
10
|
+
def self.pattern(state, id)
|
11
|
+
if state[:schema_and_entity].nil?
|
12
|
+
raise StandardError.new("[figure]: no state given, #{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
schema = state[:schema_and_entity].split(".").first
|
16
|
+
"figure-#{schema}-#{id}"
|
17
|
+
end
|
18
|
+
|
9
19
|
def convert(node, state = {})
|
10
20
|
# If we want to skip this node
|
11
21
|
return "" if state[:no_notes_examples]
|
12
22
|
|
13
|
-
|
23
|
+
# Set ID to "figure-id" in case of conflicts
|
24
|
+
node['id'] = if node['id']
|
25
|
+
self.class.pattern(state, node['id'])
|
26
|
+
else
|
27
|
+
self.class.pattern(state, node['number'])
|
28
|
+
end
|
29
|
+
|
30
|
+
super(node, state)
|
14
31
|
end
|
15
32
|
end
|
33
|
+
|
16
34
|
# This replaces the converter
|
17
35
|
ReverseAdoc::Converters.register :figure, Figure.new
|
18
36
|
end
|
@@ -5,31 +5,69 @@ module Stepmod
|
|
5
5
|
module Converters
|
6
6
|
class ModuleRef < ReverseAdoc::Converters::Base
|
7
7
|
def convert(node, _state = {})
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
link_end = node["linkend"].to_s.split(":")
|
9
|
+
ref_id = link_end.last
|
10
|
+
parts = link_end.last.split(".")
|
11
|
+
text = node.text.gsub(/\s/, " ").squeeze(" ").strip
|
12
|
+
schema = link_end.first
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
if _state[:schema_and_entity].nil?
|
15
|
+
# puts "[module_ref] setting node state #{link_end.inspect}"
|
16
|
+
_state[:schema_and_entity] = schema
|
17
|
+
end
|
18
|
+
|
19
|
+
result = case link_end[1]
|
20
|
+
when "1_scope", "introduction"
|
21
|
+
# When we see this:
|
22
|
+
# <module_ref linkend="functional_usage_view:1_scope">Functional usage view</module_ref>
|
23
|
+
# <module_ref linkend="part_definition_relationship:introduction"> Part definition relationship</module_ref>
|
24
|
+
# We convert into:
|
25
|
+
# <<express:functional_usage_view>>
|
26
|
+
# <<express:part_definition_relationship>>
|
27
|
+
|
28
|
+
"<<express:#{schema}>>"
|
29
|
+
|
30
|
+
when "3_definition"
|
31
|
+
# #23:
|
32
|
+
# When we see this:
|
33
|
+
# <module_ref linkend="product_as_individual:3_definition">individual products</module_ref>
|
34
|
+
# We convert to this:
|
35
|
+
# {{individual products}}
|
14
36
|
|
15
|
-
|
37
|
+
"{{#{text}}}"
|
16
38
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
"
|
39
|
+
when "4_types"
|
40
|
+
# When we see this:
|
41
|
+
# <module_ref linkend="activity_method_assignment:4_types">activity_method_item</module_ref>
|
42
|
+
# We convert to this:
|
43
|
+
# <<express:activity_method_assignment.activity_method_item>>
|
44
|
+
"<<express:#{[schema, text].join('.')},#{text}>>"
|
45
|
+
when "4_entities", "f_usage_guide"
|
46
|
+
case link_end[2]
|
47
|
+
when "figure"
|
48
|
+
# When we see this:
|
49
|
+
# <module_ref linkend="assembly_module_design:4_entities:figure:pudv">Figure 1</module_ref>
|
50
|
+
# We convert to this:
|
51
|
+
# <<figure-pudv,Figure 1>>
|
52
|
+
"<<#{Figure.pattern(_state,ref_id)},#{text}>>"
|
53
|
+
when "table"
|
54
|
+
# When we see this:
|
55
|
+
# <module_ref linkend="independent_property_definition:4_entities:table:T1">Table 1</module_ref>
|
56
|
+
# We convert to this:
|
57
|
+
# <<table-T1,Table 1>>
|
58
|
+
"<<#{Table.pattern(_state,ref_id)},#{text}>>"
|
59
|
+
end
|
60
|
+
else
|
61
|
+
puts "[module_ref]: encountered unknown <module_ref> tag, #{link_end.join(":")}"
|
62
|
+
raise StandardError.new("[module_ref]: encountered unknown <module_ref> tag, #{link_end.join(":")}")
|
23
63
|
end
|
64
|
+
|
65
|
+
# puts "[module_ref] #{result}"
|
66
|
+
result
|
24
67
|
end
|
25
68
|
|
26
69
|
private
|
27
70
|
|
28
|
-
def normalized_ref(ref)
|
29
|
-
return unless ref || ref.empty?
|
30
|
-
|
31
|
-
ref.squeeze(" ").strip
|
32
|
-
end
|
33
71
|
end
|
34
72
|
ReverseAdoc::Converters.register :module_ref, ModuleRef.new
|
35
73
|
end
|
@@ -1,10 +1,52 @@
|
|
1
|
+
|
2
|
+
require "stepmod/utils/converters/figure"
|
3
|
+
require "stepmod/utils/converters/table"
|
4
|
+
|
1
5
|
module Stepmod
|
2
6
|
module Utils
|
3
7
|
module Converters
|
4
8
|
class ModuleRefExpressDescription < ReverseAdoc::Converters::Base
|
5
9
|
def convert(node, _state = {})
|
6
|
-
|
7
|
-
|
10
|
+
link_end = node["linkend"].to_s.split(":")
|
11
|
+
ref_id = link_end.last
|
12
|
+
parts = link_end.last.split(".")
|
13
|
+
text = node.text.gsub(/\s/, " ").squeeze(" ").strip
|
14
|
+
|
15
|
+
# puts "linkend #{node["linkend"]}"
|
16
|
+
|
17
|
+
result = case link_end[1]
|
18
|
+
when "1_scope", "introduction"
|
19
|
+
# When we see this:
|
20
|
+
# <module_ref linkend="functional_usage_view:1_scope">Functional usage view</module_ref>
|
21
|
+
# <module_ref linkend="part_definition_relationship:introduction"> Part definition relationship</module_ref>
|
22
|
+
# We convert into:
|
23
|
+
# <<express:functional_usage_view>>
|
24
|
+
# <<express:part_definition_relationship>>
|
25
|
+
|
26
|
+
"<<express:#{link_end.first}>>"
|
27
|
+
|
28
|
+
when "3_definition"
|
29
|
+
# #23:
|
30
|
+
# When we see this:
|
31
|
+
# <module_ref linkend="product_as_individual:3_definition">individual products</module_ref>
|
32
|
+
# We convert to this:
|
33
|
+
# {{individual products}}
|
34
|
+
|
35
|
+
"{{#{text}}}"
|
36
|
+
|
37
|
+
when "4_types"
|
38
|
+
# ISO 10303-2 does not contain TYPEs, ignore
|
39
|
+
""
|
40
|
+
when "4_entities", "f_usage_guide"
|
41
|
+
# ISO 10303-2 does not contain figures and tables, ignore
|
42
|
+
""
|
43
|
+
else
|
44
|
+
puts "[module_ref_express_description]: encountered unknown <module_ref> tag, #{link_end.join(":")}"
|
45
|
+
raise StandardError.new("[module_ref_express_description]: encountered unknown <module_ref> tag, #{link_end.join(":")}")
|
46
|
+
end
|
47
|
+
|
48
|
+
# puts "[module_ref] #{result}"
|
49
|
+
result
|
8
50
|
end
|
9
51
|
end
|
10
52
|
ReverseAdoc::Converters.register :module_ref,
|
@@ -4,9 +4,22 @@ module Stepmod
|
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
6
|
class Table < ReverseAdoc::Converters::Base
|
7
|
+
|
8
|
+
def self.pattern(state, id)
|
9
|
+
if state[:schema_and_entity].nil?
|
10
|
+
raise StandardError.new("[table]: no state given, #{id}")
|
11
|
+
end
|
12
|
+
|
13
|
+
schema = state[:schema_and_entity].split(".").first
|
14
|
+
"table-#{schema}-#{id}"
|
15
|
+
end
|
16
|
+
|
7
17
|
def convert(node, state = {})
|
18
|
+
# If we want to skip this node
|
19
|
+
return "" if state[:no_notes_examples]
|
20
|
+
|
8
21
|
id = node["id"]
|
9
|
-
anchor = id ? "[[
|
22
|
+
anchor = id ? "[[table-#{self.class.pattern(state, id)}]]\n" : ""
|
10
23
|
title = node["caption"].to_s
|
11
24
|
title = ".#{title}\n" unless title.empty?
|
12
25
|
attrs = style(node)
|