Skip to content

Replace JSONPath with jq in jsondocck #143089

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

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

fluiderson
Copy link
Contributor

This is an ongoing effort to close #142479. I've decided to take a hard path and rewrite rustdoc-types's entire testsuite. I don't think it'll be a good idea to construct a JSONPath-jq transpiler because it'll look really awkward for new contributors, JSONPath's limitations + jaq's own quirks may create a lot of questions that even current maintainers would've no answers for without digging into jsondocck's internals.

I expect jsondocck to have just 2 directives: jq and arg. Thanks to jq's flexibility, these 2 can do everything that the current directive set can and much more (actually, too much, I left some comments to opt out some dependencies when it'll be possible on jaq's side). I'm trying to actively utilize jq's features instead of just blindly rewriting existing assertions, so there should be more deletions than additions.

When I'll be done, I'll try to rebase and split my work to make it more easier to review. So far jsondocck is already functional, so you can check out how it may look like and give some feedback if you want. I'll commit updated tests folder by folder.

it's unnecessary for private crates
the deleted lines are duplicates of the lines 36 & 37
there are no insignificant whitespaces or comments, it's a single line
- directives were collected before processing, but there seems to be nothing preventing them from checking right away
- the unified error message style follows the style of short diagnostics from the compiler (almost the same was used on the deleted line 39)
i tried to keep the original code structure, but it's an almost entire rewrite. thankfully, there are more deletions than insertions, i expect jq to be incredibly powerful to supersede previous set of directives. no tests yet, but it seems to be working. i also simplified the `LINE_PATTERN` regex and added a comment for each section. jaq's guts are a bit arcane to me, but it seems to be only related to its setup, a resulted API turned out to be pretty straightforward
@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 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 27, 2025
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
All checks passed!
checking python file formatting
28 files already formatted
checking C++ file formatting
some tidy checks failed
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:14
  local time: Fri Jun 27 11:49:53 UTC 2025
  network time: Fri, 27 Jun 2025 11:49:54 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

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 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.
3 participants