@@ -107,6 +107,8 @@ Options:
107
107
Do not activate the ` default` feature
108
108
--compact Only output the suggested version on stdout for
109
109
further processing
110
+ -j, --json Output a JSON-formatted description of all collected
111
+ data on stdout.
110
112
-s, --stable-path PATH
111
113
use local path as stable/old crate
112
114
-c, --current-path PATH
@@ -142,6 +144,92 @@ cargo semver | tee semver_out
142
144
Make sure you do the above with access to a nightly toolchain. Check your CI provider's
143
145
documentation on how to do that.
144
146
147
+ ### JSON output
148
+
149
+ By passing the ` -j ` flag, all output on standard out is formatted as a machine-readable
150
+ JSON blob. This can be useful for integration with other tools, and always generates all
151
+ possible output (ignoring other output-related flags). The output format is defined as
152
+ follows:
153
+
154
+ The top level object contains the keys ` old_version ` , ` new_version ` and ` changes ` . The
155
+ former two hold a version number in the format ` major.minor.patch ` , the latter an object
156
+ describing changes between the crate versions, which contains two arrays in the keys
157
+ ` path_changes ` and ` changes ` .
158
+
159
+ The ` path_changes ` array contains objects describing item additions and removals, which
160
+ have the following keys:
161
+
162
+ * ` name ` : The name of the item.
163
+ * ` def_span ` : An object describing the location of the item in one of the crates.
164
+ * ` additions ` : An array of spans that describe locations where the item has been added.
165
+ * ` removals ` : An array of spans that describe locations where the item has been removed.
166
+
167
+ An example object might look like this:
168
+
169
+ ``` json
170
+ {
171
+ "name" : " NFT_META_CGROUP" ,
172
+ "def_span" : {
173
+ "file" : " /path/to/libc-0.2.48/src/unix/notbsd/linux/other/mod.rs" ,
174
+ "line_lo" : 776 ,
175
+ "line_hi" : 776 ,
176
+ "col_lo" : 0 ,
177
+ "col_hi" : 40
178
+ },
179
+ "additions" : [
180
+ {
181
+ "file" : " /path/to/libc-0.2.48/src/lib.rs" ,
182
+ "line_lo" : 195 ,
183
+ "line_hi" : 195 ,
184
+ "col_lo" : 16 ,
185
+ "col_hi" : 23
186
+ }
187
+ ],
188
+ "removals" : []
189
+ }
190
+ ```
191
+
192
+
193
+ The ` changes ` array contains objects describing all other changes, which have the
194
+ following keys:
195
+
196
+ * ` name ` : The name of the item
197
+ * ` max_category ` : the most severe change category for this item, as a string.
198
+ * Possible values are ` Patch ` , ` NonBreaking ` , ` TechnicallyBreaking ` , and ` Breaking ` .
199
+ * ` new_span ` : an object describing the location of the item in the new crate (see example).
200
+ * ` changes ` : an array of 2-element sequences containing an error message and an optional
201
+ sub-span (` null ` if none is present)
202
+
203
+ An example object might look like this:
204
+
205
+ ``` json
206
+ {
207
+ "name" : " <new::util::enumerate::Enumerate<T> as new::prelude::Stream>" ,
208
+ "max_category" : " TechnicallyBreaking" ,
209
+ "new_span" : {
210
+ "file" : " /path/to/tokio-0.1.17/src/util/enumerate.rs" ,
211
+ "line_lo" : 46 ,
212
+ "line_hi" : 63 ,
213
+ "col_lo" : 0 ,
214
+ "col_hi" : 1
215
+ },
216
+ "changes" : [
217
+ [
218
+ " trait impl generalized or newly added" ,
219
+ null
220
+ ]
221
+ ]
222
+ }
223
+ ```
224
+
225
+ For reference, all objects describing spans have the same keys:
226
+
227
+ * ` file ` : A file name.
228
+ * ` line_lo ` : The line the span starts on.
229
+ * ` line_hi ` : The line the span ends on.
230
+ * ` col_lo ` : The column the span starts on.
231
+ * ` col_hi ` : The column the span ends on.
232
+
145
233
## Functionality
146
234
147
235
The guideline used to implement semver compatibility is the [ API evolution
0 commit comments