expressir 2.1.18 → 2.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d20d882f0b9e6b30860d41294671b6c235cff0cc024521276ca9ca3283e1f79a
4
- data.tar.gz: 8625cc4fa425c9d02c73e056b8ee9ee8aa69eaab566452b44e1a1ae137faacf6
3
+ metadata.gz: b0e1c52810ce3b1361d9f8327c0c270ac3a7f366f16d3b3236a0ed3e559155a9
4
+ data.tar.gz: a852899cbf8d6a7747b8609ae7ec00736eddfcfad6a9fd8d410cd453811a4188
5
5
  SHA512:
6
- metadata.gz: 88dc6630b82e7b7c01f49df868664caa34d54e5d21d2af4d786094f7c880b7f39bbd7295f084e1e3558f9705a7798364740dfdc40086241b7d20e36419ae75b9
7
- data.tar.gz: 0f87bcc8eda3e6b321202f64b9bcfc5a357c8b3ee4c1f0dc481a7610e9680f2af50a0b257838809d05888fda647f28be9583e1debfac557fa31c78b1b2c66fb2
6
+ metadata.gz: f8db59aa54a5a1edd29165ec3b79e9e98a35ebd51d8d0184735417c96bbd9d178328ddad2feef11f177bc140bd514913d5581f0c01ba8f9ee25b5a3cdf35a7d2
7
+ data.tar.gz: fef82dcf757767e2a1eea5b252083f0b8f9db85226263f74c7979fde768caa25895df05cca29ac525b799f21ffd19dfd138e26087d3351e0a210b62746bd1867
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-03-21 10:31:17 UTC using RuboCop version 1.74.0.
3
+ # on 2025-06-05 12:41:11 UTC using RuboCop version 1.75.2.
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
@@ -21,6 +21,12 @@ Layout/LineLength:
21
21
  Exclude:
22
22
  - 'lib/expressir/express/parser.rb'
23
23
 
24
+ # Offense count: 1
25
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
26
+ Lint/DuplicateBranch:
27
+ Exclude:
28
+ - 'lib/expressir/coverage.rb'
29
+
24
30
  # Offense count: 3
25
31
  Lint/ShadowingOuterLocalVariable:
26
32
  Exclude:
@@ -35,13 +41,17 @@ Lint/UnusedMethodArgument:
35
41
  - 'lib/expressir/express/cache.rb'
36
42
  - 'lib/expressir/express/parser.rb'
37
43
 
38
- # Offense count: 61
44
+ # Offense count: 75
39
45
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
40
46
  Metrics/AbcSize:
41
47
  Exclude:
42
48
  - 'lib/expressir/benchmark.rb'
43
- - 'lib/expressir/cli.rb'
49
+ - 'lib/expressir/commands/benchmark.rb'
50
+ - 'lib/expressir/commands/benchmark_cache.rb'
51
+ - 'lib/expressir/commands/coverage.rb'
52
+ - 'lib/expressir/commands/validate.rb'
44
53
  - 'lib/expressir/config.rb'
54
+ - 'lib/expressir/coverage.rb'
45
55
  - 'lib/expressir/express/formatter.rb'
46
56
  - 'lib/expressir/express/hyperlink_formatter.rb'
47
57
  - 'lib/expressir/express/parser.rb'
@@ -50,17 +60,19 @@ Metrics/AbcSize:
50
60
  - 'lib/expressir/model/declarations/schema.rb'
51
61
  - 'lib/expressir/model/model_element.rb'
52
62
 
53
- # Offense count: 2
63
+ # Offense count: 1
54
64
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
55
65
  # AllowedMethods: refine
56
66
  Metrics/BlockLength:
57
- Max: 141
67
+ Max: 143
58
68
 
59
- # Offense count: 45
69
+ # Offense count: 54
60
70
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
61
71
  Metrics/CyclomaticComplexity:
62
72
  Exclude:
63
73
  - 'lib/expressir/benchmark.rb'
74
+ - 'lib/expressir/commands/coverage.rb'
75
+ - 'lib/expressir/coverage.rb'
64
76
  - 'lib/expressir/express/formatter.rb'
65
77
  - 'lib/expressir/express/model_visitor.rb'
66
78
  - 'lib/expressir/express/parser.rb'
@@ -69,16 +81,18 @@ Metrics/CyclomaticComplexity:
69
81
  - 'lib/expressir/model/model_element.rb'
