Skip to content

Commit f9a5967

Browse files
committed
Start documenting tests/rustdoc-json
1 parent 70366bd commit f9a5967

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/doc/rustc-dev-guide/src/compiler-src.md

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

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

158159
You can read more about [`rustdoc`] in [this chapter][rustdoc-chapter].
159160

@@ -162,6 +163,7 @@ You can read more about [`rustdoc`] in [this chapter][rustdoc-chapter].
162163
[`src/tools/rustdoc-js`]: https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc-js
163164
[`src/tools/rustdoc-themes`]: https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc-themes
164165
[`src/tools/rustdoc`]: https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc
166+
[`src/rustdoc-json-types`]: https://github.com/rust-lang/rust/tree/master/src/rustdoc-json-types
165167
[rustdoc-chapter]: ./rustdoc.md
166168

167169
## Tests
Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
11
# The `rustdoc-json` test suite
22

3-
> **FIXME**: This section is a stub. It will be populated by [PR #2422](https://github.com/rust-lang/rustc-dev-guide/pull/2422/).
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)