|
| 1 | +# The `rustdoc-json` test suite |
| 2 | + |
| 3 | +This page is specifically about the test suite named `rustdoc-json`, which tests rustdoc's [json output]. |
| 4 | +For other test suites used for testing rustdoc, see [Rustdoc tests](../rustdoc.md#tests). |
| 5 | + |
| 6 | +Tests are run with compiletest, and have access to the usuall set of [directives](../tests/directives.md). |
| 7 | +Frequenly used directives here are: |
| 8 | + |
| 9 | +- [`//@ aux-build`][aux-build] to have dependencies. |
| 10 | +- `//@ edition: 2021` (or some other edition). |
| 11 | +- `//@ compile-flags: --document-hidden-items` to enable [document private items]. |
| 12 | + |
| 13 | +Each crate's json output is checked by 2 programs: [jsondoclint] and [jsondocck]. |
| 14 | + |
| 15 | +## jsondoclint |
| 16 | + |
| 17 | +[jsondoclint] checks that all [`Id`]s exist in the `index` (or `paths`). |
| 18 | +This makes sure their are no dangling [`Id`]s. |
| 19 | + |
| 20 | +<!-- TODO: It does some more things too? |
| 21 | +Also, talk about how it works |
| 22 | + --> |
| 23 | + |
| 24 | +## jsondocck |
| 25 | + |
| 26 | +<!-- TODO: shlex, jsonpath, values, variables --> |
| 27 | + |
| 28 | +### Directives |
| 29 | + |
| 30 | +- `//@ has <path>`:: Checks `<path>` exists, i.e. matches at least 1 value. |
| 31 | +- `//@ !has <path>`:: Checks `<path>` doesn't exist, i.e. matches 0 values. |
| 32 | +- `//@ has <path> <value>`: Check `<path>` exists, and 1 of the matches is equal to the given `<value>` |
| 33 | +- `//@ !has <path> <value>`: Checks `<path>` exists, but none of the matches equal the given `<value>`. |
| 34 | +- `//@ is <path> <value>`: Check `<path>` matches exacly one value, and it's equal to the given `<value>`. |
| 35 | +- `//@ is <path> <value> <value>...`: Check that `<path>` matches to exactly every given `<value>`. |
| 36 | + Ordering doesn't matter here. |
| 37 | +- `//@ !is <path> <value>`: Check `<path>` matches exactly one value, and that value is not equal to the given `<value>`. |
| 38 | +- `//@ count <path> <number>` Check that `<path>` matches to `<number>` of values. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +[json output]: https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#json-output |
| 43 | +[jsondocck]: https://github.com/rust-lang/rust/tree/master/src/tools/jsondocck |
| 44 | +[jsondoclint]: https://github.com/rust-lang/rust/tree/master/src/tools/jsondoclint |
| 45 | +[aux-build]: ../tests/compiletest.md#building-auxiliary-crates |
| 46 | +[`Id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc_json_types/struct.Id.html |
0 commit comments