70
82
  - 'spec/support/model_element_helper.rb'
71
83
 
72
- # Offense count: 80
84
+ # Offense count: 99
73
85
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
74
86
  Metrics/MethodLength:
75
- Max: 44
87
+ Max: 82
76
88
 
77
- # Offense count: 35
89
+ # Offense count: 43
78
90
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
79
91
  Metrics/PerceivedComplexity:
80
92
  Exclude:
81
93
  - 'lib/expressir/benchmark.rb'
94
+ - 'lib/expressir/commands/coverage.rb'
95
+ - 'lib/expressir/coverage.rb'
82
96
  - 'lib/expressir/express/formatter.rb'
83
97
  - 'lib/expressir/express/visitor.rb'
84
98
  - 'lib/expressir/model/declarations/schema.rb'
@@ -89,6 +103,13 @@ Performance/FixedSize:
89
103
  Exclude:
90
104
  - 'lib/expressir/express/formatter.rb'
91
105
 
106
+ # Offense count: 6
107
+ # This cop supports unsafe autocorrection (--autocorrect-all).
108
+ # Configuration parameters: AllowRegexpMatch.
109
+ Performance/RedundantEqualityComparisonBlock:
110
+ Exclude:
111
+ - 'spec/expressir/coverage_spec.rb'
112
+
92
113
  # Offense count: 1
93
114
  Style/MissingRespondToMissing:
94
115
  Exclude:
data/README.adoc CHANGED
@@ -80,20 +80,31 @@ Commands:
80
80
  expressir format PATH # pretty print EXPRESS schema located at PATH
81
81
  expressir help [COMMAND] # Describe available commands or one specific command
82
82
  expressir validate *PATH # validate EXPRESS schema located at PATH
83
+ expressir coverage *PATH # List EXPRESS entities and check documentation coverage
83
84
  expressir version # Expressir Version
84
85
  ----
85
86
 
86
- === Pretty print
87
+ === Format schema
88
+
89
+ The `format` command pretty prints an EXPRESS schema, making it more readable
90
+ while preserving its structure.
87
91
 
88
92
  [source, sh]
89
93
  ----
94
+ # Pretty print a schema to stdout
90
95
  expressir format schemas/resources/action_schema/action_schema.exp
91
96
  ----
92
97
 
98
+ This command:
99
+ 1. Parses the EXPRESS schema
100
+ 2. Formats it with consistent indentation and spacing
101
+ 3. Outputs the formatted schema to stdout
102
+
93
103
  === Clean schema
94
104
 
95
- The `clean` command strips remarks and prettifies EXPRESS schemas. You can
96
- optionally save the result to a file.
105
+ The `clean` command strips remarks and prettifies EXPRESS schemas. This is
106
+ useful for removing all documentation comments while maintaining the schema's
107
+ functional definition. You can optionally save the result to a file.
97
108
 
98
109
  [source, sh]
99
110
  ----
@@ -104,6 +115,46 @@ expressir clean schemas/resources/action_schema/action_schema.exp
104
115
  expressir clean schemas/resources/action_schema/action_schema.exp --output clean_schema.exp
105
116
  ----
106
117
 
118
+ [options="header"]
119
+ |===
120
+ | Option | Description
121
+ | `--output PATH` | Path to save the cleaned schema (optional, defaults to stdout)
122
+ |===
123
+
124
+ === Validate schema
125
+
126
+ The `validate` command performs validation checks on EXPRESS schema files.
127
+
128
+ It verifies:
129
+
130
+ . That the schema can be parsed correctly
131
+ . That the schema includes a version string
132
+
133
+ [source, sh]
134
+ ----
135
+ # Validate a single schema
136
+ expressir validate schemas/resources/action_schema/action_schema.exp
137
+
138
+ # Validate multiple schemas
139
+ expressir validate schemas/resources/action_schema/action_schema.exp schemas/resources/approval_schema/approval_schema.exp
140
+ ----
141
+
142
+ The command reports any schemas that:
143
+
144
+ * Failed to parse
145
+ * Are missing a version string
146
+
147
+ If all validations pass, it will display "Validation passed for all EXPRESS schemas."
148
+
149
+ === Version
150
+
151
+ The `version` command displays the current version of the Expressir gem.
152
+
153
+ [source, sh]
154
+ ----
155
+ expressir version
156
+ ----
157
+
107
158
  === Benchmarking
