canon 0.1.6 → 0.1.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 (136) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +163 -67
  3. data/README.adoc +400 -7
  4. data/docs/Gemfile +9 -0
  5. data/docs/INDEX.adoc +99 -182
  6. data/docs/_config.yml +100 -0
  7. data/docs/advanced/diff-classification.adoc +547 -0
  8. data/docs/advanced/diff-pipeline.adoc +358 -0
  9. data/docs/advanced/index.adoc +214 -0
  10. data/docs/advanced/semantic-diff-report.adoc +390 -0
  11. data/docs/{VERBOSE.adoc → advanced/verbose-mode-architecture.adoc} +51 -53
  12. data/docs/features/diff-formatting/algorithm-specific-output.adoc +533 -0
  13. data/docs/{CHARACTER_VISUALIZATION.adoc → features/diff-formatting/character-visualization.adoc} +23 -62
  14. data/docs/features/diff-formatting/colors-and-symbols.adoc +606 -0
  15. data/docs/features/diff-formatting/context-and-grouping.adoc +490 -0
  16. data/docs/features/diff-formatting/display-filtering.adoc +472 -0
  17. data/docs/features/diff-formatting/index.adoc +140 -0
  18. data/docs/features/environment-configuration/index.adoc +327 -0
  19. data/docs/features/environment-configuration/override-system.adoc +436 -0
  20. data/docs/features/environment-configuration/size-limits.adoc +273 -0
  21. data/docs/features/index.adoc +173 -0
  22. data/docs/features/input-validation/index.adoc +521 -0
  23. data/docs/features/match-options/algorithm-specific-behavior.adoc +365 -0
  24. data/docs/features/match-options/html-policies.adoc +312 -0
  25. data/docs/features/match-options/index.adoc +621 -0
  26. data/docs/getting-started/index.adoc +83 -0
  27. data/docs/getting-started/quick-start.adoc +76 -0
  28. data/docs/guides/choosing-configuration.adoc +689 -0
  29. data/docs/guides/index.adoc +181 -0
  30. data/docs/{CLI.adoc → interfaces/cli/index.adoc} +18 -13
  31. data/docs/interfaces/index.adoc +101 -0
  32. data/docs/{RSPEC.adoc → interfaces/rspec/index.adoc} +242 -31
  33. data/docs/{RUBY_API.adoc → interfaces/ruby-api/index.adoc} +118 -16
  34. data/docs/lychee.toml +65 -0
  35. data/docs/reference/cli-options.adoc +418 -0
  36. data/docs/reference/environment-variables.adoc +375 -0
  37. data/docs/reference/index.adoc +204 -0
  38. data/docs/reference/options-across-interfaces.adoc +417 -0
  39. data/docs/understanding/algorithms/dom-diff.adoc +389 -0
  40. data/docs/understanding/algorithms/index.adoc +314 -0
  41. data/docs/understanding/algorithms/semantic-tree-diff.adoc +533 -0
  42. data/docs/understanding/architecture.adoc +447 -0
  43. data/docs/understanding/comparison-pipeline.adoc +317 -0
  44. data/docs/understanding/formats/html.adoc +380 -0
  45. data/docs/understanding/formats/index.adoc +261 -0
  46. data/docs/understanding/formats/json.adoc +390 -0
  47. data/docs/understanding/formats/xml.adoc +366 -0
  48. data/docs/understanding/formats/yaml.adoc +504 -0
  49. data/docs/understanding/index.adoc +130 -0
  50. data/lib/canon/cli.rb +42 -1
  51. data/lib/canon/commands/diff_command.rb +108 -23
  52. data/lib/canon/comparison/compare_profile.rb +101 -0
  53. data/lib/canon/comparison/comparison_result.rb +41 -2
  54. data/lib/canon/comparison/html_comparator.rb +292 -71
  55. data/lib/canon/comparison/html_compare_profile.rb +117 -0
  56. data/lib/canon/comparison/match_options.rb +42 -4
  57. data/lib/canon/comparison/strategies/base_match_strategy.rb +99 -0
  58. data/lib/canon/comparison/strategies/match_strategy_factory.rb +74 -0
  59. data/lib/canon/comparison/strategies/semantic_tree_match_strategy.rb +220 -0
  60. data/lib/canon/comparison/xml_comparator.rb +695 -91
  61. data/lib/canon/comparison.rb +207 -2
  62. data/lib/canon/config/env_provider.rb +71 -0
  63. data/lib/canon/config/env_schema.rb +58 -0
  64. data/lib/canon/config/override_resolver.rb +55 -0
  65. data/lib/canon/config/type_converter.rb +59 -0
  66. data/lib/canon/config.rb +158 -29
  67. data/lib/canon/data_model.rb +29 -0
  68. data/lib/canon/diff/diff_classifier.rb +74 -14
  69. data/lib/canon/diff/diff_context_builder.rb +41 -0
  70. data/lib/canon/diff/diff_line.rb +18 -2
  71. data/lib/canon/diff/diff_node.rb +18 -3
  72. data/lib/canon/diff/diff_node_mapper.rb +71 -12
  73. data/lib/canon/diff/formatting_detector.rb +53 -0
  74. data/lib/canon/diff_formatter/by_line/base_formatter.rb +60 -5
  75. data/lib/canon/diff_formatter/by_line/html_formatter.rb +68 -16
  76. data/lib/canon/diff_formatter/by_line/json_formatter.rb +0 -37
  77. data/lib/canon/diff_formatter/by_line/simple_formatter.rb +0 -42
  78. data/lib/canon/diff_formatter/by_line/xml_formatter.rb +116 -31
  79. data/lib/canon/diff_formatter/by_line/yaml_formatter.rb +0 -37
  80. data/lib/canon/diff_formatter/by_object/base_formatter.rb +126 -19
  81. data/lib/canon/diff_formatter/by_object/xml_formatter.rb +30 -1
  82. data/lib/canon/diff_formatter/debug_output.rb +7 -1
  83. data/lib/canon/diff_formatter/diff_detail_formatter.rb +674 -57
  84. data/lib/canon/diff_formatter/legend.rb +42 -0
  85. data/lib/canon/diff_formatter.rb +78 -9
  86. data/lib/canon/errors.rb +56 -0
  87. data/lib/canon/formatters/html_formatter_base.rb +35 -1
  88. data/lib/canon/formatters/json_formatter.rb +3 -0
  89. data/lib/canon/formatters/yaml_formatter.rb +3 -0
  90. data/lib/canon/html/data_model.rb +229 -0
  91. data/lib/canon/html.rb +9 -0
  92. data/lib/canon/options/cli_generator.rb +70 -0
  93. data/lib/canon/options/registry.rb +234 -0
  94. data/lib/canon/rspec_matchers.rb +34 -13
  95. data/lib/canon/tree_diff/adapters/html_adapter.rb +316 -0
  96. data/lib/canon/tree_diff/adapters/json_adapter.rb +204 -0
  97. data/lib/canon/tree_diff/adapters/xml_adapter.rb +285 -0
  98. data/lib/canon/tree_diff/adapters/yaml_adapter.rb +213 -0
  99. data/lib/canon/tree_diff/core/attribute_comparator.rb +84 -0
  100. data/lib/canon/tree_diff/core/matching.rb +241 -0
  101. data/lib/canon/tree_diff/core/node_signature.rb +164 -0
  102. data/lib/canon/tree_diff/core/node_weight.rb +135 -0
  103. data/lib/canon/tree_diff/core/tree_node.rb +450 -0
  104. data/lib/canon/tree_diff/matchers/hash_matcher.rb +258 -0
  105. data/lib/canon/tree_diff/matchers/similarity_matcher.rb +168 -0
  106. data/lib/canon/tree_diff/matchers/structural_propagator.rb +242 -0
  107. data/lib/canon/tree_diff/matchers/universal_matcher.rb +220 -0
  108. data/lib/canon/tree_diff/operation_converter.rb +631 -0
  109. data/lib/canon/tree_diff/operations/operation.rb +92 -0
  110. data/lib/canon/tree_diff/operations/operation_detector.rb +626 -0
  111. data/lib/canon/tree_diff/tree_diff_integrator.rb +140 -0
  112. data/lib/canon/tree_diff.rb +33 -0
  113. data/lib/canon/validators/json_validator.rb +3 -1
  114. data/lib/canon/validators/yaml_validator.rb +3 -1
  115. data/lib/canon/version.rb +1 -1
  116. data/lib/canon/xml/data_model.rb +22 -23
  117. data/lib/canon/xml/element_matcher.rb +128 -20
  118. data/lib/canon/xml/namespace_helper.rb +110 -0
  119. data/lib/canon.rb +3 -0
  120. metadata +81 -23
  121. data/_config.yml +0 -116
  122. data/docs/ADVANCED_TOPICS.adoc +0 -20
  123. data/docs/BASIC_USAGE.adoc +0 -16
  124. data/docs/CUSTOMIZING_BEHAVIOR.adoc +0 -19
  125. data/docs/DIFF_ARCHITECTURE.adoc +0 -435
  126. data/docs/DIFF_FORMATTING.adoc +0 -540
  127. data/docs/FORMATS.adoc +0 -447
  128. data/docs/INPUT_VALIDATION.adoc +0 -477
  129. data/docs/MATCH_ARCHITECTURE.adoc +0 -463
  130. data/docs/MATCH_OPTIONS.adoc +0 -719
  131. data/docs/MODES.adoc +0 -432
  132. data/docs/NORMATIVE_INFORMATIVE_DIFFS.adoc +0 -219
  133. data/docs/OPTIONS.adoc +0 -1387
  134. data/docs/PREPROCESSING.adoc +0 -491
  135. data/docs/SEMANTIC_DIFF_REPORT.adoc +0 -528
  136. data/docs/UNDERSTANDING_CANON.adoc +0 -17
