Skip to content

jq directives for jsondocck#158269

Open
kohsine wants to merge 4 commits into
rust-lang:mainfrom
kohsine:add-jq
Open

jq directives for jsondocck#158269
kohsine wants to merge 4 commits into
rust-lang:mainfrom
kohsine:add-jq

Conversation

@kohsine

@kohsine kohsine commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Closes #142479.

Adds jq directives for jsondocck.

I decided to add jq instead of replacing jsonpath entirely so that migration could happen incrementally. In theory, it should be possible to replace every jsonpath test case with the new jq directives. Moving forward, this might put more burden on reviewers as test case writers would have the option to use jq or jsonpath or even both. Note that you cannot use jq_set with jsonpath directives or set with jq directives. Diff should be reviewed without whitespace.

r? @aDotInTheVoid

@rustbot

rustbot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

Some changes occurred in src/tools/compiletest

cc @jieyouxu

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

These commits modify tests/rustdoc-json.
rustdoc-json is a public (but unstable) interface.

Please ensure that if you've changed the output:

  • It's intentional.
  • The FORMAT_VERSION in src/librustdoc-json-types is bumped if necessary.

cc @aDotInTheVoid, @obi1kenobi

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc labels Jun 22, 2026
@rustbot

rustbot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Failed to set assignee to aDotInTheVoid: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 22, 2026

@aDotInTheVoid aDotInTheVoid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! This is a really good start.


This should also update the docs in src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-json-test-suite.md

Also, I know we don't have them at the moment, but it would be nice to have unit-tests for this. (Grep for jsondoclint for details about how to wire them into the overall build/ci system).

Finally, I can't review/approve this (rust-lang/team#2523), someone still on the rustdoc team will have to.

View changes since this review

Comment thread src/tools/jsondocck/src/directive.rs Outdated
Comment thread src/tools/jsondocck/src/directive.rs Outdated
Comment thread src/tools/jsondocck/src/directive.rs Outdated
@aDotInTheVoid

Copy link
Copy Markdown
Member

r? @lolbinarycat (Discussed this at all-hands, feel free to re-assign).

CC @fmease (Also discussed vague ideas about rustdoc testing)

@rustbot

rustbot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

lolbinarycat is currently at their maximum review capacity.
They may take a while to respond.

@kohsine

kohsine commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Mirrored the jsonpath directives for jq except for has <path> and !has <path> which are useless because jq returns null for both non-existent paths and existent paths with null values.

Conversions from has "$.foo.bar" will probably look like jq_is '.foo | has("bar")' true.

Conversions from !has "$.foo.bar" will probably look like jq_is '.foo | has("bar")' false.

Unfortunately this means that we lose error messages from !has <path>. has <path> didn't have good error messages in the first place. We still get good error messages from all the other directives though.

@kohsine kohsine requested a review from aDotInTheVoid June 23, 2026 20:02
@kohsine kohsine changed the title jq and jqset directives jq directives for jsondocck Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsondocck: replace JSONPath with jq as json query language.

4 participants