metanorma-plugin-glossarist 0.3.2 → 0.3.6

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 (30) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -6
  3. data/.rubocop_todo.yml +55 -246
  4. data/Gemfile +6 -5
  5. data/README.adoc +11 -1
  6. data/lib/metanorma/plugin/glossarist/bibliography_renderer.rb +54 -10
  7. data/lib/metanorma/plugin/glossarist/concept_filter.rb +22 -40
  8. data/lib/metanorma/plugin/glossarist/concept_path_resolver.rb +100 -0
  9. data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +55 -84
  10. data/lib/metanorma/plugin/glossarist/dataset_registry.rb +98 -0
  11. data/lib/metanorma/plugin/glossarist/document.rb +8 -20
  12. data/lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb +47 -61
  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 +51 -0
  23. data/lib/metanorma/plugin/glossarist/sanitize.rb +6 -4
  24. data/lib/metanorma/plugin/glossarist/template_renderer.rb +113 -0
  25. data/lib/metanorma/plugin/glossarist/version.rb +1 -1
  26. data/lib/metanorma-plugin-glossarist.rb +26 -7
  27. data/metanorma-plugin-glossarist.gemspec +1 -1
  28. metadata +21 -6
  29. data/lib/metanorma/plugin/glossarist/concept_renderer.rb +0 -91
  30. 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: 55d315bc6cddf69dfc612fa0f19f6b7fb2161333f765a525befffb6e83000185
4
- data.tar.gz: db3d207cb5be69640cd4e137c79853ee5d008537743f6d24763ae687f464923c
3
+ metadata.gz: 6d98a873073dcda160a7b6f3ee5e61c994c50c418007e0dd2861c231c16ac65d
4
+ data.tar.gz: 2d3c3cc14fcaed9644f72fe7626e7aa8ebfd65d7b88ce4144c697b5cb3e123b2
5
5
  SHA512:
6
- metadata.gz: 164ee3cb6feb6b609cc4bb28541f539e9fd2c7354a05dded59863b9d81405ae0f42bc68a618f5b5fecb02b503bf628a6101c9ab0a3ffae0c54c502ecd0db9e63
7
- data.tar.gz: b014dcaa771d6e67dac030f6ffaf0b662cfc9e5f2471ec8a482c38006ff2dcdd321c568a3c8f3fa3026170dd19c497dcbff0c21c8e25c7f19fd373e5af463792
6
+ metadata.gz: f9b86a8598407a6172693189fb1e89e7faa2d49673035a74f895ec0bb43886d3205fbd77cf620090f4ed157a4c4512367ca3479fc598f5e7259f724f1c9db53e
7
+ data.tar.gz: 49cb457f4154355f6c9484754704e0063c70df33e396600c5ac8ad2b2705bc8994fdbe38ed4463683c3e7f7668873eceb1f4f837d999115e34dc1f54fac70e9c
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,326 +1,135 @@
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-09 09:31:05 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
28
- # This cop supports safe autocorrection (--autocorrect).
29
- # Configuration parameters: EnforcedStyle, IndentationWidth.
30
- # SupportedStyles: with_first_argument, with_fixed_indentation
31
- Layout/ArgumentAlignment:
32
- 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'
36
-
37
- # Offense count: 1
38
- # 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
- # Configuration parameters: EnforcedStyleAlignWith.
47
- # SupportedStylesAlignWith: either, start_of_block, start_of_line
48
- Layout/BlockAlignment:
49
- 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'
63
-
64
- # Offense count: 1
65
- # 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:
83
- Exclude:
84
- - 'spec/metanorma/plugin/glossarist/concept_filter_spec.rb'
85
-
86
- # Offense count: 4
87
- # This cop supports safe autocorrection (--autocorrect).
88
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
89
- # SupportedHashRocketStyles: key, separator, table
90
- # SupportedColonStyles: key, separator, table
91
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
92
- Layout/HashAlignment:
93
- 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'
98
-
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
108
- # This cop supports safe autocorrection (--autocorrect).
109
- # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
110
- # SupportedStylesAlignWith: start_of_line, relative_to_receiver
111
- Layout/IndentationWidth:
112
- 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'
125
-
126
- # Offense count: 32
14
+ # Offense count: 25
127
15
  # This cop supports safe autocorrection (--autocorrect).
128
16
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
129
17
  # URISchemes: http, https
130
18
  Layout/LineLength:
