expressir 2.1.29 → 2.1.31

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +98 -0
  3. data/.github/workflows/links.yml +100 -0
  4. data/.github/workflows/rake.yml +4 -0
  5. data/.github/workflows/release.yml +5 -0
  6. data/.github/workflows/validate_schemas.yml +1 -1
  7. data/.gitignore +3 -0
  8. data/.rubocop.yml +1 -1
  9. data/.rubocop_todo.yml +209 -55
  10. data/Gemfile +2 -1
  11. data/README.adoc +650 -83
  12. data/docs/Gemfile +12 -0
  13. data/docs/_config.yml +141 -0
  14. data/docs/_guides/changes/changes-format.adoc +778 -0
  15. data/docs/_guides/changes/importing-eengine.adoc +898 -0
  16. data/docs/_guides/changes/index.adoc +396 -0
  17. data/docs/_guides/changes/programmatic-usage.adoc +1038 -0
  18. data/docs/_guides/changes/validating-changes.adoc +681 -0
  19. data/docs/_guides/cli/benchmark-performance.adoc +834 -0
  20. data/docs/_guides/cli/coverage-analysis.adoc +921 -0
  21. data/docs/_guides/cli/format-schemas.adoc +547 -0
  22. data/docs/_guides/cli/index.adoc +8 -0
  23. data/docs/_guides/cli/managing-changes.adoc +927 -0
  24. data/docs/_guides/cli/validate-ascii.adoc +645 -0
  25. data/docs/_guides/cli/validate-schemas.adoc +534 -0
  26. data/docs/_guides/index.adoc +165 -0
  27. data/docs/_guides/ler/creating-packages.adoc +664 -0
  28. data/docs/_guides/ler/index.adoc +305 -0
  29. data/docs/_guides/ler/loading-packages.adoc +707 -0
  30. data/docs/_guides/ler/package-formats.adoc +748 -0
  31. data/docs/_guides/ler/querying-packages.adoc +826 -0
  32. data/docs/_guides/ler/validating-packages.adoc +750 -0
  33. data/docs/_guides/liquid/basic-templates.adoc +813 -0
  34. data/docs/_guides/liquid/documentation-generation.adoc +1042 -0
  35. data/docs/_guides/liquid/drops-reference.adoc +829 -0
  36. data/docs/_guides/liquid/filters-and-tags.adoc +912 -0
  37. data/docs/_guides/liquid/index.adoc +468 -0
  38. data/docs/_guides/manifests/creating-manifests.adoc +483 -0
  39. data/docs/_guides/manifests/index.adoc +307 -0
  40. data/docs/_guides/manifests/resolving-manifests.adoc +557 -0
  41. data/docs/_guides/manifests/validating-manifests.adoc +713 -0
  42. data/docs/_guides/ruby-api/formatting-schemas.adoc +605 -0
  43. data/docs/_guides/ruby-api/index.adoc +257 -0
  44. data/docs/_guides/ruby-api/parsing-files.adoc +421 -0
  45. data/docs/_guides/ruby-api/search-engine.adoc +609 -0
  46. data/docs/_guides/ruby-api/working-with-repository.adoc +577 -0
  47. data/docs/_pages/data-model.adoc +665 -0
  48. data/docs/_pages/express-language.adoc +506 -0
  49. data/docs/_pages/getting-started.adoc +414 -0
  50. data/docs/_pages/index.adoc +116 -0
  51. data/docs/_pages/introduction.adoc +256 -0
  52. data/docs/_pages/ler-packages.adoc +837 -0
  53. data/docs/_pages/parsers.adoc +683 -0
  54. data/docs/_pages/schema-manifests.adoc +431 -0
  55. data/docs/_references/index.adoc +228 -0
  56. data/docs/_tutorials/creating-ler-package.adoc +735 -0
  57. data/docs/_tutorials/documentation-coverage.adoc +795 -0
  58. data/docs/_tutorials/index.adoc +221 -0
  59. data/docs/_tutorials/liquid-templates.adoc +806 -0
  60. data/docs/_tutorials/parsing-your-first-schema.adoc +522 -0
  61. data/docs/_tutorials/querying-schemas.adoc +751 -0
  62. data/docs/_tutorials/working-with-multiple-schemas.adoc +676 -0
  63. data/docs/index.adoc +242 -0
  64. data/docs/lychee.toml +84 -0
  65. data/examples/demo_ler_usage.sh +86 -0
  66. data/examples/ler/README.md +111 -0
  67. data/examples/ler/simple_example.ler +0 -0
  68. data/examples/ler/simple_schema.exp +33 -0
  69. data/examples/ler_build.rb +75 -0
  70. data/examples/ler_cli.rb +79 -0
  71. data/examples/ler_demo_complete.rb +276 -0
  72. data/examples/ler_query.rb +91 -0
  73. data/examples/ler_query_examples.rb +305 -0
  74. data/examples/ler_stats.rb +81 -0
  75. data/examples/phase3_demo.rb +159 -0
  76. data/examples/query_demo_simple.rb +131 -0
  77. data/expressir.gemspec +2 -0
  78. data/lib/expressir/changes/schema_change.rb +32 -22
  79. data/lib/expressir/changes/{edition_change.rb → version_change.rb} +3 -3
  80. data/lib/expressir/cli.rb +12 -4
  81. data/lib/expressir/commands/changes_import_eengine.rb +2 -2
  82. data/lib/expressir/commands/changes_validate.rb +1 -1
  83. data/lib/expressir/commands/manifest.rb +427 -0
  84. data/lib/expressir/commands/package.rb +1274 -0
  85. data/lib/expressir/commands/validate.rb +70 -37
  86. data/lib/expressir/commands/validate_ascii.rb +607 -0
  87. data/lib/expressir/commands/validate_load.rb +88 -0
  88. data/lib/expressir/express/formatter.rb +5 -1
  89. data/lib/expressir/express/formatters/remark_item_formatter.rb +25 -0
  90. data/lib/expressir/express/parser.rb +33 -0
  91. data/lib/expressir/manifest/resolver.rb +213 -0
  92. data/lib/expressir/manifest/validator.rb +195 -0
  93. data/lib/expressir/model/declarations/entity.rb +6 -0
  94. data/lib/expressir/model/dependency_resolver.rb +270 -0
  95. data/lib/expressir/model/indexes/entity_index.rb +103 -0
  96. data/lib/expressir/model/indexes/reference_index.rb +148 -0
  97. data/lib/expressir/model/indexes/type_index.rb +149 -0
  98. data/lib/expressir/model/interface_validator.rb +384 -0
  99. data/lib/expressir/model/repository.rb +400 -5
  100. data/lib/expressir/model/repository_validator.rb +295 -0
  101. data/lib/expressir/model/search_engine.rb +525 -0
  102. data/lib/expressir/model.rb +4 -94
  103. data/lib/expressir/package/builder.rb +200 -0
  104. data/lib/expressir/package/metadata.rb +81 -0
  105. data/lib/expressir/package/reader.rb +165 -0
  106. data/lib/expressir/schema_manifest.rb +11 -1
  107. data/lib/expressir/version.rb +1 -1
  108. data/lib/expressir.rb +16 -3
  109. metadata +115 -5
  110. data/docs/benchmarking.adoc +0 -107
  111. data/docs/liquid_drops.adoc +0 -1547