108
159
 
109
160
  Expressir includes powerful benchmarking capabilities for measuring schema
@@ -181,6 +232,244 @@ The benchmark commands support several options:
181
232
  When using the `--format json` option, results will be output in JSON format,
182
233
  making it easy to parse for further analysis or visualization.
183
234
 
235
+ === Documentation coverage
236
+
237
+ Expressir can analyze EXPRESS schemas to check for documentation coverage. This helps
238
+ identify which entities are properly documented with remarks and which ones require
239
+ documentation.
240
+
241
+ ==== Analyzing documentation coverage
242
+
243
+ Use the `coverage` command to check documentation coverage of EXPRESS schemas:
244
+
245
+ [source, sh]
246
+ ----
247
+ # Analyze a single EXPRESS file
248
+ expressir coverage schemas/resources/action_schema/action_schema.exp
249
+
250
+ # Analyze multiple EXPRESS files
251
+ expressir coverage schemas/resources/action_schema/action_schema.exp schemas/resources/approval_schema/approval_schema.exp
252
+
253
+ # Analyze all EXPRESS files in a directory (recursively)
254
+ expressir coverage schemas/resources/
255
+
256
+ # Analyze files specified in a YAML file
257
+ expressir coverage schemas.yml
258
+ ----
259
+
260
+ The output shows which entities are missing documentation, calculates coverage percentages,
261
+ and provides an overall documentation coverage summary.
262
+
263
+ ==== Coverage options
264
+
265
+ The coverage command supports different output formats and exclusion options:
266
+
267
+ [options="header"]
268
+ |===
269
+ | Option | Description
270
+ | `--format text` | (Default) Display a human-readable table with coverage information
271
+ | `--format json` | Output in JSON format for programmatic processing
272
+ | `--format yaml` | Output in YAML format for programmatic processing
273
+ | `--exclude TYPES` | Comma-separated list of EXPRESS entity types to exclude from coverage analysis
274
+ |===
275
+
276
+ ==== Excluding entity types from coverage
277
+
278
+ You can exclude specific EXPRESS entity types from coverage analysis using the
279
+ `--exclude` option.
280
+
281
+ This is useful when certain entity types don't require documentation coverage,
282
+ such as TYPE entities whose descriptions are generated by template strings.
283
+
284
+ [source, sh]
285
+ ----
286
+ # Exclude TYPE entities from coverage analysis
287
+ expressir coverage --exclude=TYPE schemas/resources/action_schema/action_schema.exp
288
+
289
+ # Exclude only SELECT type definitions (useful since TYPE descriptions are often template-generated)
290
+ expressir coverage --exclude=TYPE:SELECT schemas/resources/action_schema/action_schema.exp
291
+
292
+ # Exclude multiple entity types
293
+ expressir coverage --exclude=TYPE,CONSTANT,FUNCTION schemas/resources/action_schema/action_schema.exp
294
+
295
+ # Exclude parameters and variables (often don't require individual documentation)
296
+ expressir coverage --exclude=PARAMETER,VARIABLE schemas/resources/action_schema/action_schema.exp
297
+
298
+ # Combine with output format options
299
+ expressir coverage --exclude=TYPE:SELECT --format=json schemas/resources/action_schema/action_schema.exp
300
+ ----
301
+
302
+ ==== Elements checked in documentation coverage
303
+
304
+ Expressir checks documentation coverage for all EXPRESS elements (ModelElement
305
+ subclasses), including:
306
+
307
+ Schema-level entities:
308
+
309
+ `TYPE`:: Type definitions (supports subtype exclusion, see below)
310
+ `ENTITY`:: Entity definitions
311
+ `CONSTANT`:: Constant definitions
312
+ `FUNCTION`:: Function definitions
313
+ `RULE`:: Rule definitions
314
+ `PROCEDURE`:: Procedure definitions
315
+ `SUBTYPE_CONSTRAINT`:: Subtype constraint definitions
316
+ `INTERFACE`:: Interface definitions
317
+
318
+ Nested entities within other constructs:
319
+
320
+ `PARAMETER`:: Function and procedure parameters
321
+ `VARIABLE`:: Variables within functions, rules, and procedures
322
+ `ATTRIBUTE`:: Entity attributes
323
+ `DERIVED_ATTRIBUTE`:: Derived attributes in entities
324
+ `INVERSE_ATTRIBUTE`:: Inverse attributes in entities
325
+ `UNIQUE_RULE`:: Unique rules within entities
326
+ `WHERE_RULE`:: Where rules within entities and types
327
+ `ENUMERATION_ITEM`:: Items within enumeration types
328
+ `INTERFACE_ITEM`:: Items within interfaces
329
+ `INTERFACED_ITEM`:: Interfaced items
330
+ `SCHEMA_VERSION`:: Schema version information
331
+ `SCHEMA_VERSION_ITEM`:: Schema version items
332
+
333
+ ==== TYPE subtype exclusion
334
+
335
+ For TYPE elements, you can exclude specific subtypes using the `TYPE:SUBTYPE`
336
+ syntax:
337
+
338
+ [source, sh]
339
+ ----
340
+ # Exclude only SELECT types
341
+ expressir coverage --exclude=TYPE:SELECT schemas/resources/action_schema/action_schema.exp
342
+
343
+ # Exclude multiple TYPE subtypes
344
+ expressir coverage --exclude=TYPE:SELECT,TYPE:ENUMERATION schemas/resources/action_schema/action_schema.exp
345
+ ----
346
+
347
+ Valid TYPE subtypes that can be excluded:
348
+
349
+ `AGGREGATE`:: Aggregate type
350
+ `ARRAY`:: Array type
351
+ `BAG`:: Bag type
352
+ `BINARY`:: Binary type
353
+ `BOOLEAN`:: Boolean type
354
+ `ENUMERATION`:: Enumeration type
355
+ +
356
+ [example]
357
+ ====
358
+ ----
359
+ TYPE uuid_relationship_role = ENUMERATION OF
360
+ (supersedes,
361
+ merge,
362
+ split,
363
+ derive_from,
364
+ same_as,
365
+ similar_to);
366
+ END_TYPE;
367
+ ----
368
+ ====
369
+
370
+ `GENERIC`:: Generic type
371
+ `GENERIC_ENTITY`:: Generic entity type
372
+ +
373
+ [example]
374
+ ====
375
+ ----
376
+ TYPE uuid_attribute_select = EXTENSIBLE GENERIC_ENTITY SELECT;
377
+ END_TYPE;
378
+ ----
379
+ ====
380
+
381
+ `INTEGER`:: Integer type
382
+ `LIST`:: List type
383
+ +
384
+ [example]
385
+ ====
386
+ ----
387
+ TYPE uuid_list_item = LIST [1:?] OF UNIQUE LIST [1:?] OF UNIQUE uuid_attribute_select;
388
+ END_TYPE;
389
+ ----
390
+ ====
391
+
392
+ `LOGICAL`:: Logical type
393
+ `NUMBER`:: Number type
394
+ `REAL`:: Real type
395
+ `SELECT`:: Select type
396
+ +
397
+ [example]
398
+ ====
399
+ ----
400
+ TYPE uuid_set_or_list_attribute_select = SELECT
401
+ (uuid_list_item,
402
+ uuid_set_item);
403
+ END_TYPE;
404
+ ----
405
+ ====
406
+
407
+ `SET`:: Set type
408
+ +
409
+ [example]
410
+ ====
411
+ ----
412
+ TYPE uuid_set_item = SET [1:?] OF uuid_attribute_select;
413
+ END_TYPE;
414
+ ----
415
+ ====
416
+
417
+ `STRING`::
418
+ String type
419
+ +
420
+ [example]
421
+ ====
422
+ ----
423
+ TYPE uuid = STRING (36) FIXED;
424
+ END_TYPE;
425
+ ----
426
+ ====
427
+
428
+ This is particularly useful since TYPE entities with certain subtypes (like
429
+ SELECT) often have descriptions generated by template strings and may not
430
+ require individual remark item coverage.
431
+
432
+ NOTE: ISO 10303 excludes documentation coverage for TYPE:SELECT and
433
+ TYPE:ENUMERATION.
434
+
435
+ If you specify an invalid entity type or subtype, the command will display an
436
+ error message with the list of valid options.
437
+
438
+ .Example with JSON output:
439
+ [example]
440
+ ====
441
+ [source, sh]
442
+ ----
443
+ expressir coverage schemas/resources/ --format json
444
+ ----
445
+ ====
446
+
447
+ When using JSON or YAML output formats, all file and directory paths are
448
+ displayed relative to the current working directory:
449
+
450
+ [source, yaml]
451
+ ----
452
+ - file: "schemas/resources/action_schema/action_schema.exp"
453
+ file_basename: action_schema.exp
454
+ directory: "schemas/resources/action_schema"
455
+ # ... other fields
456
+ ----
457
+
458
+ ==== Coverage output
459
+
460
+ The default text output displays:
461
+
462
+ . Directory coverage (when analyzing multiple directories)
463
+
464
+ . File coverage, showing:
465
+ ** File path
466
+ ** List of undocumented entities
467
+ ** Coverage percentage
468
+
469
+ . Overall documentation coverage statistics
470
+
471
+ This helps identify areas of your EXPRESS schemas that need documentation
472
+ improvement.
184
473
 
