jsondocck: replace JSONPath with jq as json query language. #142479
Labels
A-rustdoc-json
Area: Rustdoc JSON backend
A-testsuite
Area: The testsuite used to check the correctness of rustc
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
E-mentor
Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
Impetus: #142327 (comment)
Currently, jsondocck uses JSONPath to query the output in assertions. Unfortunately, it's not a particularly flexible query language. In particular, it can't feed the result of one query to index an object. We'd really like this, so we can run a query to get an ID, then look up the item with that ID.
Using jq, we can do this. It has an implementation in rust: https://docs.rs/jaq-core/2.2.0/jaq_core/index.html
How
In jsondoc, this place would need to be changed to call into
jaq
instead.rust/src/tools/jsondocck/src/cache.rs
Lines 31 to 34 in 8da6239
When doing so, the contents of
Cache::variables
should be provided, so they can be used in selectors.Test Migration
I think the longest part of this will be migrating the tests from jsonpath to jq. It might be possible to hack up jsondocck to call
jsonpath_rust::parser::parse_json_path
on all the JSONPath queries, and then convert the JSONPath ast to a equivalent jq query.I'm not sure if this would be more or less effort than "just" doing it manually. But it'd be easier to review the resulting change this way, and it'd probably be more interesting.
The text was updated successfully, but these errors were encountered: