metanorma-plugin-glossarist 0.3.3 → 0.3.7

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -6
  3. data/.rubocop_todo.yml +90 -196
  4. data/Gemfile +6 -5
  5. data/README.adoc +11 -1
  6. data/lib/metanorma/plugin/glossarist/bibliography_renderer.rb +54 -12
  7. data/lib/metanorma/plugin/glossarist/concept_filter.rb +22 -40
  8. data/lib/metanorma/plugin/glossarist/concept_path_resolver.rb +117 -0
  9. data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +98 -82
  10. data/lib/metanorma/plugin/glossarist/dataset_registry.rb +108 -0
  11. data/lib/metanorma/plugin/glossarist/document.rb +9 -20
  12. data/lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb +47 -60
  13. data/lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb +10 -4
  14. data/lib/metanorma/plugin/glossarist/liquid/custom_filters.rb +14 -0
  15. data/lib/metanorma/plugin/glossarist/liquid/drop_bracket_access.rb +36 -0
  16. data/lib/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop.rb +47 -0
  17. data/lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop.rb +29 -0
  18. data/lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_drop.rb +45 -0
  19. data/lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb +1 -1
  20. data/lib/metanorma/plugin/glossarist/liquid.rb +26 -0
  21. data/lib/metanorma/plugin/glossarist/liquid_rendering.rb +26 -0
  22. data/lib/metanorma/plugin/glossarist/liquid_templates/_concept.liquid +52 -0
  23. data/lib/metanorma/plugin/glossarist/sanitize.rb +6 -4
  24. data/lib/metanorma/plugin/glossarist/section_filter.rb +50 -0
  25. data/lib/metanorma/plugin/glossarist/template_renderer.rb +112 -0
  26. data/lib/metanorma/plugin/glossarist/version.rb +1 -1
  27. data/lib/metanorma-plugin-glossarist.rb +30 -8
  28. data/metanorma-plugin-glossarist.gemspec +1 -1
  29. metadata +18 -9
  30. data/lib/metanorma/plugin/glossarist/citation_helper.rb +0 -13
  31. data/lib/metanorma/plugin/glossarist/concept_renderer.rb +0 -93
  32. data/lib/metanorma/plugin/glossarist/concept_serializer.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe89743a34d45928f640f6276a517ace30cf56fccc16f1e41b6ed083d68742db
4
- data.tar.gz: e217662e0b7bd0a353c7841745466236acf0be3fe30df53956fd81ba3d21fa81
3
+ metadata.gz: df92f7c76b0f53a2ab86ce33202371f17a4d83a7c9f781196d2ffc8d88477102
4
+ data.tar.gz: 10c0cb1fa52fc6d9bd7b60a30910e78fe8f2dda1f23ea280b2ab84f9f2cf8a0d
5
5
  SHA512:
6
- metadata.gz: 1c6b4cd2d5650232544219d900ceb018b78169518702d2db27087c985777002df39f821d72fbb075e2e4171c2fe69fdb9808a558e7952a472c0e7ebfae718c28
7
- data.tar.gz: 8616215c2ec7245a6bfe16955507629e7133d165f0176d8efc93d2e5804b787b9169c395c3fed4b59e4777cf0a92600c1d00b80c190705efcdab2cf622813220
6
+ metadata.gz: ba5db22578e76a38145ded8c9fd81cfa6dd5bf5752b4e502e232ef1586ac502450918c9a7d450646407d3165f5cffafdc93571e19eb2cc5819d9106bf036a126
7
+ data.tar.gz: a27d8568b1a1dcdcc779374c0be6e13709cb68d921ac2ebbb0d7db3595680714c7e88d3db509574fdd717782c5827ac347bef1979d1aed707c8a6831bb740a5f
data/.gitignore CHANGED
@@ -1,3 +1,8 @@
1
+
2
+ # rspec failure tracking
3
+ *.log.txt
4
+ .rspec_status
5
+ .rubocop-https--*
1
6
  /.bundle/
2
7
  /.yardoc
3
8
  /_yardoc/
@@ -6,10 +11,5 @@
6
11
  /pkg/
7
12
  /spec/reports/
8
13
  /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- .rubocop-https--*
14
- *.log.txt
15
14
  Gemfile.lock
15
+ TODO*
data/.rubocop_todo.yml CHANGED
@@ -1,89 +1,40 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-11 09:00:54 UTC using RuboCop version 1.86.1.
3
+ # on 2026-06-13 04:20:36 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 7
10
- # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
12
- Bundler/OrderedGems:
13
- Exclude:
14
- - 'Gemfile'
15
-
16
- # Offense count: 1
17
- # This cop supports safe autocorrection (--autocorrect).
18
- Gemspec/RequireMFA:
19
- Exclude:
20
- - 'metanorma-plugin-glossarist.gemspec'
21
-
22
9
  # Offense count: 1
23
10
  Gemspec/RequiredRubyVersion:
24
11
  Exclude:
25
12
  - 'metanorma-plugin-glossarist.gemspec'
26
13
 
27
- # Offense count: 3
14
+ # Offense count: 2
28
15
  # This cop supports safe autocorrection (--autocorrect).
29
16
  # Configuration parameters: EnforcedStyle, IndentationWidth.
30
17
  # SupportedStyles: with_first_argument, with_fixed_indentation
31
18
  Layout/ArgumentAlignment:
32
19
  Exclude:
33
- - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
34
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
35
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
20
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
21
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
36
22
 
37
23
  # Offense count: 1
38
24
  # This cop supports safe autocorrection (--autocorrect).
39
- # Configuration parameters: IndentationWidth.
40
- Layout/AssignmentIndentation:
41
- Exclude:
42
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
43
-
44
- # Offense count: 20
45
- # This cop supports safe autocorrection (--autocorrect).
46
25
  # Configuration parameters: EnforcedStyleAlignWith.
47
26
  # SupportedStylesAlignWith: either, start_of_block, start_of_line
48
27
  Layout/BlockAlignment:
49
28
  Exclude:
50
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
51
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
52
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
53
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
54
-
55
- # Offense count: 14
56
- # This cop supports safe autocorrection (--autocorrect).
57
- Layout/BlockEndNewline:
58
- Exclude:
59
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
60
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
61
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
62
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
29
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
63
30
 
64
31
  # Offense count: 1
65
32
  # This cop supports safe autocorrection (--autocorrect).
66
- Layout/ClosingParenthesisIndentation:
67
- Exclude:
68
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
69
-
70
- # Offense count: 1
71
- # This cop supports safe autocorrection (--autocorrect).
72
- # Configuration parameters: EnforcedStyle, IndentationWidth.
73
- # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
74
- Layout/FirstArgumentIndentation:
75
- Exclude:
76
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
77
-
78
- # Offense count: 4
79
- # This cop supports safe autocorrection (--autocorrect).
80
- # Configuration parameters: EnforcedStyle, IndentationWidth.
81
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
82
- Layout/FirstHashElementIndentation:
33
+ Layout/BlockEndNewline:
83
34
  Exclude:
84
- - 'spec/metanorma/plugin/glossarist/concept_filter_spec.rb'
35
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
85
36
 
86
- # Offense count: 4
37
+ # Offense count: 2
87
38
  # This cop supports safe autocorrection (--autocorrect).
88
39
  # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
89
40
  # SupportedHashRocketStyles: key, separator, table
@@ -91,37 +42,15 @@ Layout/FirstHashElementIndentation:
91
42
  # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
92
43
  Layout/HashAlignment:
93
44
  Exclude:
94
- - 'Gemfile'
95
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
96
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
97
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
45
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
98
46
 
99
- # Offense count: 1
100
- # This cop supports safe autocorrection (--autocorrect).
101
- # Configuration parameters: EnforcedStyle.
102
- # SupportedStyles: normal, indented_internal_methods
103
- Layout/IndentationConsistency:
104
- Exclude:
105
- - 'metanorma-plugin-glossarist.gemspec'
106
-
107
- # Offense count: 22
47
+ # Offense count: 2
108
48
  # This cop supports safe autocorrection (--autocorrect).
109
49
  # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
110
50
  # SupportedStylesAlignWith: start_of_line, relative_to_receiver
111
51
  Layout/IndentationWidth:
112
52
  Exclude:
113
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
114
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
115
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
116
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
117
-
118
- # Offense count: 1
119
- # This cop supports safe autocorrection (--autocorrect).
120
- # Configuration parameters: EnforcedStyle.
121
- # SupportedStyles: leading, trailing
122
- Layout/LineContinuationLeadingSpace:
123
- Exclude:
124
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
53
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
125
54
 
126
55
  # Offense count: 32
127
56
  # This cop supports safe autocorrection (--autocorrect).
@@ -129,138 +58,129 @@ Layout/LineContinuationLeadingSpace:
129
58
  # URISchemes: http, https
130
59
  Layout/LineLength:
131
60
  Exclude:
132
- - 'Gemfile'
133
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
134
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
61
+ - 'lib/metanorma-plugin-glossarist.rb'
62
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
135
63
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
64
+ - 'lib/metanorma/plugin/glossarist/liquid.rb'
136
65
  - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
137
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
66
+ - 'lib/metanorma/plugin/glossarist/liquid/drop_bracket_access.rb'
67
+ - 'lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop.rb'
68
+ - 'lib/metanorma/plugin/glossarist/section_filter.rb'
138
69
  - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
70
+ - 'spec/metanorma/plugin/glossarist/bibliography_scope_spec.rb'
139
71
  - 'spec/metanorma/plugin/glossarist/concept_filter_spec.rb'
140
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
141
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
72
+ - 'spec/metanorma/plugin/glossarist/concept_path_resolver_spec.rb'
73
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop_spec.rb'
74
+ - 'spec/metanorma/plugin/glossarist/liquid/with_glossarist_context_spec.rb'
142
75
 
143
- # Offense count: 6
76
+ # Offense count: 1
144
77
  # This cop supports safe autocorrection (--autocorrect).
145
78
  Layout/MultilineBlockLayout:
146
79
  Exclude:
147
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
148
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
149
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
80
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
150
81
 
151
- # Offense count: 1
82
+ # Offense count: 2
152
83
  # This cop supports safe autocorrection (--autocorrect).
153
- # Configuration parameters: EnforcedStyle.
154
- # SupportedStyles: symmetrical, new_line, same_line
155
- Layout/MultilineMethodCallBraceLayout:
84
+ # Configuration parameters: AllowInHeredoc.
85
+ Layout/TrailingWhitespace:
156
86
  Exclude:
157
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
87
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
88
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
158
89
 
159
- # Offense count: 14
90
+ # Offense count: 1
160
91
  # This cop supports safe autocorrection (--autocorrect).
161
- # Configuration parameters: AllowInHeredoc.
162
- Layout/TrailingWhitespace:
92
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
93
+ # NotImplementedExceptions: NotImplementedError
94
+ Lint/UnusedMethodArgument:
163
95
  Exclude:
164
- - 'Gemfile'
165
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
166
96
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
167
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
168
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
169
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
170
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
171
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
172
97
 
173
98
  # Offense count: 1
174
- # This cop supports safe autocorrection (--autocorrect).
175
- # Configuration parameters: AllowedMethods, AllowedPatterns.
176
- Lint/AmbiguousBlockAssociation:
99
+ Lint/UselessConstantScoping:
177
100
  Exclude:
178
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
101
+ - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
179
102
 
180
- # Offense count: 6
103
+ # Offense count: 11
181
104
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
182
105
  Metrics/AbcSize:
183
106
  Exclude:
184
107
  - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
185
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
186
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
108
+ - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
187
109
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
110
+ - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
111
+ - 'lib/metanorma/plugin/glossarist/template_renderer.rb'
188
112
 
189
- # Offense count: 4
113
+ # Offense count: 6
190
114
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
191
115
  Metrics/CyclomaticComplexity:
192
116
  Exclude:
193
117
  - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
194
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
195
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
118
+ - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
119
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
196
120
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
197
121
 
198
- # Offense count: 8
122
+ # Offense count: 14
199
123
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
200
124
  Metrics/MethodLength:
201
- Max: 19
125
+ Max: 24
202
126
 
203
- # Offense count: 4
127
+ # Offense count: 5
204
128
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
205
129
  Metrics/PerceivedComplexity:
206
130
  Exclude:
207
131
  - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
208
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
209
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
210
- - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
211
-
212
- # Offense count: 1
213
- # This cop supports unsafe autocorrection (--autocorrect-all).
214
- Performance/MapCompact:
215
- Exclude:
132
+ - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
216
133
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
217
134
 
218
- # Offense count: 1
219
- # This cop supports safe autocorrection (--autocorrect).
220
- # Configuration parameters: EnforcedStyle.
221
- # SupportedStyles: be, be_nil
222
- RSpec/BeNil:
223
- Exclude:
224
- - 'spec/metanorma/plugin/glossarist_spec.rb'
225
-
226
- # Offense count: 14
135
+ # Offense count: 19
227
136
  # Configuration parameters: Prefixes, AllowedPatterns.
228
137
  # Prefixes: when, with, without
229
138
  RSpec/ContextWording:
230
139
  Exclude:
231
140
  - 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
232
141
 
233
- # Offense count: 7
142
+ # Offense count: 1
143
+ # Configuration parameters: IgnoredMetadata.
144
+ RSpec/DescribeClass:
145
+ Exclude:
146
+ - 'spec/metanorma/plugin/glossarist/bibliography_scope_spec.rb'
147
+
148
+ # Offense count: 27
234
149
  # Configuration parameters: CountAsOne.
235
150
  RSpec/ExampleLength:
236
151
  Max: 35
237
152
 
238
- # Offense count: 18
239
- # This cop supports safe autocorrection (--autocorrect).
240
- # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
241
- # DisallowedExamples: works
242
- RSpec/ExampleWording:
243
- Exclude:
244
- - 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
245
-
246
- # Offense count: 12
153
+ # Offense count: 31
247
154
  RSpec/MultipleExpectations:
248
- Max: 7
155
+ Max: 4
249
156
 
250
- # Offense count: 28
157
+ # Offense count: 33
251
158
  # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
252
159
  # SupportedStyles: always, named_only
253
160
  RSpec/NamedSubject:
254
161
  Exclude:
255
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
256
162
  - 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
257
163
 
258
- # Offense count: 22
164
+ # Offense count: 30
259
165
  # Configuration parameters: AllowedGroups.
260
166
  RSpec/NestedGroups:
261
167
  Max: 6
262
168
 
263
- # Offense count: 19
169
+ # Offense count: 2
170
+ RSpec/RepeatedExample:
171
+ Exclude:
172
+ - 'spec/metanorma/plugin/glossarist/concept_path_resolver_spec.rb'
173
+
174
+ # Offense count: 3
175
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
176
+ # SupportedInflectors: default, active_support
177
+ RSpec/SpecFilePathFormat:
178
+ Exclude:
179
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop_spec.rb'
180
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop_spec.rb'
181
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/managed_concept_drop_spec.rb'
182
+
183
+ # Offense count: 1
264
184
  # This cop supports safe autocorrection (--autocorrect).
265
185
  # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
266
186
  # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
@@ -269,58 +189,32 @@ RSpec/NestedGroups:
269
189
  # AllowedMethods: lambda, proc, it
270
190
  Style/BlockDelimiters:
271
191
  Exclude:
272
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
273
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
274
- - 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
275
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
192
+ - 'spec/metanorma/plugin/glossarist/section_spec.rb'
276
193
 
277
- # Offense count: 4
194
+ # Offense count: 1
278
195
  # This cop supports safe autocorrection (--autocorrect).
279
- Style/MultilineIfModifier:
196
+ # Configuration parameters: EnforcedStyle, AllowComments.
197
+ # SupportedStyles: empty, nil, both
198
+ Style/EmptyElse:
280
199
  Exclude:
281
- - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
282
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
283
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
200
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
284
201
 
285
202
  # Offense count: 1
