canon 0.1.5 → 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,375 @@
1
+ ---
2
+ layout: default
3
+ title: Environment Variables
4
+ parent: Reference
5
+ nav_order: 4
6
+ ---
7
+
8
+ :toc:
9
+ :toclevels: 3
10
+
11
+ == Purpose
12
+
13
+ Canon provides environment variable support that works uniformly across all three interfaces: CLI, Ruby API, and RSpec. This allows you to configure Canon behavior through your environment without changing code or command-line arguments.
14
+
15
+ Environment variables are particularly useful for:
16
+
17
+ * Setting defaults across multiple test runs
18
+ * Configuring CI/CD pipelines
19
+ * Temporary overrides without code changes
20
+ * System-wide configuration preferences
21
+
22
+ == Environment Variable Naming
23
+
24
+ Canon uses a hierarchical naming scheme for environment variables:
25
+
26
+ === Global Variables
27
+
28
+ Global variables apply to all formats (XML, HTML, JSON, YAML):
29
+
30
+ [source]
31
+ ----
32
+ CANON_{ATTRIBUTE_NAME}
33
+ ----
34
+
35
+ .Global environment variable example
36
+ [example]
37
+ ====
38
+ [source,bash]
39
+ ----
40
+ export CANON_USE_COLOR=false
41
+ export CANON_ALGORITHM=semantic
42
+ export CANON_MAX_FILE_SIZE=10485760
43
+ ----
44
+ ====
45
+
46
+ === Format-Specific Variables
47
+
48
+ Format-specific variables apply only to a particular format and override global variables:
49
+
50
+ [source]
51
+ ----
52
+ CANON_{FORMAT}_{CONFIG_TYPE}_{ATTRIBUTE_NAME}
53
+ ----
54
+
55
+ Where:
56
+
57
+ * `{FORMAT}` is one of: `XML`, `HTML`, `JSON`, `YAML`
58
+ * `{CONFIG_TYPE}` is one of: `DIFF`, `MATCH`, `FORMAT`
59
+ * `{ATTRIBUTE_NAME}` is the configuration attribute
60
+
61
+ .Format-specific environment variable example
62
+ [example]
63
+ ====
64
+ [source,bash]
65
+ ----
66
+ # XML-specific diff configuration
67
+ export CANON_XML_DIFF_ALGORITHM=semantic
68
+ export CANON_XML_DIFF_USE_COLOR=true
69
+
70
+ # HTML-specific match configuration
71
+ export CANON_HTML_MATCH_PROFILE=rendered
72
+
73
+ # JSON-specific preprocessing
74
+ export CANON_JSON_FORMAT_PREPROCESSING=normalize
75
+ ----
76
+ ====
77
+
78
+ == Complete Environment Variables Reference
79
+
80
+ === Diff Configuration Variables
81
+
82
+ [cols="3,1,2,4,2"]
83
+ |===
84
+ |Variable Name |Type |Default |Description |Applies To
85
+
86
+ |`CANON_MODE`
87
+ |symbol
88
+ |`:by_line`
89
+ |Diff output mode: `by_line` or `by_object`
90
+ |All formats
91
+
92
+ |`CANON_USE_COLOR`
93
+ |boolean
94
+ |`true`
95
+ |Enable/disable ANSI color codes in output
96
+ |All formats
97
+
98
+ |`CANON_CONTEXT_LINES`
99
+ |integer
100
+ |`3`
101
+ |Number of context lines around changes
102
+ |All formats
103
+
104
+ |`CANON_GROUPING_LINES`
105
+ |integer
106
+ |`10`
107
+ |Maximum lines between changes to group them
108
+ |All formats
109
+
110
+ |`CANON_SHOW_DIFFS`
111
+ |symbol
112
+ |`:all`
113
+ |Which diffs to show: `all`, `normative`, `informative`
114
+ |All formats
115
+
116
+ |`CANON_VERBOSE_DIFF`
117
+ |boolean
118
+ |`false`
119
+ |Enable verbose diff output with detailed analysis
120
+ |All formats
121
+
122
+ |`CANON_ALGORITHM`
123
+ |symbol
124
+ |`:dom`
125
+ |Diff algorithm: `dom` (positional) or `semantic` (tree-based)
126
+ |All formats
127
+
128
+ |`CANON_MAX_FILE_SIZE`
129
+ |integer
130
+ |`5242880`
131
+ |Maximum file size in bytes (default 5MB)
132
+ |All formats
133
+
134
+ |`CANON_MAX_NODE_COUNT`
135
+ |integer
136
+ |`10000`
137
+ |Maximum number of nodes in parsed tree
138
+ |All formats
139
+
140
+ |`CANON_MAX_DIFF_LINES`
141
+ |integer
142
+ |`10000`
143
+ |Maximum number of diff output lines
144
+ |All formats
145
+ |===
146
+
147
+ === Match Configuration Variables
148
+
149
+ [cols="3,1,2,4,2"]
150
+ |===
151
+ |Variable Name |Type |Default |Description |Applies To
152
+
153
+ |`CANON_PROFILE`
154
+ |symbol
155
+ |`nil`
156
+ |Match profile: `strict`, `rendered`, `spec_friendly`, `content_only`
157
+ |All formats
158
+ |===
159
+
160
+ === Format Configuration Variables
161
+
162
+ [cols="3,1,2,4,2"]
163
+ |===
164
+ |Variable Name |Type |Default |Description |Applies To
165
+
166
+ |`CANON_PREPROCESSING`
167
+ |string
168
+ |`none`
169
+ |Preprocessing mode: `none`, `c14n`, `normalize`, `format`
170
+ |XML, HTML, JSON, YAML
171
+ |===
172
+
173
+ == Examples: Same Configuration, Different Interfaces
174
+
175
+ This section demonstrates how the same configuration is expressed across all three Canon interfaces.
176
+
177
+ === Example 1: Basic Configuration
178
+
179
+ Enable semantic diff algorithm with color output.
180
+
181
+ .Using environment variables
182
+ [source,bash]
183
+ ----
184
+ export CANON_ALGORITHM=semantic
185
+ export CANON_USE_COLOR=true
186
+ ----
187
+
188
+ .Using CLI
189
+ [source,bash]
190
+ ----
191
+ canon diff file1.xml file2.xml \
192
+ --diff-algorithm semantic \
193
+ --color
194
+ ----
195
+
196
+ .Using Ruby API
197
+ [source,ruby]
198
+ ----
199
+ Canon.compare(file1, file2, format: :xml,
200
+ diff_algorithm: :semantic,
201
+ color: true
202
+ )
203
+ ----
204
+
205
+ .Using RSpec
206
+ [source,ruby]
207
+ ----
208
+ RSpec.configure do |config|
209
+ config.canon.xml.diff.algorithm = :semantic
210
+ config.canon.xml.diff.use_color = true
211
+ end
212
+ ----
213
+
214
+ === Example 2: Format-Specific Configuration
215
+
216
+ Configure XML and HTML differently.
217
+
218
+ .Using environment variables
219
+ [source,bash]
220
+ ----
221
+ # XML uses semantic diff
222
+ export CANON_XML_DIFF_ALGORITHM=semantic
223
+ export CANON_XML_MATCH_PROFILE=strict
224
+
225
+ # HTML uses DOM diff and rendered profile
226
+ export CANON_HTML_DIFF_ALGORITHM=dom
227
+ export CANON_HTML_MATCH_PROFILE=rendered
228
+ ----
229
+
230
+ .Using CLI
231
+ [source,bash]
232
+ ----
233
+ # For XML files
234
+ canon diff file1.xml file2.xml \
235
+ --diff-algorithm semantic \
236
+ --match-profile strict
237
+
238
+ # For HTML files
239
+ canon diff file1.html file2.html \
240
+ --diff-algorithm dom \
241
+ --match-profile rendered
242
+ ----
243
+
244
+ .Using Ruby API
245
+ [source,ruby]
246
+ ----
247
+ # For XML
248
+ Canon.compare(file1_xml, file2_xml, format: :xml,
249
+ diff_algorithm: :semantic,
250
+ match_profile: :strict
251
+ )
252
+
253
+ # For HTML
254
+ Canon.compare(file1_html, file2_html, format: :html,
255
+ diff_algorithm: :dom,
256
+ match_profile: :rendered
257
+ )
258
+ ----
259
+
260
+ .Using RSpec
261
+ [source,ruby]
262
+ ----
263
+ RSpec.configure do |config|
264
+ # XML configuration
265
+ config.canon.xml.diff.algorithm = :semantic
266
+ config.canon.xml.match.profile = :strict
267
+
268
+ # HTML configuration
269
+ config.canon.html.diff.algorithm = :dom
270
+ config.canon.html.match.profile = :rendered
271
+ end
272
+ ----
273
+
274
+ === Example 3: Size Limits
275
+
276
+ Configure file size and node count limits.
277
+
278
+ .Using environment variables
279
+ [source,bash]
280
+ ----
281
+ export CANON_MAX_FILE_SIZE=10485760 # 10MB
282
+ export CANON_MAX_NODE_COUNT=50000 # 50k nodes
283
+ export CANON_MAX_DIFF_LINES=20000 # 20k lines
284
+ ----
285
+
286
+ .Using Ruby API
287
+ [source,ruby]
288
+ ----
289
+ Canon.configure do |config|
290
+ config.xml.diff.max_file_size = 10_485_760
291
+ config.xml.diff.max_node_count = 50_000
292
+ config.xml.diff.max_diff_lines = 20_000
293
+ end
294
+ ----
295
+
296
+ .Using RSpec
297
+ [source,ruby]
298
+ ----
299
+ RSpec.configure do |config|
300
+ config.canon.xml.diff.max_file_size = 10_485_760
301
+ config.canon.xml.diff.max_node_count = 50_000
302
+ config.canon.xml.diff.max_diff_lines = 20_000
303
+ end
304
+ ----
305
+
306
+ NOTE: Size limits are not available as CLI options - they must be configured through environment variables or programmatic configuration.
307
+
308
+ == Priority Chain
309
+
310
+ When multiple configuration sources are present, Canon uses the following priority order (highest to lowest):
311
+
312
+ 1. **Explicit arguments** - Passed directly to the comparison method or CLI command
313
+ 2. **Environment variables** - Set via `CANON_*` variables
314
+ 3. **Default values** - Built-in Canon defaults
315
+
316
+ .Priority chain example
317
+ [example]
318
+ ====
319
+ [source,bash]
320
+ ----
321
+ # Environment variable sets default
322
+ export CANON_ALGORITHM=semantic
323
+
324
+ # CLI argument overrides environment variable
325
+ canon diff file1.xml file2.xml --diff-algorithm dom
326
+ # Uses: dom (explicit CLI argument wins)
327
+
328
+ # No CLI argument, environment variable applies
329
+ canon diff file1.xml file2.xml
330
+ # Uses: semantic (from environment variable)
331
+ ----
332
+ ====
333
+
334
+ == Type Conversion
335
+
336
+ Canon automatically converts environment variable string values to the appropriate types:
337
+
338
+ [cols="1,3"]
339
+ |===
340
+ |Type |Conversion Rules
341
+
342
+ |Boolean
343
+ |`"true"`, `"1"`, `"yes"` → `true` +
344
+ `"false"`, `"0"`, `"no"` → `false`
345
+
346
+ |Integer
347
+ |String parsed as decimal integer
348
+
349
+ |Symbol
350
+ |String converted to symbol (e.g., `"semantic"` → `:semantic`)
351
+ |===
352
+
353
+ == Debugging Environment Variables
354
+
355
+ To verify which environment variables Canon is using:
356
+
357
+ .Check active environment variables
358
+ [source,bash]
359
+ ----
360
+ env | grep CANON_
361
+ ----
362
+
363
+ .Enable verbose output to see configuration
364
+ [source,bash]
365
+ ----
366
+ export CANON_VERBOSE_DIFF=true
367
+ canon diff file1.xml file2.xml --verbose
368
+ ----
369
+
370
+ == See Also
371
+
372
+ * link:../features/environment-configuration/index.html[Environment Configuration]
373
+ * link:../features/environment-configuration/override-system.html[Override System]
374
+ * link:options-across-interfaces.html[Options Across Interfaces]
375
+ * link:cli-options.html[CLI Options Reference]
@@ -0,0 +1,204 @@
1
+ ---
2
+ layout: default
3
+ title: Reference
4
+ nav_order: 7
5
+ has_children: true
6
+ ---
7
+ = Reference
8
+
9
+ Complete reference documentation for quick lookups.
10
+
11
+ == Overview
12
+
13
+ This section provides comprehensive reference material for all Canon options, methods, and concepts. Use this section when you need to:
14
+
15
+ * Look up specific CLI options
16
+ * Find complete API method signatures
17
+ * Understand all match dimensions
18
+ * Check environment variable names
19
+ * Reference technical terms
20
+
21
+ == Reference Pages
22
+
23
+ link:cli-options[**CLI Options Reference**]::
24
+ Complete listing of all command-line options for `format` and `diff` commands.
25
+ +
26
+ Organized by category with examples for each option.
27
+
28
+ link:ruby-api-methods[**Ruby API Methods Reference**]::
29
+ Complete API documentation for all public methods.
30
+ +
31
+ Includes signatures, parameters, return values, and examples.
32
+
33
+ link:match-dimensions[**Match Dimensions Reference**]::
34
+ All available match dimensions with descriptions and valid values.
35
+ +
36
+ Organized by format (XML/HTML, JSON/YAML) with examples.
37
+
38
+ link:environment-variables[**Environment Variables Reference**]::
39
+ All environment variables that configure Canon's behavior.
40
+ +
41
+ Includes variable names, types, defaults, and examples.
42
+
43
+ link:glossary[**Glossary**]::
44
+ Definitions of technical terms used throughout Canon documentation.
45
+ +
46
+ Alphabetically organized with cross-references.
47
+
48
+ == Quick Lookup Tables
49
+
50
+ === Match Profiles
51
+
52
+ [cols="1,3"]
53
+ |===
54
+ |Profile |Description
55
+
56
+ |`strict`
57
+ |Exact matching - all dimensions strict
58
+
59
+ |`rendered`
60
+ |Browser/CSS rendering simulation
61
+
62
+ |`spec_friendly`
63
+ |Test-friendly - ignores formatting
64
+
65
+ |`content_only`
66
+ |Ignores all structural differences
67
+ |===
68
+
69
+ See link:match-dimensions#profiles[Match Dimensions: Profiles] for detailed dimension settings.
70
+
71
+ === Diff Algorithms
72
+
73
+ [cols="1,2,2"]
74
+ |===
75
+ |Algorithm |Strength |Best For
76
+
77
+ |`dom`
78
+ |Fast, stable
79
+ |Similar documents
80
+
81
+ |`semantic`
82
+ |Intelligent, move detection
83
+ |Restructured documents
84
+ |===
85
+
86
+ See link:../understanding/algorithms/[Comparison Algorithms] for details.
87
+
88
+ === Diff Modes
89
+
90
+ [cols="1,3"]
91
+ |===
92
+ |Mode |Description
93
+
94
+ |`by_line`
95
+ |Traditional line-by-line diff output
96
+
97
+ |`by_object`
98
+ |Tree-based semantic diff output
99
+ |===
100
+
101
+ See link:../understanding/diff-modes/[Diff Modes] for details.
102
+
103
+ === Supported Formats
104
+
105
+ [cols="1,2,2"]
106
+ |===
107
+ |Format |Canonicalization |Default Diff Mode
108
+
109
+ |XML
110
+ |W3C C14N 1.1
111
+ |`by_object`
112
+
113
+ |HTML
114
+ |HTML4/5 specific
115
+ |`by_line`
116
+
117
+ |JSON
118
+ |Sorted keys
119
+ |`by_object`
120
+
121
+ |YAML
122
+ |Sorted keys
123
+ |`by_object`
124
+ |===
125
+
126
+ See link:../understanding/formats/[Format Support] for details.
127
+
128
+ == Common Lookups
129
+
130
+ === CLI Command Structure
131
+
132
+ [source,bash]
133
+ ----
134
+ # Format command
135
+ canon format <file> [options]
136
+
137
+ # Diff command
138
+ canon diff <file1> <file2> [options]
139
+ ----
140
+
141
+ See link:cli-options[CLI Options Reference] for all options.
142
+
143
+ === Ruby API Patterns
144
+
145
+ [source,ruby]
146
+ ----
147
+ # Formatting
148
+ Canon.format(input, format, **options)
149
+
150
+ # Comparison
151
+ Canon::Comparison.equivalent?(doc1, doc2, **options)
152
+ Canon::Comparison.compare(doc1, doc2, **options)
153
+
154
+ # RSpec matchers
155
+ expect(actual).to be_xml_equivalent_to(expected)
156
+ expect(actual).to match_xml(expected, **options)
157
+ ----
158
+
159
+ See link:ruby-api-methods[Ruby API Reference] for complete signatures.
160
+
161
+ === Environment Variables
162
+
163
+ [source,bash]
164
+ ----
165
+ # Size limits
166
+ export CANON_MAX_FILE_SIZE=5242880 # 5MB
167
+ export CANON_MAX_NODES=10000
168
+
169
+ # Diff configuration
170
+ export CANON_DIFF_CONTEXT_LINES=5
171
+ export CANON_DIFF_GROUPING_LINES=3
172
+
173
+ # Debug
174
+ export CANON_DEBUG=true
175
+ ----
176
+
177
+ See link:environment-variables[Environment Variables Reference] for all variables.
178
+
179
+ == Using This Section
180
+
181
+ **To find a specific option**::
182
+ Use your browser's search (Ctrl+F / Cmd+F) or check the link:cli-options[CLI Options] or link:ruby-api-methods[Ruby API] references.
183
+
184
+ **To understand a term**::
185
+ Check the link:glossary[Glossary] for definitions and cross-references.
186
+
187
+ **To see all match dimensions**::
188
+ Review link:match-dimensions[Match Dimensions Reference] for complete listings.
189
+
190
+ **To configure via environment**::
191
+ See link:environment-variables[Environment Variables Reference] for all ENV options.
192
+
193
+ == Next Steps
194
+
195
+ * Browse specific reference pages for detailed information
196
+ * Use the search function to find specific topics
197
+ * Refer to link:../interfaces/[Interfaces] for usage examples
198
+ * Check link:../guides/[Guides] for task-oriented tutorials
199
+
200
+ == See Also
201
+
202
+ * link:../interfaces/[Interfaces] - How to use these options
203
+ * link:../features/[Features] - Detailed feature explanations
204
+ * link:../guides/[Guides] - Task-oriented tutorials