@@ -0,0 +1,547 @@
1
+ ---
2
+ title: Format Schemas
3
+ parent: CLI Guides
4
+ grand_parent: Guides
5
+ nav_order: 2
6
+ ---
7
+
8
+ == Format Schemas
9
+
10
+ === Purpose
11
+
12
+ The [`format`](../../../exe/expressir:1) command pretty-prints EXPRESS schemas with consistent indentation, spacing, and structure. This makes schemas more readable and ensures consistent formatting across projects.
13
+
14
+ === References
15
+
16
+ * link:../../tutorials/parsing-your-first-schema.html[Tutorial: Parsing Your First Schema]
17
+ * link:../../pages/parsers.html[Parsers Documentation]
18
+ * link:validate-schemas.html[Validate Schemas]
19
+
20
+ === Concepts
21
+
22
+ Pretty-printing:: Reformatting code with consistent style without changing semantics
23
+ Schema formatting:: Apply EXPRESS language formatting conventions
24
+ Idempotent:: Running format multiple times produces the same result
25
+
26
+ === Basic Usage
27
+
28
+ ==== Format to stdout
29
+
30
+ [source,bash]
31
+ ----
32
+ expressir format schema.exp
33
+ ----
34
+
35
+ The formatted schema is printed to stdout, leaving the original file unchanged.
36
+
37
+ ==== Save to File
38
+
39
+ [source,bash]
40
+ ----
41
+ # Using output redirection
42
+ expressir format schema.exp > formatted.exp
43
+
44
+ # Using --output flag
45
+ expressir format schema.exp --output formatted.exp
46
+
47
+ # In-place formatting
48
+ expressir format schema.exp --output schema.exp
49
+ ----
50
+
51
+ ==== Format Multiple Files
52
+
53
+ [source,bash]
54
+ ----
55
+ # Explicit files
56
+ expressir format schema1.exp schema2.exp schema3.exp
57
+
58
+ # Using wildcards
59
+ expressir format schemas/*.exp
60
+
61
+ # Process all exp files
62
+ expressir format **/*.exp
63
+ ----
64
+
65
+ === Command Options
66
+
67
+ ==== Available Options
68
+
69
+ [options="header"]
70
+ |===
71
+ | Option | Description | Default
72
+
73
+ | `--output PATH`, `-o PATH`
74
+ | Save formatted output to file
75
+ | stdout
76
+
77
+ | `--verbose`
78
+ | Show detailed processing information
79
+ | false
80
+
81
+ | `--help`, `-h`
82
+ | Display help message
83
+ | -
84
+ |===
85
+
86
+ ==== Output Option
87
+
88
+ [source,bash]
89
+ ----
90
+ # Save to specific file
91
+ expressir format schema.exp --output formatted.exp
92
+
93
+ # Short form
94
+ expressir format schema.exp -o formatted.exp
95
+
96
+ # In-place (overwrites original)
97
+ expressir format schema.exp -o schema.exp
98
+ ----
99
+
100
+ ==== Verbose Option
101
+
102
+ [source,bash]
103
+ ----
104
+ # Show processing details
105
+ expressir format schema.exp --verbose
106
+ ----
107
+
108
+ Output:
109
+ [source]
110
+ ----
111
+ Parsing: schema.exp
112
+ Schema: example_schema
113
+ Entities: 5
114
+ Types: 3
115
+ Functions: 2
116
+ Formatting complete
117
+ ----
118
+
119
+ === Formatting Rules
120
+
121
+ ==== Indentation
122
+
123
+ * **Keywords**: Flush left
124
+ * **Declarations**: 2 spaces per level
125
+ * **Nested blocks**: Additional 2 spaces
126
+
127
+ Example:
128
+
129
+ [source,express]
130
+ ----
131
+ SCHEMA example_schema;
132
+
133
+ TYPE label = STRING;
134
+ END_TYPE;
135
+
136
+ ENTITY person;
137
+ name : label;
138
+ INVERSE
139
+ employed_by : SET [0:1] OF organization FOR employees;
140
+ END_ENTITY;
141
+
142
+ END_SCHEMA;
143
+ ----
144
+
145
+ ==== Spacing
146
+
147
+ * **After keywords**: One space
148
+ * **Before colons**: One space
149
+ * **Around operators**: One space each side
150
+ * **Empty lines**: Between major declarations
151
+
152
+ Example:
153
+
154
+ [source,express]
155
+ ----
156
+ ENTITY product;
157
+ id : identifier;
158
+ name : label;
159
+ price : REAL;
160
+ WHERE
161
+ WR1: price > 0.0;
162
+ END_ENTITY;
163
+ ----
164
+
165
+ ==== Case Preservation
166
+
167
+ Keywords and identifiers maintain their original case:
168
+
169
+ [source,express]
170
+ ----
171
+ ENTITY Person; (* Capital P preserved *)
172
+ Name : STRING; (* Capital N preserved *)
173
+ END_ENTITY;
174
+ ----
175
+
176
+ ==== Comment Handling
177
+
178
+ Remarks are preserved in their original positions:
179
+
180
+ [source,express]
181
+ ----
182
+ (* Entity-level remark *)
183
+ ENTITY person;
184
+ (* Attribute remark *)
185
+ name : STRING;
186
+ END_ENTITY;
187
+ ----
188
+
189
+ === Use Cases
190
+
191
+ ==== Code Review Preparation
192
+
193
+ [source,bash]
194
+ ----
195
+ # Format before committing
196
+ expressir format src/schemas/*.exp --output formatted/
197
+
198
+ # Compare with original
199
+ diff -u src/schemas/ formatted/
200
+
201
+ # If acceptable, replace
202
+ mv formatted/* src/schemas/
203
+ ----
204
+
205
+ ==== Standardize Project Formatting
206
+
207
+ [source,bash]
208
+ ----
209
+ #!/bin/bash
210
+ # format-all.sh
211
+
212
+ echo "Formatting all schemas..."
213
+
214
+ for file in schemas/**/*.exp; do
215
+ echo " Processing: $file"
216
+ expressir format "$file" --output "$file"
217
+ done
218
+
219
+ echo "Done!"
220
+ ----
221
+
222
+ ==== Pre-commit Hook
223
+
224
+ Create `.git/hooks/pre-commit`:
225
+
226
+ [source,bash]
227
+ ----
228
+ #!/bin/bash
229
+
230
+ # Get staged .exp files
231
+ FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.exp$')
232
+
233
+ if [ -z "$FILES" ]; then
234
+ exit 0
235
+ fi
236
+
237
+ echo "Formatting EXPRESS files..."
238
+
239
+ for file in $FILES; do
240
+ expressir format "$file" --output "$file"
241
+ git add "$file"
242
+ done
243
+
244
+ echo "Formatting complete"
245
+ ----
246
+
247
+ Make it executable:
248
+ [source,bash]
249
+ ----
250
+ chmod +x .git/hooks/pre-commit
251
+ ----
252
+
253
+ ==== CI/CD Formatting Check
254
+
255
+ [source,bash]
256
+ ----
257
+ #!/bin/bash
258
+ # check-formatting.sh
259
+
260
+ UNFORMATTED=()
261
+
262
+ for file in schemas/*.exp; do
263
+ # Format to temp file
264
+ expressir format "$file" > /tmp/formatted.exp
265
+
266
+ # Compare with original
267
+ if ! diff -q "$file" /tmp/formatted.exp > /dev/null; then
268
+ UNFORMATTED+=("$file")
269
+ fi
270
+ done
271
+
272
+ if [ ${#UNFORMATTED[@]} -gt 0 ]; then
273
+ echo "❌ The following files need formatting:"
274
+ printf ' %s\n' "${UNFORMATTED[@]}"
275
+ exit 1
276
+ fi
277
+
278
+ echo "✓ All files properly formatted"
279
+ ----
280
+
281
+ ==== Batch Processing with Verification
282
+
283
+ [source,bash]
284
+ ----
285
+ #!/bin/bash
286
+
287
+ for file in schemas/*.exp; do
288
+ echo "Processing: $file"
289
+
290
+ # Create backup
291
+ cp "$file" "$file.bak"
292
+
293
+ # Format
294
+ if expressir format "$file" --output "$file"; then
295
+ echo " ✓ Formatted successfully"
296
+ rm "$file.bak"
297
+ else
298
+ echo " ✗ Error formatting, restoring backup"
299
+ mv "$file.bak" "$file"
300
+ fi
301
+ done
302
+ ----
303
+
304
+ === Formatting Workflow
305
+
306
+ ==== Development Workflow
307
+
308
+ [source,bash]
309
+ ----
310
+ # 1. Edit schema
311
+ vim schema.exp
312
+
313
+ # 2. Format
314
+ expressir format schema.exp --output schema.exp
315
+
316
+ # 3. Validate
317
+ expressir validate schema.exp
318
+
319
+ # 4. Commit
320
+ git add schema.exp
321
+ git commit -m "Update schema"
322
+ ----
323
+
324
+ ==== Team Standardization
325
+
326
+ [source,bash]
327
+ ----
328
+ # 1. Format entire project
329
+ find schemas -name '*.exp' -exec expressir format {} -o {} \;
330
+
331
+ # 2. Verify all formats
332
+ ./scripts/check-formatting.sh
333
+
334
+ # 3. Commit standardized formatting
335
+ git add schemas/
336
+ git commit -m "Standardize schema formatting"
337
+ ----
338
+
339
+ === Common Patterns
340
+
341
+ ==== Backup Before Formatting
342
+
343
+ [source,bash]
344
+ ----
345
+ # Create backup
346
+ cp schema.exp schema.exp.bak
347
+
348
+ # Format in-place
349
+ expressir format schema.exp -o schema.exp
350
+
351
+ # If satisfied, remove backup
352
+ rm schema.exp.bak
353
+ ----
354
+
355
+ ==== Format and Compare
356
+
357
+ [source,bash]
358
+ ----
359
+ # Format to temp file
360
+ expressir format schema.exp > formatted.exp
361
+
362
+ # Show differences
363
+ diff -u schema.exp formatted.exp
364
+
365
+ # Apply if acceptable
366
+ mv formatted.exp schema.exp
367
+ ----
368
+
369
+ ==== Pipeline Processing
370
+
371
+ [source,bash]
372
+ ----
373
+ # Format, then validate, then check coverage
374
+ expressir format schema.exp | \
375
+ tee formatted.exp | \
376
+ expressir validate && \
377
+ expressir coverage formatted.exp
378
+ ----
379
+
380
+ === Error Handling
381
+
382
+ ==== Invalid Syntax
383
+
384
+ If schema has syntax errors, formatting will fail:
385
+
386
+ [source,bash]
387
+ ----
388
+ $ expressir format invalid.exp
389
+ Error: Failed to parse invalid.exp
390
+ Expected ';' at line 10, column 5
391
+ ----
392
+
393
+ **Solution**: Fix syntax errors first.
394
+
395
+ ==== File Not Found
396
+
397
+ [source,bash]
398
+ ----
399
+ $ expressir format missing.exp
400
+ Error: File not found: missing.exp
401
+ ----
402
+
403
+ **Solution**: Check file path and name.
404
+
405
+ ==== Permission Denied
406
+
407
+ [source,bash]
408
+ ----
409
+ $ expressir format schema.exp -o /root/output.exp
410
+ Error: Permission denied: /root/output.exp
411
+ ----
412
+
413
+ **Solution**: Use writable output location.
414
+
415
+ === Best Practices
416
+
417
+ **Always Validate After Formatting**::
418
+ Ensure formatting didn't introduce issues
419
+ +
420
+ [source,bash]
421
+ ----
422
+ expressir format schema.exp -o schema.exp && expressir validate schema.exp
423
+ ----
424
+
425
+ **Use Version Control**::
426
+ Commit before and after formatting for safety
427
+
428
+ **Automate Formatting**::
429
+ Add to pre-commit hooks or CI/CD
430
+
431
+ **Format Consistently**::
432
+ Format all project files at once for consistency
433
+
434
+ **Test Before Rollout**::
435
+ Test formatting on sample files first
436
+
437
+ === Troubleshooting
438
+
439
+ ==== Formatting Changes Semantics
440
+
441
+ **Problem**: Formatted schema behaves differently
442
+
443
+ **Cause**: Rare parser bug or edge case
444
+
445
+ **Solution**:
446
+ 1. Report issue to Expressir GitHub
447
+ 2. Revert to original file
448
+ 3. Use manual formatting
449
+
450
+ ==== Large Files Take Too Long
451
+
452
+ **Problem**: Formatting very large schemas is slow
453
+
454
+ **Solutions**:
455
+ * Process files individually
456
+ * Use more powerful hardware
457
+ * Consider splitting large schemas
458
+
459
+ ==== Inconsistent Results
460
+
461
+ **Problem**: Multiple format runs produce different output
462
+
463
+ **Cause**: Non-deterministic formatting (shouldn't happen)
464
+
465
+ **Solution**:
466
+ 1. Update to latest Expressir version
467
+ 2. Report bug if persists
468
+
469
+ === Integration Examples
470
+
471
+ ==== GitHub Actions
472
+
473
+ [source,yaml]
474
+ ----
475
+ name: Format Check
476
+
477
+ on: [push, pull_request]
478
+
479
+ jobs:
480
+ format:
481
+ runs-on: ubuntu-latest
482
+ steps:
483
+ - uses: actions/checkout@v2
484
+
485
+ - name: Install Expressir
486
+ run: gem install expressir
487
+
488
+ - name: Check Formatting
489
+ run: |
490
+ for file in schemas/*.exp; do
491
+ expressir format "$file" > formatted.exp
492
+ if ! diff -q "$file" formatted.exp; then
493
+ echo "❌ $file needs formatting"
494
+ exit 1
495
+ fi
496
+ done
497
+ echo "✓ All files properly formatted"
498
+ ----
499
+
500
+ ==== Makefile Integration
501
+
502
+ [source,makefile]
503
+ ----
504
+ .PHONY: format format-check
505
+
506
+ format:
507
+ @echo "Formatting schemas..."
508
+ @find schemas -name '*.exp' -exec expressir format {} -o {} \;
509
+ @echo "Done"
510
+
511
+ format-check:
512
+ @echo "Checking formatting..."
513
+ @./scripts/check-formatting.sh
514
+ ----
515
+
516
+ Usage:
517
+ [source,bash]
518
+ ----
519
+ make format # Format all schemas
520
+ make format-check # Verify formatting
521
+ ----
522
+
523
+ === Next Steps
524
+
525
+ **Related Commands**::
526
+ * link:validate-schemas.html[Validate Schemas] - Check syntax and structure
527
+ * link:coverage-analysis.html[Coverage Analysis] - Check documentation
528
+
529
+ **Advanced Topics**::
530
+ * link:../ruby-api/formatting-schemas.html[Ruby API Formatting] - Programmatic formatting
531
+ * Custom formatters for specific standards
532
+
533
+ **Automation**::
534
+ * link:../deployment/ci-cd-setup.html[CI/CD Setup] - Automated workflows
535
+ * Pre-commit hooks setup
536
+
537
+ === Summary
538
+
539
+ The format command:
540
+
541
+ * ✅ Pretty-prints EXPRESS schemas consistently
542
+ * ✅ Preserves semantics while improving readability
543
+ * ✅ Supports batch processing and automation
544
+ * ✅ Integrates easily with CI/CD workflows
545
+ * ✅ Helps maintain code quality standards
546
+
547
+ Use formatting regularly to maintain clean, readable schemas across your project.
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: CLI Guides
3
+ parent: Overview
4
+ nav_order: 2
5
+ has_children: true
6
+ ---
7
+
8
+ == Expressir CLI Guides