131
19
  Exclude:
132
- - 'Gemfile'
133
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
134
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
20
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
135
21
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
22
+ - 'lib/metanorma/plugin/glossarist/liquid.rb'
136
23
  - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
137
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
24
+ - 'lib/metanorma/plugin/glossarist/liquid/drop_bracket_access.rb'
25
+ - 'lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop.rb'
138
26
  - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
27
+ - 'spec/metanorma/plugin/glossarist/bibliography_scope_spec.rb'
139
28
  - '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'
142
-
143
- # Offense count: 6
144
- # This cop supports safe autocorrection (--autocorrect).
145
- Layout/MultilineBlockLayout:
146
- 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'
29
+ - 'spec/metanorma/plugin/glossarist/concept_path_resolver_spec.rb'
30
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop_spec.rb'
31
+ - 'spec/metanorma/plugin/glossarist/liquid/with_glossarist_context_spec.rb'
150
32
 
151
33
  # Offense count: 1
152
- # This cop supports safe autocorrection (--autocorrect).
153
- # Configuration parameters: EnforcedStyle.
154
- # SupportedStyles: symmetrical, new_line, same_line
155
- Layout/MultilineMethodCallBraceLayout:
34
+ Lint/UselessConstantScoping:
156
35
  Exclude:
157
- - 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
158
-
159
- # Offense count: 14
160
- # This cop supports safe autocorrection (--autocorrect).
161
- # Configuration parameters: AllowInHeredoc.
162
- Layout/TrailingWhitespace:
163
- Exclude:
164
- - 'Gemfile'
165
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
166
36
  - '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
37
 
173
- # Offense count: 1
174
- # This cop supports safe autocorrection (--autocorrect).
175
- # Configuration parameters: AllowedMethods, AllowedPatterns.
176
- Lint/AmbiguousBlockAssociation:
177
- Exclude:
178
- - 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
179
-
180
- # Offense count: 6
38
+ # Offense count: 8
181
39
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
182
40
  Metrics/AbcSize:
183
41
  Exclude:
184
42
  - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
185
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
186
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
43
+ - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
187
44
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
45
+ - 'lib/metanorma/plugin/glossarist/template_renderer.rb'
188
46
 
189
- # Offense count: 4
47
+ # Offense count: 5
190
48
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
191
49
  Metrics/CyclomaticComplexity:
192
50
  Exclude:
193
51
  - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
194
- - 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
195
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
52
+ - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
53
+ - 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
196
54
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
197
55
 
198
- # Offense count: 8
56
+ # Offense count: 13
199
57
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
200
58
  Metrics/MethodLength:
201
- Max: 19
59
+ Max: 22
202
60
 
203
61
  # Offense count: 4
204
62
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
205
63
  Metrics/PerceivedComplexity:
206
64
  Exclude:
207
65
  - '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:
66
+ - 'lib/metanorma/plugin/glossarist/concept_filter.rb'
216
67
  - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
217
68
 
218
69
  # Offense count: 1
219
- # This cop supports safe autocorrection (--autocorrect).
220
- # Configuration parameters: EnforcedStyle.
221
- # SupportedStyles: be, be_nil
222
- RSpec/BeNil:
70
+ # Configuration parameters: MinSize.
71
+ Performance/CollectionLiteralInLoop:
223
72
  Exclude:
224
- - 'spec/metanorma/plugin/glossarist_spec.rb'
73
+ - 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
225
74
 
226
- # Offense count: 14
75
+ # Offense count: 17
227
76
  # Configuration parameters: Prefixes, AllowedPatterns.
228
77
  # Prefixes: when, with, without
229
78
  RSpec/ContextWording:
230
79
  Exclude:
231
80
  - 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
232
81
 
233
- # Offense count: 7
82
+ # Offense count: 1
83
+ # Configuration parameters: IgnoredMetadata.
84
+ RSpec/DescribeClass:
85
+ Exclude:
86
+ - 'spec/metanorma/plugin/glossarist/bibliography_scope_spec.rb'
87
+
88
+ # Offense count: 19
234
89
  # Configuration parameters: CountAsOne.
235
90
  RSpec/ExampleLength:
236
91
  Max: 35
237
92
 
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
93
+ # Offense count: 22
247
94
  RSpec/MultipleExpectations:
248
- Max: 7
95
+ Max: 3
249
96
 