@@ -0,0 +1,418 @@
1
+ ---
2
+ title: CLI Options Reference
3
+ parent: Reference
4
+ nav_order: 1
5
+ ---
6
+ = CLI options reference
7
+ :toc:
8
+ :toclevels: 3
9
+
10
+ == Purpose
11
+
12
+ This page provides a complete reference for all Canon command-line interface options organized by command and function.
13
+
14
+ For conceptual understanding, see link:../understanding/comparison-pipeline.adoc[Comparison Pipeline].
15
+
16
+ For choosing the right configuration, see link:../guides/choosing-configuration.adoc[Choosing Configuration].
17
+
18
+ == Command syntax
19
+
20
+ [source,bash]
21
+ ----
22
+ canon <command> [arguments] [options]
23
+ ----
24
+
25
+ == Commands
26
+
27
+ === `format` command
28
+
29
+ Format a document using canonicalization rules.
30
+
31
+ [source,bash]
32
+ ----
33
+ canon format FILE [OPTIONS]
34
+ ----
35
+
36
+ **Options**:
37
+ [cols="2,3"]
38
+ |===
39
+ |Option |Description
40
+
41
+ |`--format FORMAT`
42
+ |Specify format: xml, html, json, yaml
43
+
44
+ |`--output FILE`
45
+ |Write output to file (default: stdout)
46
+
47
+ |`--preprocessing MODE`
48
+ |Apply preprocessing: none, c14n, normalize, format
49
+ |===
50
+
51
+ === `diff` command
52
+
53
+ Compare two documents and show differences.
54
+
55
+ [source,bash]
56
+ ----
57
+ canon diff FILE1 FILE2 [OPTIONS]
58
+ ----
59
+
60
+ This command supports all 4 layers of Canon's architecture. See sections below for layer-specific options.
61
+
62
+ == Layer 1: Preprocessing options
63
+
64
+ Controls document normalization before comparison.
65
+
66
+ [cols="2,3"]
67
+ |===
68
+ |Option |Description
69
+
70
+ |`--preprocessing MODE`
71
+ |Preprocessing mode: `none` (default), `c14n`, `normalize`, `format`
72
+ |===
73
+
74
+ **Modes**:
75
+ * `none` - No preprocessing (compare as-is)
76
+ * `c14n` - Canonicalize (XML C14N, JSON/YAML sorted keys)
77
+ * `normalize` - Normalize whitespace throughout
78
+ * `format` - Pretty-print with standard formatting
79
+
80
+ See link:../features/preprocessing/[Preprocessing] for details.
81
+
82
+ == Layer 2: Algorithm options
83
+
84
+ Controls which comparison algorithm to use.
85
+
86
+ [cols="2,3"]
87
+ |===
88
+ |Option |Description
89
+
90
+ |`--diff-algorithm ALGORITHM`
91
+ |Algorithm: `dom` (default), `semantic`
92
+ |===
93
+
94
+ **Algorithms**:
95
+ * `dom` - Fast, stable, positional comparison
96
+ * `semantic` - Slower, intelligent, detects moves
97
+
98
+ See link:../understanding/algorithms/[Algorithms] for details.
99
+
100
+ == Layer 3: Match options
101
+
102
+ Controls what to compare and how strictly.
103
+
104
+ === Match profiles
105
+
106
+ [cols="2,3"]
107
+ |===
108
+ |Option |Description
109
+
110
+ |`--match-profile PROFILE`
111
+ |Profile: `strict`, `rendered`, `spec_friendly`, `content_only`
112
+ |===
113
+
114
+ **Profiles**:
115
+ * `strict` - Exact matching (all dimensions strict)
116
+ * `rendered` - Browser rendering (ignores formatting)
117
+ * `spec_friendly` - Test-friendly (most common)
118
+ * `content_only` - Maximum tolerance
119
+
120
+ === Match dimensions
121
+
122
+ Individual dimension control (overrides profile settings):
123
+
124
+ [cols="2,3"]
125
+ |===
126
+ |Option |Description
127
+
128
+ |`--text-content BEHAVIOR`
129
+ |Text content: `strict`, `normalize`, `ignore`
130
+
131
+ |`--structural-whitespace BEHAVIOR`
132
+ |Structural whitespace: `strict`, `normalize`, `ignore`
133
+
134
+ |`--attribute-whitespace BEHAVIOR`
135
+ |Attribute whitespace (XML/HTML): `strict`, `normalize`, `ignore`
136
+
137
+ |`--attribute-order BEHAVIOR`
138
+ |Attribute order (XML/HTML): `strict`, `ignore`
139
+
140
+ |`--attribute-values BEHAVIOR`
141
+ |Attribute values (XML/HTML): `strict`, `normalize`, `ignore`
142
+
143
+ |`--key-order BEHAVIOR`
144
+ |Key order (JSON/YAML): `strict`, `ignore`
145
+
146
+ |`--comments BEHAVIOR`
147
+ |Comments: `strict`, `normalize`, `ignore`
148
+ |===
149
+
150
+ See link:../features/match-options/[Match Options] for details.
151
+
152
+ == Layer 4: Diff formatting options
153
+
154
+ Controls how differences are displayed.
155
+
156
+ === Diff mode
157
+
158
+ [cols="2,3"]
159
+ |===
160
+ |Option |Description
161
+
162
+ |`--diff-mode MODE`
163
+ |Mode: `by_line` (default for HTML), `by_object` (default for XML/JSON/YAML)
164
+ |===
165
+
166
+ **Modes**:
167
+ * `by_line` - Traditional line-by-line diff
168
+ * `by_object` - Tree-based semantic diff
169
+
170
+ === Display options
171
+
172
+ [cols="2,3"]
173
+ |===
174
+ |Option |Description
175
+
176
+ |`--verbose`, `-v`
177
+ |Show configuration tables and detailed information (diffs always shown when files differ)
178
+
179
+ |`--color`, `--no-color`
180
+ |Enable/disable colored output (default: enabled)
181
+
182
+ |`--context-lines N`
183
+ |Lines of context around changes (default: 3)
184
+
185
+ |`--diff-grouping-lines N`
186
+ |Group changes within N lines (default: nil)
187
+
188
+ |`--show-legend`
189
+ |Display legend for symbols (default: true with verbose)
190
+
191
+ |`--show-diffs MODE`
192
+ |Filter displayed differences: `all` (default), `normative`, `informative`
193
+ |===
194
+
195
+ See link:../features/diff-formatting/[Diff Formatting] for details.
196
+
197
+ == Format specification options
198
+
199
+ [cols="2,3"]
200
+ |===
201
+ |Option |Description
202
+
203
+ |`--format FORMAT`
204
+ |Format for both files: `xml`, `html`, `json`, `yaml`
205
+
206
+ |`--format1 FORMAT`
207
+ |Format of first file (overrides --format)
208
+
209
+ |`--format2 FORMAT`
210
+ |Format of second file (overrides --format)
211
+ |===
212
+
213
+ == General options
214
+
215
+ [cols="2,3"]
216
+ |===
217
+ |Option |Description
218
+
219
+ |`--help`, `-h`
220
+ |Show help message
221
+
222
+ |`--version`, `-V`
223
+ |Show version
224
+
225
+ |`--debug`
226
+ |Enable debug output
227
+ |===
228
+
229
+ == Environment variables
230
+
231
+ [cols="2,3"]
232
+ |===
233
+ |Variable |Description
234
+
235
+ |`CANON_VERBOSE`
236
+ |Set to `1` to enable detailed option tables in verbose mode
237
+
238
+ |`NO_COLOR`
239
+ |Set to disable colored output (overrides --color)
240
+ |===
241
+
242
+ == Complete examples
243
+
244
+ === Example 1: Basic comparison
245
+
246
+ [source,bash]
247
+ ----
248
+ canon diff file1.xml file2.xml --verbose
249
+ ----
250
+
251
+ Uses all defaults:
252
+ * Layer 1: No preprocessing
253
+ * Layer 2: DOM algorithm
254
+ * Layer 3: Format defaults (XML strict matching)
255
+ * Layer 4: by_object mode with colors
256
+
257
+ === Example 2: Test-friendly comparison
258
+
259
+ [source,bash]
260
+ ----
261
+ canon diff expected.xml actual.xml \
262
+ --match-profile spec_friendly \
263
+ --verbose
264
+ ----
265
+
266
+ Uses:
267
+ * Layer 1: Normalize preprocessing (from profile)
268
+ * Layer 2: DOM algorithm (default)
269
+ * Layer 3: spec_friendly profile
270
+ * Layer 4: by_object mode with colors
271
+
272
+ === Example 3: Semantic analysis
273
+
274
+ [source,bash]
275
+ ----
276
+ canon diff old.xml new.xml \
277
+ --diff-algorithm semantic \
278
+ --match-profile spec_friendly \
279
+ --diff-mode by_object \
280
+ --verbose
281
+ ----
282
+
283
+ Uses:
284
+ * Layer 1: Normalize preprocessing
285
+ * Layer 2: Semantic algorithm (detects moves)
286
+ * Layer 3: spec_friendly matching
287
+ * Layer 4: by_object mode (shows operations)
288
+
289
+ === Example 4: Exact matching with context
290
+
291
+ [source,bash]
292
+ ----
293
+ canon diff file1.json file2.json \
294
+ --match-profile strict \
295
+ --diff-mode by_line \
296
+ --context-lines 5 \
297
+ --verbose
298
+ ----
299
+
300
+ Uses:
301
+ * Layer 1: No preprocessing
302
+ * Layer 2: DOM algorithm
303
+ * Layer 3: strict profile (exact matching)
304
+ * Layer 4: by_line mode with 5 context lines
305
+
306
+ === Example 5: Custom dimension control
307
+
308
+ [source,bash]
309
+ ----
310
+ canon diff page1.html page2.html \
311
+ --preprocessing normalize \
312
+ --text-content normalize \
313
+ --structural-whitespace ignore \
314
+ --attribute-order ignore \
315
+ --comments ignore \
316
+ --diff-mode by_line \
317
+ --verbose
318
+ ----
319
+
320
+ Uses:
321
+ * Layer 1: Normalize preprocessing
322
+ * Layer 2: DOM algorithm
323
+ * Layer 3: Custom dimensions
324
+ * Layer 4: by_line mode
325
+
326
+ === Example 6: With CANON_VERBOSE tables
327
+
328
+ [source,bash]
329
+ ----
330
+ CANON_VERBOSE=1 canon diff file1.xml file2.xml \
331
+ --match-profile spec_friendly \
332
+ --verbose
333
+ ----
334
+
335
+ Shows:
336
+ * CANON VERBOSE option tables (Tier 1)
337
+ * Semantic Diff Report (Tier 2)
338
+ * Detailed diff (Tier 3)
339
+
340
+ == Configuration patterns
341
+
342
+ === Fast comparison (default)
343
+
344
+ [source,bash]
345
+ ----
346
+ canon diff file1.xml file2.xml
347
+ ----
348
+
349
+ * Minimal processing
350
+ * Fast DOM algorithm
351
+ * Format defaults
352
+ * No verbose output
353
+
354
+ === Test scenario
355
+
356
+ [source,bash]
357
+ ----
358
+ canon diff expected.xml actual.xml \
359
+ --match-profile spec_friendly \
360
+ --verbose
361
+ ----
362
+
363
+ * Ignores formatting
364
+ * Shows actionable diffs
365
+ * Most common for testing
366
+
367
+ === Debugging differences
368
+
369
+ [source,bash]
370
+ ----
371
+ CANON_VERBOSE=1 canon diff file1.xml file2.xml \
372
+ --diff-algorithm semantic \
373
+ --diff-mode by_object \
374
+ --verbose
375
+ ----
376
+
377
+ * Full option tables
378
+ * Semantic analysis
379
+ * Operation-based output
380
+ * Maximum information
381
+
382
+ === Browser-equivalent HTML
383
+
384
+ [source,bash]
385
+ ----
386
+ canon diff page1.html page2.html \
387
+ --match-profile rendered \
388
+ --verbose
389
+ ----
390
+
391
+ * HTML rendering simulation
392
+ * Ignores formatting
393
+ * Attribute order ignored
394
+
395
+ == Exit codes
396
+
397
+ [cols="1,3"]
398
+ |===
399
+ |Code |Meaning
400
+
401
+ |`0`
402
+ |Documents are equivalent
403
+
404
+ |`1`
405
+ |Documents differ
406
+
407
+ |`2`
408
+ |Error occurred (invalid arguments, file not found, etc.)
409
+ |===
410
+
411
+ == See also
412
+
413
+ * link:../understanding/comparison-pipeline.adoc[Comparison Pipeline] - 4-layer architecture
414
+ * link:../guides/choosing-configuration.adoc[Choosing Configuration] - Decision guide
415
+ * link:../features/match-options/[Match Options] - Dimension reference
416
+ * link:../features/diff-formatting/[Diff Formatting] - Output customization
417
+ * link:../interfaces/cli/[CLI Interface] - Command-line usage guide
418
+ * link:../interfaces/ruby-api/[Ruby API] - Programmatic usage