Skip to content

Commit abd8c05

Browse files
committed
Start documenting tests/rustdoc-json
1 parent 234bc7b commit abd8c05

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
- [Rustdoc internals](./rustdoc-internals.md)
102102
- [Search](./rustdoc-internals/search.md)
103103
- [The `rustdoc` test suite](./rustdoc-internals/rustdoc-test-suite.md)
104+
- [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
104105
- [Autodiff internals](./autodiff/internals.md)
105106
- [Installation](./autodiff/installation.md)
106107
- [How to debug](./autodiff/debugging.md)

src/compiler-src.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ The bulk of [`rustdoc`] is in [`librustdoc`]. However, the [`rustdoc`] binary
155155
itself is [`src/tools/rustdoc`], which does nothing except call [`rustdoc::main`].
156156

157157
There is also `JavaScript` and `CSS` for the docs in [`src/tools/rustdoc-js`]
158-
and [`src/tools/rustdoc-themes`].
158+
and [`src/tools/rustdoc-themes`]. The type definitions for `--output-format=json`
159+
are in a seperate crate in [`src/rustdoc-json-types`].
159160

160161
You can read more about [`rustdoc`] in [this chapter][rustdoc-chapter].
161162

@@ -164,6 +165,7 @@ You can read more about [`rustdoc`] in [this chapter][rustdoc-chapter].
164165
[`src/tools/rustdoc-js`]: https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc-js
165166
[`src/tools/rustdoc-themes`]: https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc-themes
166167
[`src/tools/rustdoc`]: https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc
168+
[`src/rustdoc-json-types`]: https://github.com/rust-lang/rust/tree/master/src/rustdoc-json-types
167169
[rustdoc-chapter]: ./rustdoc.md
168170

169171
## Tests

src/rustdoc-internals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ directly, even during `HTML` generation. This [didn't used to be the case], and
214214
a lot of `rustdoc`'s architecture was designed around not doing that, but a
215215
`TyCtxt` is now passed to `formats::renderer::run_format`, which is used to
216216
run generation for both `HTML` and the
217-
(unstable as of <!-- date-check --> March 2023) JSON format.
217+
(unstable as of <!-- date-check --> May 2025) JSON format.
218218

219219
This change has allowed other changes to remove data from the "clean" [`AST`][ast]
220220
that can be easily derived from `TyCtxt` queries, and we'll usually accept
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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
47+
[document private items]: https://doc.rust-lang.org/nightly/rustdoc/command-line-arguments.html#--document-private-items-show-items-that-are-not-public

0 commit comments

Comments
 (0)