canon 0.1.3 → 0.1.5
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 +4 -4
- data/.rubocop.yml +9 -1
- data/.rubocop_todo.yml +276 -7
- data/README.adoc +203 -138
- data/_config.yml +116 -0
- data/docs/ADVANCED_TOPICS.adoc +20 -0
- data/docs/BASIC_USAGE.adoc +16 -0
- data/docs/CHARACTER_VISUALIZATION.adoc +567 -0
- data/docs/CLI.adoc +493 -0
- data/docs/CUSTOMIZING_BEHAVIOR.adoc +19 -0
- data/docs/DIFF_ARCHITECTURE.adoc +435 -0
- data/docs/DIFF_FORMATTING.adoc +540 -0
- data/docs/FORMATS.adoc +447 -0
- data/docs/INDEX.adoc +222 -0
- data/docs/INPUT_VALIDATION.adoc +477 -0
- data/docs/MATCH_ARCHITECTURE.adoc +463 -0
- data/docs/MATCH_OPTIONS.adoc +719 -0
- data/docs/MODES.adoc +432 -0
- data/docs/NORMATIVE_INFORMATIVE_DIFFS.adoc +219 -0
- data/docs/OPTIONS.adoc +1387 -0
- data/docs/PREPROCESSING.adoc +491 -0
- data/docs/RSPEC.adoc +605 -0
- data/docs/RUBY_API.adoc +478 -0
- data/docs/SEMANTIC_DIFF_REPORT.adoc +528 -0
- data/docs/UNDERSTANDING_CANON.adoc +17 -0
- data/docs/VERBOSE.adoc +482 -0
- data/exe/canon +7 -0
- data/lib/canon/cli.rb +179 -0
- data/lib/canon/commands/diff_command.rb +195 -0
- data/lib/canon/commands/format_command.rb +113 -0
- data/lib/canon/comparison/base_comparator.rb +39 -0
- data/lib/canon/comparison/comparison_result.rb +79 -0
- data/lib/canon/comparison/html_comparator.rb +410 -0
- data/lib/canon/comparison/json_comparator.rb +212 -0
- data/lib/canon/comparison/match_options.rb +616 -0
- data/lib/canon/comparison/xml_comparator.rb +566 -0
- data/lib/canon/comparison/yaml_comparator.rb +93 -0
- data/lib/canon/comparison.rb +239 -0
- data/lib/canon/config.rb +172 -0
- data/lib/canon/diff/diff_block.rb +71 -0
- data/lib/canon/diff/diff_block_builder.rb +105 -0
- data/lib/canon/diff/diff_classifier.rb +46 -0
- data/lib/canon/diff/diff_context.rb +85 -0
- data/lib/canon/diff/diff_context_builder.rb +107 -0
- data/lib/canon/diff/diff_line.rb +77 -0
- data/lib/canon/diff/diff_node.rb +56 -0
- data/lib/canon/diff/diff_node_mapper.rb +148 -0
- data/lib/canon/diff/diff_report.rb +133 -0
- data/lib/canon/diff/diff_report_builder.rb +62 -0
- data/lib/canon/diff_formatter/by_line/base_formatter.rb +407 -0
- data/lib/canon/diff_formatter/by_line/html_formatter.rb +672 -0
- data/lib/canon/diff_formatter/by_line/json_formatter.rb +284 -0
- data/lib/canon/diff_formatter/by_line/simple_formatter.rb +190 -0
- data/lib/canon/diff_formatter/by_line/xml_formatter.rb +860 -0
- data/lib/canon/diff_formatter/by_line/yaml_formatter.rb +292 -0
- data/lib/canon/diff_formatter/by_object/base_formatter.rb +199 -0
- data/lib/canon/diff_formatter/by_object/json_formatter.rb +305 -0
- data/lib/canon/diff_formatter/by_object/xml_formatter.rb +248 -0
- data/lib/canon/diff_formatter/by_object/yaml_formatter.rb +17 -0
- data/lib/canon/diff_formatter/character_map.yml +197 -0
- data/lib/canon/diff_formatter/debug_output.rb +431 -0
- data/lib/canon/diff_formatter/diff_detail_formatter.rb +551 -0
- data/lib/canon/diff_formatter/legend.rb +141 -0
- data/lib/canon/diff_formatter.rb +520 -0
- data/lib/canon/errors.rb +56 -0
- data/lib/canon/formatters/html4_formatter.rb +17 -0
- data/lib/canon/formatters/html5_formatter.rb +17 -0
- data/lib/canon/formatters/html_formatter.rb +37 -0
- data/lib/canon/formatters/html_formatter_base.rb +163 -0
- data/lib/canon/formatters/json_formatter.rb +3 -0
- data/lib/canon/formatters/xml_formatter.rb +20 -55
- data/lib/canon/formatters/yaml_formatter.rb +4 -1
- data/lib/canon/pretty_printer/html.rb +57 -0
- data/lib/canon/pretty_printer/json.rb +25 -0
- data/lib/canon/pretty_printer/xml.rb +29 -0
- data/lib/canon/rspec_matchers.rb +222 -80
- data/lib/canon/validators/base_validator.rb +49 -0
- data/lib/canon/validators/html_validator.rb +138 -0
- data/lib/canon/validators/json_validator.rb +89 -0
- data/lib/canon/validators/xml_validator.rb +53 -0
- data/lib/canon/validators/yaml_validator.rb +73 -0
- data/lib/canon/version.rb +1 -1
- data/lib/canon/xml/attribute_handler.rb +80 -0
- data/lib/canon/xml/c14n.rb +36 -0
- data/lib/canon/xml/character_encoder.rb +38 -0
- data/lib/canon/xml/data_model.rb +225 -0
- data/lib/canon/xml/element_matcher.rb +196 -0
- data/lib/canon/xml/line_range_mapper.rb +158 -0
- data/lib/canon/xml/namespace_handler.rb +86 -0
- data/lib/canon/xml/node.rb +32 -0
- data/lib/canon/xml/nodes/attribute_node.rb +54 -0
- data/lib/canon/xml/nodes/comment_node.rb +23 -0
- data/lib/canon/xml/nodes/element_node.rb +56 -0
- data/lib/canon/xml/nodes/namespace_node.rb +38 -0
- data/lib/canon/xml/nodes/processing_instruction_node.rb +24 -0
- data/lib/canon/xml/nodes/root_node.rb +16 -0
- data/lib/canon/xml/nodes/text_node.rb +23 -0
- data/lib/canon/xml/processor.rb +151 -0
- data/lib/canon/xml/whitespace_normalizer.rb +72 -0
- data/lib/canon/xml/xml_base_handler.rb +188 -0
- data/lib/canon.rb +14 -3
- metadata +116 -21
data/README.adoc
CHANGED
|
@@ -1,219 +1,284 @@
|
|
|
1
|
-
= Canon:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
RSpec matchers for equivalence testing.
|
|
5
|
-
|
|
1
|
+
= Canon: Semantic comparison for serialization formats
|
|
2
|
+
:toc:
|
|
3
|
+
:toclevels: 2
|
|
6
4
|
|
|
7
5
|
== Purpose
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
== Features
|
|
15
|
-
|
|
16
|
-
XML canonicalization::
|
|
17
|
-
Format XML documents according to the https://www.w3.org/TR/xml-c14n11/[W3C
|
|
18
|
-
Canonicalized XML] format, with consistent indentation and ordering.
|
|
19
|
-
|
|
20
|
-
YAML canonicalization::
|
|
21
|
-
Format YAML documents with keys sorted alphabetically in a recursive manner at
|
|
22
|
-
all levels of the YAML structure, with consistent indentation.
|
|
23
|
-
|
|
24
|
-
JSON canonicalization::
|
|
25
|
-
Format JSON documents with keys sorted alphabetically in a recursive manner at
|
|
26
|
-
all levels of the JSON structure, with consistent indentation.
|
|
27
|
-
|
|
28
|
-
RSpec matchers::
|
|
29
|
-
Provides matchers for testing equivalence between serialized formats.
|
|
7
|
+
Canon provides canonicalization, pretty-printing, and semantic comparison for
|
|
8
|
+
serialization formats (XML, HTML, JSON, YAML). It produces standardized forms
|
|
9
|
+
suitable for comparison, testing, digital signatures, and human-readable output.
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
Single API for working with all three formats.
|
|
11
|
+
Key features:
|
|
33
12
|
|
|
13
|
+
* **Format support**: XML, HTML, JSON, YAML
|
|
14
|
+
* **Canonicalization**: W3C XML C14N 1.1, sorted JSON/YAML keys
|
|
15
|
+
* **Semantic comparison**: Compare meaning, not formatting
|
|
16
|
+
* **Multiple interfaces**: Ruby API, CLI, RSpec matchers
|
|
17
|
+
* **Smart diff output**: By-line or by-object modes with syntax highlighting
|
|
34
18
|
|
|
35
19
|
== Installation
|
|
36
20
|
|
|
37
|
-
Add
|
|
21
|
+
Add to your application's Gemfile:
|
|
38
22
|
|
|
39
23
|
[source,ruby]
|
|
40
24
|
----
|
|
41
25
|
gem 'canon'
|
|
42
26
|
----
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
Then execute:
|
|
45
29
|
|
|
46
30
|
[source,bash]
|
|
47
31
|
----
|
|
48
32
|
$ bundle install
|
|
49
33
|
----
|
|
50
34
|
|
|
51
|
-
Or install
|
|
35
|
+
Or install directly:
|
|
52
36
|
|
|
53
37
|
[source,bash]
|
|
54
38
|
----
|
|
55
39
|
$ gem install canon
|
|
56
40
|
----
|
|
57
41
|
|
|
42
|
+
== Quick start
|
|
58
43
|
|
|
59
|
-
|
|
44
|
+
=== Format documents
|
|
60
45
|
|
|
61
|
-
|
|
46
|
+
[source,ruby]
|
|
47
|
+
----
|
|
48
|
+
require 'canon'
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
# Canonical form (compact)
|
|
51
|
+
Canon.format('<root><b>2</b><a>1</a></root>', :xml)
|
|
52
|
+
# => "<root><a>1</a><b>2</b></root>"
|
|
65
53
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
# Pretty-print (human-readable)
|
|
55
|
+
require 'canon/pretty_printer/xml'
|
|
56
|
+
Canon::Xml::PrettyPrinter.new(indent: 2).format(xml_input)
|
|
57
|
+
----
|
|
69
58
|
|
|
70
|
-
|
|
59
|
+
=== Compare documents
|
|
71
60
|
|
|
72
61
|
[source,ruby]
|
|
73
62
|
----
|
|
74
|
-
|
|
75
|
-
Canon.format({content}, {format})
|
|
63
|
+
require 'canon/comparison'
|
|
76
64
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
----
|
|
65
|
+
xml1 = '<root><a>1</a><b>2</b></root>'
|
|
66
|
+
xml2 = '<root> <b>2</b> <a>1</a> </root>'
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`{format}`:: is the format type, which can be `:xml`, `:yaml`, or `:json`.
|
|
68
|
+
Canon::Comparison.equivalent?(xml1, xml2)
|
|
69
|
+
# => true (semantically equivalent despite formatting differences)
|
|
70
|
+
----
|
|
85
71
|
|
|
72
|
+
=== Use in tests
|
|
86
73
|
|
|
87
|
-
.Demonstration of formatting methods
|
|
88
|
-
[example]
|
|
89
|
-
====
|
|
90
74
|
[source,ruby]
|
|
91
75
|
----
|
|
92
|
-
require 'canon'
|
|
76
|
+
require 'canon/rspec_matchers'
|
|
77
|
+
|
|
78
|
+
RSpec.describe 'XML generation' do
|
|
79
|
+
it 'generates correct XML' do
|
|
80
|
+
expect(actual_xml).to be_xml_equivalent_to(expected_xml)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
----
|
|
93
84
|
|
|
94
|
-
|
|
95
|
-
xml_input = '<root><b>2</b><a>1</a></root>'
|
|
96
|
-
formatted_xml = Canon.format(xml_input, :xml)
|
|
97
|
-
# => Pretty-printed XML with consistent formatting
|
|
98
|
-
# or
|
|
99
|
-
formatted_xml = Canon.format_xml(xml_input)
|
|
85
|
+
=== Command-line interface
|
|
100
86
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
# or
|
|
106
|
-
formatted_yaml = Canon.format_yaml(yaml_input)
|
|
87
|
+
[source,bash]
|
|
88
|
+
----
|
|
89
|
+
# Format a file
|
|
90
|
+
$ canon format input.xml --mode pretty
|
|
107
91
|
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
formatted_json = Canon.format_json(json_input)
|
|
92
|
+
# Compare files
|
|
93
|
+
$ canon diff file1.xml file2.xml --verbose
|
|
94
|
+
|
|
95
|
+
# Get help
|
|
96
|
+
$ canon help
|
|
114
97
|
----
|
|
115
|
-
====
|
|
116
98
|
|
|
99
|
+
== Documentation
|
|
117
100
|
|
|
118
|
-
===
|
|
101
|
+
=== Using Canon
|
|
119
102
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
* **link:docs/RUBY_API[Ruby API]** - Using Canon from Ruby code
|
|
104
|
+
* **link:docs/CLI[Command-line interface]** - CLI commands and options
|
|
105
|
+
* **link:docs/RSPEC[RSpec matchers]** - Testing with Canon
|
|
123
106
|
|
|
124
|
-
|
|
107
|
+
=== Understanding Canon
|
|
125
108
|
|
|
126
|
-
[
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
109
|
+
* **link:docs/MATCH_ARCHITECTURE[Match architecture]** - How comparison
|
|
110
|
+
works
|
|
111
|
+
* **link:docs/FORMATS[Format support]** - XML, HTML, JSON, YAML details
|
|
112
|
+
* **link:docs/MODES[Diff modes]** - By-line vs by-object comparison
|
|
130
113
|
|
|
131
|
-
|
|
132
|
-
Canon.parse_{format}({content})
|
|
133
|
-
----
|
|
114
|
+
=== Features
|
|
134
115
|
|
|
135
|
-
|
|
116
|
+
* **link:docs/PREPROCESSING[Preprocessing]** - Document normalization
|
|
117
|
+
options
|
|
118
|
+
* **link:docs/MATCH_OPTIONS[Match options]** - Match dimensions and
|
|
119
|
+
profiles
|
|
120
|
+
* **link:docs/DIFF_FORMATTING[Diff formatting]** - Customizing diff output
|
|
121
|
+
* **link:docs/CHARACTER_VISUALIZATION[Character visualization]** -
|
|
122
|
+
Whitespace and special characters
|
|
123
|
+
* **link:docs/INPUT_VALIDATION[Input validation]** - Error handling
|
|
136
124
|
|
|
137
|
-
|
|
138
|
-
`{format}`:: is the format type, which can be `:xml`, `:yaml`, or `:json`.
|
|
125
|
+
=== Advanced topics
|
|
139
126
|
|
|
140
|
-
|
|
141
|
-
[
|
|
142
|
-
|
|
143
|
-
[
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
xml_doc = Canon.parse_xml(xml_input)
|
|
148
|
-
# => Nokogiri::XML::Document
|
|
127
|
+
* **link:docs/VERBOSE[Verbose mode]** - Two-tier diff architecture
|
|
128
|
+
* **link:docs/SEMANTIC_DIFF_REPORT[Semantic diff report]** - Diff report
|
|
129
|
+
format
|
|
130
|
+
* **link:docs/NORMATIVE_INFORMATIVE_DIFFS[Normative vs informative diffs]** - Diff
|
|
131
|
+
classification
|
|
132
|
+
* **link:docs/DIFF_ARCHITECTURE[Diff architecture]** - Technical pipeline
|
|
133
|
+
details
|
|
149
134
|
|
|
150
|
-
|
|
151
|
-
yaml_obj = Canon.parse(yaml_input, :yaml)
|
|
152
|
-
yaml_obj = Canon.parse_yaml(yaml_input)
|
|
153
|
-
# => Ruby object (Hash, Array, etc.)
|
|
135
|
+
== Features
|
|
154
136
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
137
|
+
=== Canonicalization
|
|
138
|
+
|
|
139
|
+
**XML**: W3C Canonical XML Version 1.1 specification with namespace
|
|
140
|
+
declaration ordering, attribute ordering, character encoding normalization, and
|
|
141
|
+
proper handling of xml:base, xml:lang, xml:space, and xml:id attributes.
|
|
142
|
+
|
|
143
|
+
**HTML**: Consistent formatting for HTML 4/5 and XHTML with automatic detection
|
|
144
|
+
and appropriate formatting rules.
|
|
145
|
+
|
|
146
|
+
**JSON/YAML**: Alphabetically sorted keys at all levels with consistent
|
|
147
|
+
formatting.
|
|
148
|
+
|
|
149
|
+
=== Semantic comparison
|
|
150
|
+
|
|
151
|
+
Compare documents based on meaning, not formatting:
|
|
161
152
|
|
|
153
|
+
* Whitespace normalization options
|
|
154
|
+
* Attribute/key order handling
|
|
155
|
+
* Comment handling
|
|
156
|
+
* Multiple match dimensions with behaviors
|
|
157
|
+
* Predefined match profiles (strict, rendered, spec_friendly, content_only)
|
|
162
158
|
|
|
163
|
-
|
|
159
|
+
See link:docs/MATCH_OPTIONS[Match options] for details.
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
161
|
+
=== Smart diff output
|
|
162
|
+
|
|
163
|
+
**By-line mode**: Traditional line-by-line diff with:
|
|
164
|
+
|
|
165
|
+
* DOM-guided semantic matching for XML
|
|
166
|
+
* Syntax-aware token highlighting
|
|
167
|
+
* Context lines around changes
|
|
168
|
+
* Whitespace visualization
|
|
169
|
+
|
|
170
|
+
**By-object mode**: Tree-based semantic diff with:
|
|
171
|
+
|
|
172
|
+
* Visual tree structure using box-drawing characters
|
|
173
|
+
* Shows only what changed (additions, removals, modifications)
|
|
174
|
+
* Color-coded output
|
|
175
|
+
|
|
176
|
+
See link:docs/MODES[Diff modes] for details.
|
|
177
|
+
|
|
178
|
+
=== Enhanced diff features
|
|
179
|
+
|
|
180
|
+
* **Color-coded output**: Red (normative deletions), green (normative additions), yellow
|
|
181
|
+
(normative structure), cyan (informative diffs)
|
|
182
|
+
* **Whitespace visualization**: Make invisible characters visible with CJK-safe
|
|
183
|
+
Unicode symbols
|
|
184
|
+
* **Non-ASCII detection**: Warnings for unexpected Unicode characters
|
|
185
|
+
* **Customizable**: Character maps, context lines, grouping options
|
|
186
|
+
|
|
187
|
+
See link:docs/DIFF_FORMATTING[Diff formatting] and
|
|
188
|
+
link:docs/CHARACTER_VISUALIZATION[Character visualization] for details.
|
|
189
|
+
|
|
190
|
+
=== Input validation
|
|
191
|
+
|
|
192
|
+
Comprehensive validation with clear error messages showing exact line and
|
|
193
|
+
column numbers for syntax errors in XML, HTML, JSON, and YAML.
|
|
194
|
+
|
|
195
|
+
See link:docs/INPUT_VALIDATION[Input validation] for details.
|
|
196
|
+
|
|
197
|
+
== Examples
|
|
198
|
+
|
|
199
|
+
=== Ruby API example
|
|
167
200
|
|
|
168
201
|
[source,ruby]
|
|
169
202
|
----
|
|
170
|
-
require '
|
|
171
|
-
|
|
203
|
+
require 'canon/comparison'
|
|
204
|
+
|
|
205
|
+
# Compare with custom options
|
|
206
|
+
Canon::Comparison.equivalent?(doc1, doc2,
|
|
207
|
+
match: {
|
|
208
|
+
text_content: :normalize,
|
|
209
|
+
structural_whitespace: :ignore,
|
|
210
|
+
comments: :ignore
|
|
211
|
+
},
|
|
212
|
+
verbose: true
|
|
213
|
+
)
|
|
214
|
+
----
|
|
172
215
|
|
|
173
|
-
|
|
174
|
-
# Unified matcher with format parameter
|
|
175
|
-
it 'compares equivalent XML' do
|
|
176
|
-
xml1 = '<root><a>1</a><b>2</b></root>'
|
|
177
|
-
xml2 = '<root><b>2</b><a>1</a></root>'
|
|
178
|
-
expect(xml1).to be_serialization_equivalent_to(xml2, format: :xml)
|
|
179
|
-
end
|
|
216
|
+
See link:docs/RUBY_API[Ruby API documentation].
|
|
180
217
|
|
|
181
|
-
|
|
182
|
-
yaml1 = "---\na: 1\nb: 2\n"
|
|
183
|
-
yaml2 = "---\nb: 2\na: 1\n"
|
|
184
|
-
expect(yaml1).to be_serialization_equivalent_to(yaml2, format: :yaml)
|
|
185
|
-
end
|
|
218
|
+
=== CLI example
|
|
186
219
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
220
|
+
[source,bash]
|
|
221
|
+
----
|
|
222
|
+
# Compare with semantic diff
|
|
223
|
+
$ canon diff file1.xml file2.xml \
|
|
224
|
+
--verbose \
|
|
225
|
+
--text-content normalize \
|
|
226
|
+
--structural-whitespace ignore
|
|
227
|
+
----
|
|
228
|
+
|
|
229
|
+
See link:docs/CLI[CLI documentation].
|
|
230
|
+
|
|
231
|
+
=== RSpec example
|
|
232
|
+
|
|
233
|
+
[source,ruby]
|
|
234
|
+
----
|
|
235
|
+
# Configure globally
|
|
236
|
+
Canon::RSpecMatchers.configure do |config|
|
|
237
|
+
config.xml.match.profile = :spec_friendly
|
|
238
|
+
config.xml.diff.use_color = true
|
|
239
|
+
end
|
|
192
240
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
expect(
|
|
197
|
-
expect(yaml1).to be_yaml_equivalent_to(yaml2) # YAML
|
|
198
|
-
expect(json1).to be_json_equivalent_to(json2) # JSON
|
|
241
|
+
# Use in tests
|
|
242
|
+
RSpec.describe 'XML generation' do
|
|
243
|
+
it 'generates correct structure' do
|
|
244
|
+
expect(actual_xml).to be_xml_equivalent_to(expected_xml)
|
|
199
245
|
end
|
|
200
246
|
end
|
|
201
247
|
----
|
|
202
248
|
|
|
249
|
+
See link:docs/RSPEC[RSpec documentation].
|
|
250
|
+
|
|
251
|
+
== Architecture
|
|
252
|
+
|
|
253
|
+
Canon follows an orchestrator pattern with MECE (Mutually Exclusive,
|
|
254
|
+
Collectively Exhaustive) principles:
|
|
255
|
+
|
|
256
|
+
**Comparison module** (`Canon::Comparison`): Format detection, validation, and
|
|
257
|
+
delegation to format-specific comparators (XML, HTML, JSON, YAML).
|
|
258
|
+
|
|
259
|
+
**DiffFormatter module** (`Canon::DiffFormatter`): Diff mode detection and
|
|
260
|
+
delegation to mode-specific formatters (by-line, by-object).
|
|
261
|
+
|
|
262
|
+
**Three-phase comparison**:
|
|
263
|
+
|
|
264
|
+
. **Preprocessing**: Optional document normalization (c14n, normalize, format)
|
|
265
|
+
. **Semantic matching**: Configurable match dimensions with behaviors
|
|
266
|
+
. **Diff rendering**: Formatted output with visualization
|
|
267
|
+
|
|
268
|
+
See link:docs/MATCH_ARCHITECTURE[Match architecture] for details.
|
|
203
269
|
|
|
204
270
|
== Development
|
|
205
271
|
|
|
206
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then
|
|
272
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then run
|
|
207
273
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
|
208
|
-
prompt
|
|
209
|
-
|
|
274
|
+
prompt.
|
|
210
275
|
|
|
211
276
|
== Contributing
|
|
212
277
|
|
|
213
278
|
Bug reports and pull requests are welcome on GitHub at
|
|
214
279
|
https://github.com/lutaml/canon.
|
|
215
280
|
|
|
216
|
-
|
|
217
281
|
== Copyright and license
|
|
218
282
|
|
|
219
|
-
Copyright Ribose. https://opensource.org/licenses/BSD-2-Clause[BSD-2-Clause
|
|
283
|
+
Copyright Ribose. https://opensource.org/licenses/BSD-2-Clause[BSD-2-Clause
|
|
284
|
+
License].
|
data/_config.yml
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Jekyll configuration for Canon documentation
|
|
2
|
+
# Uses Just the Docs theme - https://just-the-docs.com/
|
|
3
|
+
|
|
4
|
+
# Site settings
|
|
5
|
+
title: Canon Documentation
|
|
6
|
+
description: Semantic comparison for serialization formats (XML, HTML, JSON, YAML)
|
|
7
|
+
url: https://lutaml.github.io
|
|
8
|
+
baseurl: /canon
|
|
9
|
+
|
|
10
|
+
# Theme
|
|
11
|
+
theme: just-the-docs
|
|
12
|
+
remote_theme: just-the-docs/just-the-docs
|
|
13
|
+
|
|
14
|
+
# AsciiDoc support
|
|
15
|
+
asciidoc: {}
|
|
16
|
+
asciidoctor:
|
|
17
|
+
attributes:
|
|
18
|
+
- idprefix=_
|
|
19
|
+
- source-highlighter=rouge
|
|
20
|
+
- icons=font
|
|
21
|
+
- experimental=''
|
|
22
|
+
|
|
23
|
+
# Build settings
|
|
24
|
+
plugins:
|
|
25
|
+
- jekyll-asciidoc
|
|
26
|
+
- jekyll-seo-tag
|
|
27
|
+
|
|
28
|
+
# Just the Docs theme configuration
|
|
29
|
+
search_enabled: true
|
|
30
|
+
search:
|
|
31
|
+
heading_level: 3
|
|
32
|
+
previews: 3
|
|
33
|
+
preview_words_before: 5
|
|
34
|
+
preview_words_after: 10
|
|
35
|
+
tokenizer_separator: /[\s/]+/
|
|
36
|
+
|
|
37
|
+
# Navigation
|
|
38
|
+
nav_sort: case_insensitive
|
|
39
|
+
|
|
40
|
+
# Footer content
|
|
41
|
+
footer_content: 'Copyright © Ribose. <a href="https://opensource.org/licenses/BSD-2-Clause">BSD-2-Clause License</a>.'
|
|
42
|
+
|
|
43
|
+
# Color scheme - use light mode
|
|
44
|
+
color_scheme: light
|
|
45
|
+
|
|
46
|
+
# Logo
|
|
47
|
+
logo: false
|
|
48
|
+
|
|
49
|
+
# Aux links for the upper right navigation
|
|
50
|
+
aux_links:
|
|
51
|
+
"Canon on GitHub":
|
|
52
|
+
- "https://github.com/lutaml/canon"
|
|
53
|
+
"Report Issue":
|
|
54
|
+
- "https://github.com/lutaml/canon/issues"
|
|
55
|
+
|
|
56
|
+
# Aux links configuration
|
|
57
|
+
aux_links_new_tab: true
|
|
58
|
+
|
|
59
|
+
# Heading anchors
|
|
60
|
+
heading_anchors: true
|
|
61
|
+
|
|
62
|
+
# Back to top link
|
|
63
|
+
back_to_top: true
|
|
64
|
+
back_to_top_text: "Back to top"
|
|
65
|
+
|
|
66
|
+
# Collections - for organizing documentation
|
|
67
|
+
collections:
|
|
68
|
+
docs:
|
|
69
|
+
permalink: "/:collection/:path/"
|
|
70
|
+
output: true
|
|
71
|
+
|
|
72
|
+
# Collection defaults
|
|
73
|
+
defaults:
|
|
74
|
+
- scope:
|
|
75
|
+
path: "docs"
|
|
76
|
+
type: "docs"
|
|
77
|
+
values:
|
|
78
|
+
layout: "default"
|
|
79
|
+
nav_exclude: false
|
|
80
|
+
|
|
81
|
+
# Only process documentation AsciiDoc files
|
|
82
|
+
include:
|
|
83
|
+
- index.adoc
|
|
84
|
+
|
|
85
|
+
# Exclude everything except docs directory
|
|
86
|
+
exclude:
|
|
87
|
+
- Gemfile
|
|
88
|
+
- Gemfile.lock
|
|
89
|
+
- Gemfile.docs
|
|
90
|
+
- README.adoc
|
|
91
|
+
- node_modules
|
|
92
|
+
- vendor
|
|
93
|
+
- lib
|
|
94
|
+
- spec
|
|
95
|
+
- bin
|
|
96
|
+
- exe
|
|
97
|
+
- pkg
|
|
98
|
+
- sig
|
|
99
|
+
- old-docs
|
|
100
|
+
- .rspec
|
|
101
|
+
- .rubocop.yml
|
|
102
|
+
- .rubocop_todo.yml
|
|
103
|
+
- .gitignore
|
|
104
|
+
- Rakefile
|
|
105
|
+
- canon.gemspec
|
|
106
|
+
- .git
|
|
107
|
+
- .github
|
|
108
|
+
- "*.md"
|
|
109
|
+
- "*.swp"
|
|
110
|
+
- "*.tmp"
|
|
111
|
+
- "**/*.md"
|
|
112
|
+
- "!docs/**"
|
|
113
|
+
|
|
114
|
+
# Keep only AsciiDoc files in docs directory
|
|
115
|
+
keep_files:
|
|
116
|
+
- "docs/*.adoc"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Advanced Topics
|
|
4
|
+
nav_order: 5
|
|
5
|
+
has_children: true
|
|
6
|
+
---
|
|
7
|
+
= Advanced topics
|
|
8
|
+
|
|
9
|
+
For developers and advanced users:
|
|
10
|
+
|
|
11
|
+
* **link:VERBOSE[Verbose mode]** - Two-tier diff output architecture
|
|
12
|
+
* **link:SEMANTIC_DIFF_REPORT[Semantic diff report]** - Detailed report
|
|
13
|
+
format
|
|
14
|
+
* **link:NORMATIVE_INFORMATIVE_DIFFS[Normative vs informative diffs]** - Diff
|
|
15
|
+
classification
|
|
16
|
+
* **link:DIFF_ARCHITECTURE[Diff architecture]** - Six-layer technical
|
|
17
|
+
pipeline
|
|
18
|
+
|
|
19
|
+
These documents cover Canon's internal architecture and advanced features for
|
|
20
|
+
developers extending or maintaining Canon.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Basic Usage
|
|
4
|
+
nav_order: 2
|
|
5
|
+
has_children: true
|
|
6
|
+
---
|
|
7
|
+
= Basic usage
|
|
8
|
+
|
|
9
|
+
Choose your interface for working with Canon:
|
|
10
|
+
|
|
11
|
+
* **link:RUBY_API[Ruby API]** - Using Canon from Ruby code
|
|
12
|
+
* **link:CLI[Command-line interface]** - Terminal commands and options
|
|
13
|
+
* **link:RSPEC[RSpec matchers]** - Testing with Canon in RSpec
|
|
14
|
+
|
|
15
|
+
These guides provide practical examples and complete API reference for each
|
|
16
|
+
interface.
|