286
- # This cop supports unsafe autocorrection (--autocorrect-all).
287
- Style/ReduceToHash:
288
- Exclude:
289
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
290
-
291
- # Offense count: 120
292
203
  # This cop supports safe autocorrection (--autocorrect).
293
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
294
- # SupportedStyles: single_quotes, double_quotes
295
- Style/StringLiterals:
204
+ Style/MultilineIfModifier:
296
205
  Exclude:
297
- - 'lib/metanorma-plugin-glossarist.rb'
298
- - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
299
- - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
300
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
301
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
302
- - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
303
- - 'lib/metanorma/plugin/glossarist/document.rb'
304
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
305
- - 'lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb'
306
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
307
- - 'lib/metanorma/plugin/glossarist/sanitize.rb'
308
- - 'lib/metanorma/plugin/glossarist/version.rb'
309
- - 'metanorma-plugin-glossarist.gemspec'
206
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
310
207
 
311
- # Offense count: 3
312
- # This cop supports safe autocorrection (--autocorrect).
313
- # Configuration parameters: EnforcedStyleForMultiline.
314
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
315
- Style/TrailingCommaInArguments:
208
+ # Offense count: 2
209
+ # Configuration parameters: Max.
210
+ Style/SafeNavigationChainLength:
316
211
  Exclude:
317
- - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
318
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
212
+ - 'lib/metanorma/plugin/glossarist/dataset_registry.rb'
213
+ - 'lib/metanorma/plugin/glossarist/template_renderer.rb'
319
214
 
320
- # Offense count: 6
321
- # This cop supports safe autocorrection (--autocorrect).
322
- # Configuration parameters: EnforcedStyleForMultiline.
323
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
324
- Style/TrailingCommaInHashLiteral:
215
+ # Offense count: 1
216
+ # This cop supports unsafe autocorrection (--autocorrect-all).
217
+ # Configuration parameters: Mode.
218
+ Style/StringConcatenation:
325
219
  Exclude:
326
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
220
+ - 'lib/metanorma/plugin/glossarist/template_renderer.rb'
data/Gemfile CHANGED
@@ -1,12 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source "https://rubygems.org"
4
- git_source(:github) { |repo| "https://github.com/#{repo}" }
5
4
 
6
- gem "metanorma", github: "metanorma/metanorma", branch: "main"
7
- gem "metanorma-plugin-lutaml", github: "metanorma/metanorma-plugin-lutaml",
8
- branch: "main"
9
- gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "main"
10
5
  gem "ogc-gml", "~> 1.1"
11
6
  gem "rake"
12
7
  gem "rspec"
@@ -16,3 +11,9 @@ gem "rubocop-rake"
16
11
  gem "rubocop-rspec"
17
12
 
18
13
  gemspec
14
+
15
+ group :test do
16
+ gem "metanorma"
17
+ gem "metanorma-plugin-lutaml"
18
+ gem "metanorma-standoc"
19
+ end
data/README.adoc CHANGED
@@ -311,9 +311,19 @@ alphabetically by the English designation.
311
311
  [example]
312
312
  `lang=ara` loads all localized concepts of Arabic for all concepts.
313
313
 
314
+ `tag=<tag name>`::: Loads concepts that carry the specified organizational tag.
315
+ Tags are plain strings on `ManagedConceptData.tags`, used for grouping and
316
+ filtering concepts by section or category (e.g. `tag=general`,
317
+ `tag=time-scale-units`). Unlike `domain=`, tags are not rendered as
318
+ terminological domain annotations.
319
+ +
320
+ [example]
321
+ `tag=general` will only load concepts whose `tags` array includes `"general"`.
322
+
314
323
  `domain=<domain name>`::: Loads concepts that belong to the specified domain.
315
324
  Domains are `ConceptReference` objects (with `concept_id` and `ref_type: "domain"`)
316
- that categorize concepts into subject areas.
325
+ that categorize concepts into subject areas, and are rendered as `<domain>`
326
+ elements in the output.
317
327
  +
318
328
  [example]
319
329
  `domain=foo` will only load concepts that have a domain with `concept_id` "foo".
@@ -1,13 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "set"
4
+
3
5
  module Metanorma
4
6
  module Plugin