250
- # Offense count: 28
97
+ # Offense count: 25
251
98
  # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
252
99
  # SupportedStyles: always, named_only
253
100
  RSpec/NamedSubject:
254
101
  Exclude:
255
- - 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
256
102
  - 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
257
103
 
258
- # Offense count: 22
104
+ # Offense count: 28
259
105
  # Configuration parameters: AllowedGroups.
260
106
  RSpec/NestedGroups:
261
107
  Max: 6
262
108
 
263
- # Offense count: 19
264
- # This cop supports safe autocorrection (--autocorrect).
265
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
266
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
267
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
268
- # FunctionalMethods: let, let!, subject, watch
269
- # AllowedMethods: lambda, proc, it
270
- Style/BlockDelimiters:
109
+ # Offense count: 2
110
+ RSpec/RepeatedExample:
271
111
  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'
276
-
277
- # Offense count: 4
278
- # This cop supports safe autocorrection (--autocorrect).
279
- Style/MultilineIfModifier:
280
- 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'
112
+ - 'spec/metanorma/plugin/glossarist/concept_path_resolver_spec.rb'
284
113
 
285
- # 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
- # This cop supports safe autocorrection (--autocorrect).
293
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
294
- # SupportedStyles: single_quotes, double_quotes
295
- Style/StringLiterals:
114
+ # Offense count: 3
115
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
116
+ # SupportedInflectors: default, active_support
117
+ RSpec/SpecFilePathFormat:
296
118
  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'
119
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop_spec.rb'
120
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop_spec.rb'
121
+ - 'spec/metanorma/plugin/glossarist/liquid/drops/managed_concept_drop_spec.rb'
310
122
 
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:
123
+ # Offense count: 2
124
+ # Configuration parameters: Max.
125
+ Style/SafeNavigationChainLength:
316
126
  Exclude:
317
- - 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
318
- - 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
127
+ - 'lib/metanorma/plugin/glossarist/dataset_registry.rb'
128
+ - 'lib/metanorma/plugin/glossarist/template_renderer.rb'
319
129
 
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:
130
+ # Offense count: 1
131
+ # This cop supports unsafe autocorrection (--autocorrect-all).
132
+ # Configuration parameters: Mode.
133
+ Style/StringConcatenation:
325
134
  Exclude:
326
- - 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
135
+ - '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,11 +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
- def initialize
9
+ IEV_ENTRY = "* [[[ievtermbank,IEV]]], _IEV: Electropedia_"
10
+ IEV_ANCHOR = "ievtermbank"
11
+
12
+ def initialize(existing_anchors: [], bibliography_data: {})
8
13
  @rendered = {}
14
+ @existing_anchors = Set.new(existing_anchors)
15
+ @bibliography_data = bibliography_data
9
16
  end
10
17
 
11
18
  def render_entry(concept, lang: "eng")
@@ -13,13 +20,28 @@ module Metanorma
13
20
  return nil unless l10n
14
21
 
15
22
  entries = source_entries(l10n)
16
- warn_unresolved_xrefs(l10n)
23
+ entries.concat(xref_entries(l10n))
17
24
  entries.empty? ? nil : entries.sort.join("\n")
18
25
  end
19
26
 
20
27
  def render_all(concepts, lang: "eng")
21
- entries = concepts.filter_map { |c| render_entry(c, lang: lang) }
22
- 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")
23
45
  end
24
46
 
25
47
  private
@@ -34,23 +56,45 @@ module Metanorma
34
56
  next if @rendered.key?(ref)
35
57
 
36
58
  anchor = ref.gsub(%r{[ /:]}, "_")
59
+ next if @existing_anchors.include?(anchor)
60
+
37
61
  @rendered[ref] = anchor
38
- "* [[[#{anchor},#{ref}]]]"
62
+
63
+ if anchor == IEV_ANCHOR
64
+ IEV_ENTRY
65
+ else
66
+ format_entry(anchor, ref)
67
+ end
39
68
  end
40
69
  end
41
70
 
42
- def warn_unresolved_xrefs(l10n)
71
+ def xref_entries(l10n)
43
72
  xref_ids = extract_content_xrefs(l10n)
44
- return if xref_ids.empty?
73
+ return [] if xref_ids.empty?
45
74
 
46
- xref_ids.each do |ref_id|
75
+ xref_ids.filter_map do |ref_id|
47
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
48
82
 