185
474
 
186
475
  == Usage: Ruby
@@ -318,6 +607,68 @@ schema = repo_drop.schemas.first
318
607
  schema.file = "path/to/file.exp"
319
608
  ----
320
609
 
610
+ === Documentation coverage analysis
611
+
612
+ Expressir's documentation coverage feature can be used programmatically to
613
+ analyze and report on documentation coverage of EXPRESS schemas.
614
+
615
+ [source,ruby]
616
+ ----
617
+ # Create a coverage report from a file
618
+ report = Expressir::Coverage::Report.from_file("path/to/schema.exp")
619
+
620
+ # Or create a report from a repository
621
+ repository = Expressir::Express::Parser.from_file("path/to/schema.exp")
622
+ report = Expressir::Coverage::Report.from_repository(repository)
623
+
624
+ # Access overall statistics
625
+ puts "Overall coverage: #{report.coverage_percentage}%"
626
+ puts "Total entities: #{report.total_entities.size}"
627
+ puts "Documented entities: #{report.documented_entities.size}"
628
+ puts "Undocumented entities: #{report.undocumented_entities.size}"
629
+
630
+ # Access file-level reports
631
+ report.file_reports.each do |file_report|
632
+ puts "File: #{file_report[:file]}"
633
+ puts " Coverage: #{file_report[:coverage]}%"
634
+ puts " Total entities: #{file_report[:total]}"
635
+ puts " Documented entities: #{file_report[:documented]}"
636
+ puts " Undocumented entities: #{file_report[:undocumented].join(', ')}"
637
+ end
638
+
639
+ # Access directory-level reports
640
+ report.directory_reports.each do |dir_report|
641
+ puts "Directory: #{dir_report[:directory]}"
642
+ puts " Coverage: #{dir_report[:coverage]}%"
643
+ puts " Total entities: #{dir_report[:total]}"
644
+ puts " Documented entities: #{dir_report[:documented]}"
645
+ puts " Undocumented entities: #{dir_report[:undocumented]}"
646
+ puts " Number of files: #{dir_report[:files]}"
647
+ end
648
+
649
+ # Generate a structured hash representation
650
+ report_hash = report.to_h # Contains overall, directories and files sections
651
+ ----
652
+
653
+ You can also use the core methods directly to check documentation status:
654
+
655
+ [source,ruby]
656
+ ----
657
+ # Check if an entity has documentation
658
+ schema = repository.schemas.first
659
+ entity = schema.entities.first
660
+
661
+ if Expressir::Coverage.entity_documented?(entity)
662
+ puts "Entity #{entity.id} is documented"
663
+ else
664
+ puts "Entity #{entity.id} is not documented"
665
+ end
666
+
667
+ # Find all entities in a schema
668
+ all_entities = Expressir::Coverage.find_entities(schema)
669
+ puts "Found #{all_entities.size} entities in schema #{schema.id}"
670
+ ----
671
+
321
672
 
322
673
  == Contributing
323
674
 
data/expressir.gemspec CHANGED
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency "liquid"
40
40
  spec.add_dependency "lutaml-model", "~>0.7"
41
41
  spec.add_dependency "parslet", "~> 2.0"
42
+ spec.add_dependency "ruby-progressbar", "~> 1.11"
43
+ spec.add_dependency "terminal-table", "~> 3.0"
42
44
  spec.add_dependency "thor", "~> 1.0"
43
- spec.add_dependency "zeitwerk", "~> 2.6"
44
45
  end