-
Notifications
You must be signed in to change notification settings - Fork 546
Start documenting tests/rustdoc-json #2422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you link to here from https://rustc-dev-guide.rust-lang.org/rustdoc.html#tests ? |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||||
# The `rustdoc-json` test suite | ||||||
|
||||||
This page is specifically about the test suite named `rustdoc-json`, which tests rustdoc's [json output]. | ||||||
For other test suites used for testing rustdoc, see [Rustdoc tests](../rustdoc.md#tests). | ||||||
|
||||||
Tests are run with compiletest, and have access to the usuall set of [directives](../tests/directives.md). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Frequenly used directives here are: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
- [`//@ aux-build`][aux-build] to have dependencies. | ||||||
- `//@ edition: 2021` (or some other edition). | ||||||
- `//@ compile-flags: --document-hidden-items` to enable [document private items]. | ||||||
|
||||||
Each crate's json output is checked by 2 programs: [jsondoclint] and [jsondocck]. | ||||||
|
||||||
## jsondoclint | ||||||
|
||||||
[jsondoclint] checks that all [`Id`]s exist in the `index` (or `paths`). | ||||||
This makes sure their are no dangling [`Id`]s. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
<!-- TODO: It does some more things too? | ||||||
Also, talk about how it works | ||||||
--> | ||||||
|
||||||
## jsondocck | ||||||
|
||||||
<!-- TODO: shlex, jsonpath, values, variables --> | ||||||
|
||||||
### Directives | ||||||
|
||||||
- `//@ has <path>`:: Checks `<path>` exists, i.e. matches at least 1 value. | ||||||
- `//@ !has <path>`:: Checks `<path>` doesn't exist, i.e. matches 0 values. | ||||||
- `//@ has <path> <value>`: Check `<path>` exists, and 1 of the matches is equal to the given `<value>` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i imagine you mean "at least one", right? otherwise this is equivalent to |
||||||
- `//@ !has <path> <value>`: Checks `<path>` exists, but none of the matches equal the given `<value>`. | ||||||
- `//@ is <path> <value>`: Check `<path>` matches exacly one value, and it's equal to the given `<value>`. | ||||||
- `//@ is <path> <value> <value>...`: Check that `<path>` matches to exactly every given `<value>`. | ||||||
Ordering doesn't matter here. | ||||||
- `//@ !is <path> <value>`: Check `<path>` matches exactly one value, and that value is not equal to the given `<value>`. | ||||||
- `//@ count <path> <number>` Check that `<path>` matches to `<number>` of values. | ||||||
Comment on lines
+30
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you link to an exhaustive reference of the directives? source code is fine, just somewhere to look if a new directive gets added and i can't find it in the dev guide. |
||||||
|
||||||
|
||||||
|
||||||
[json output]: https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#json-output | ||||||
[jsondocck]: https://github.com/rust-lang/rust/tree/master/src/tools/jsondocck | ||||||
[jsondoclint]: https://github.com/rust-lang/rust/tree/master/src/tools/jsondoclint | ||||||
[aux-build]: ../tests/compiletest.md#building-auxiliary-crates | ||||||
[`Id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc_json_types/struct.Id.html | ||||||
[document private items]: https://doc.rust-lang.org/nightly/rustdoc/command-line-arguments.html#--document-private-items-show-items-that-are-not-public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.