49
- warn "[glossarist] unresolved bibliography reference: " \
50
- "<<#{ref_id}>> — not defined as a source in the dataset"
83
+ format_entry(anchor, ref_id)
51
84
  end
52
85
  end
53
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
+
54
98
  def extract_content_xrefs(l10n)
55
99
  parts = []
56
100
  l10n.definition&.each { |d| parts << d.content.to_s }
@@ -4,11 +4,12 @@ module Metanorma
4
4
  module Plugin
5
5
  module Glossarist
6
6
  class ConceptFilter
7
- COLLECTION_FILTERS = %w[lang domain group sort_by].freeze
7
+ COLLECTION_FILTERS = %w[lang domain group section tag sort_by].freeze
8
8
  SORT_LAST = ["￿"].freeze
9
9
 
10
10
  def initialize(filters)
11
11
  @filters = filters || {}
12
+ @resolver = ConceptPathResolver.new
12
13
  end
13
14
 
14
15
  def apply(collection)
@@ -17,6 +18,8 @@ module Metanorma
17
18
  if @filters.key?("domain") || @filters.key?("group")
18
19
  result = filter_by_domain(result)
19
20
  end
21
+ result = filter_by_section(result) if @filters.key?("section")
22
+ result = filter_by_tag(result) if @filters.key?("tag")
20
23
  result = filter_by_field(result) if field_filter?
21
24
  result = sort(result) if @filters.key?("sort_by")
22
25
  result
@@ -44,6 +47,20 @@ module Metanorma
44
47
  end
45
48
  end
46
49
 
50
+ def filter_by_tag(collection)
51
+ tag = @filters["tag"]
52
+ collection.select do |c|
53
+ c.data.tags&.include?(tag)
54
+ end
55
+ end
56
+
57
+ def filter_by_section(collection)
58
+ section_id = @filters["section"]
59
+ collection.select do |c|
60
+ c.data.domains&.any? { |d| d.concept_id == "section-#{section_id}" }
61
+ end
62
+ end
63
+
47
64
  def sort(collection)
48
65
  field = @filters["sort_by"]
49
66
  return collection unless field
@@ -52,14 +69,12 @@ module Metanorma
52
69
  when "term", "default_designation"
53
70
  collection.sort_by { |c| c.default_designation.to_s.downcase }
54
71
  else
55
- parts = parse_path(field)
56
- collection.sort_by { |c| sort_key(c, parts) }
72
+ collection.sort_by { |c| sort_key(c, field) }
57
73
  end
58
74
  end
59
75
 
60
- def sort_key(concept, parts)
61
- hash = ConceptSerializer.new(concept).to_h
62
- value = dig_path(hash, parts)
76
+ def sort_key(concept, field)
77
+ value = @resolver.resolve(concept, field)
63
78
  value.nil? ? SORT_LAST : natural_sort_key(value.to_s)
64
79
  end
65
80
 
@@ -75,10 +90,8 @@ module Metanorma
75
90
  start_with = path.include?(".start_with(")
76
91
  path, match_value = extract_start_with(path, value, start_with)
77
92
 
78
- parts = parse_path(path)
79
93
  collection.select do |concept|
80
- hash = ConceptSerializer.new(concept).to_h
81
- actual = dig_path(hash, parts)
94
+ actual = @resolver.resolve(concept, path)
82
95
  if start_with
83
96
  actual&.start_with?(match_value)
84
97
  else
@@ -95,37 +108,6 @@ module Metanorma
95
108
 
96
109
  [match[1], match[2]]
97
110
  end
98
-
99
- def parse_path(path)
100
- path.split(".").flat_map do |segment|
101
- if segment.include?("[")
102
- parse_indexed_segment(segment)
103
- else
104
- [segment]
105
- end
106
- end
107
- end
108
-
109
- def parse_indexed_segment(segment)
110
- field, index_part = segment.split("[", 2)
111
- index = index_part&.delete("]'\"")
112
- if index.match?(/\A\d+\z/)
113
- [field, index.to_i]
114
- else
115
- [field, index]
116
- end
117
- end
118
-
119
- def dig_path(hash, parts)
120
- parts.reduce(hash) do |current, key|
121
- case current
122
- when Hash
123
- current[key] || current[key.to_s]
124
- when Array
125
- key.is_a?(Integer) ? current[key] : nil
126
- end
127
- end
128
- end
129
111
  end
130
112
  end
131
113
  end