5
7
  module Glossarist
6
8
  class BibliographyRenderer
7
- include CitationHelper
9
+ IEV_ENTRY = "* [[[ievtermbank,IEV]]], _IEV: Electropedia_"
10
+ IEV_ANCHOR = "ievtermbank"
8
11
 
9
- def initialize
12
+ def initialize(existing_anchors: [], bibliography_data: {})
10
13
  @rendered = {}
14
+ @existing_anchors = Set.new(existing_anchors)
15
+ @bibliography_data = bibliography_data
11
16
  end
12
17
 
13
18
  def render_entry(concept, lang: "eng")
@@ -15,13 +20,28 @@ module Metanorma
15
20
  return nil unless l10n
16
21
 
17
22
  entries = source_entries(l10n)
18
- warn_unresolved_xrefs(l10n)
23
+ entries.concat(xref_entries(l10n))
19
24
  entries.empty? ? nil : entries.sort.join("\n")
20
25
  end
21
26
 
22
27
  def render_all(concepts, lang: "eng")
23
- entries = concepts.filter_map { |c| render_entry(c, lang: lang) }
24
- entries.sort.join("\n")
28
+ all_entries = concepts.filter_map do |concept|
29
+ l10n = concept.localization(lang)
30
+ next unless l10n
31
+
32
+ source_entries(l10n)
33
+ end.flatten
34
+
35
+ xref_entries = concepts.filter_map do |concept|
36
+ l10n = concept.localization(lang)
37
+ next unless l10n
38
+
39
+ xref_entries(l10n)
40
+ end.flatten
41
+
42
+ all_entries.concat(xref_entries)
43
+
44
+ all_entries.sort.join("\n")
25
45
  end
26
46
 
27
47
  private
@@ -31,28 +51,50 @@ module Metanorma
31
51
  return [] if sources.nil? || sources.empty?
32
52
 
33
53
  sources.filter_map do |source|
34
- ref = citation_ref_label(source.origin)
54
+ ref = source.origin&.text
35
55
  next if ref.nil? || ref.empty?
36
56
  next if @rendered.key?(ref)
37
57
 
38
58
  anchor = ref.gsub(%r{[ /:]}, "_")
59
+ next if @existing_anchors.include?(anchor)
60
+
39
61
  @rendered[ref] = anchor
40
- "* [[[#{anchor},#{ref}]]]"
62
+
63
+ if anchor == IEV_ANCHOR
64
+ IEV_ENTRY
65
+ else
66
+ format_entry(anchor, ref)
67
+ end
41
68
  end
42
69
  end
43
70
 
44
- def warn_unresolved_xrefs(l10n)
71
+ def xref_entries(l10n)
45
72
  xref_ids = extract_content_xrefs(l10n)
46
- return if xref_ids.empty?
73
+ return [] if xref_ids.empty?
47
74
 
48
- xref_ids.each do |ref_id|
75
+ xref_ids.filter_map do |ref_id|
49
76
  next if @rendered.value?(ref_id)
77
+ next if @existing_anchors.include?(ref_id)
78
+ next unless @bibliography_data.key?(ref_id)
79
+
80
+ anchor = ref_id
81
+ @rendered[ref_id] = anchor
50
82
 
51
- warn "[glossarist] unresolved bibliography reference: " \
52
- "<<#{ref_id}>> — not defined as a source in the dataset"
83
+ format_entry(anchor, ref_id)
53
84
  end
54
85
  end
55
86
 
87
+ def format_entry(anchor, ref)
88
+ bib = @bibliography_data[ref]
89
+ return "* [[[#{anchor},#{ref}]]]" unless bib
90
+
91
+ display_ref = bib["reference"] || ref
92
+ parts = ["* [[[#{anchor},#{display_ref}]]]"]
93
+ parts << ", _#{bib['title']}_" if bib["title"]
94
+ parts << ". Available at: #{bib['link']} " if bib["link"]
95
+ parts.join
96
+ end
97
+
56
98
  def extract_content_xrefs(l10n)
57
99
  parts = []
58
100
  l10n.definition&.each { |d| parts << d.content.to_s }