Skip to content
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

rustdoc search: filter by fields on a given type using . #118912

Open
fmease opened this issue Dec 13, 2023 · 2 comments
Open

rustdoc search: filter by fields on a given type using . #118912

fmease opened this issue Dec 13, 2023 · 2 comments
Labels
A-rustdoc-search Area: Rustdoc's search feature C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Dec 13, 2023

I've caught myself many times trying to search for fields on a specific type by entering search queries like tyctxt.types, only to be greeted by Query parser error: "Unexpected .".

I'd love rustdoc to find all fields named field defined (directly or indirectly via Deref) on “record types”1 matching path path given the input path.field.

For example, let's assume we are over at rustc's API docs and the query is tyctxt.types. Then, I'd expect rustdoc to find & link to rustc_middle::ty::context::GlobalCtxt.types (TyCtxt derefs to GlobalCtxt).

We could even think about extending this feature to cover path.field.subfield in the future which would denote (pseudo) ⟨typeof ⟦path.field⟧⟩.subfield, although that'd probably be quite hairy to implement performantly.

Related: #88660 (“item” kind filter field).

Footnotes

  1. Structs, tuple structs, enum variant structs and enum variant tuple structs.

@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. A-rustdoc-search Area: Rustdoc's search feature labels Dec 13, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 13, 2023
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 13, 2023
@fmease
Copy link
Member Author

fmease commented Dec 13, 2023

I wonder what the cost-benefit ratio of this feature is. The main motivation is cutting down the number of search results to ideally one result allowing you to almost instantly jump to the relevant docs if you already have the type & field name in your mind and want to avoid having to carefully look through a long list of results (which I'd argue is a likely scenario in large code bases esp. since field names tend to have quite short and generic names on their own).

Together with ?go_to_first=true or with the setting Directly go to item in search if there is only one result enabled and a browser keyword, this could be quite powerful.

@fmease fmease changed the title rustdoc search: filter by fields on a given type via . rustdoc search: filter by fields on a given type using . Dec 13, 2023
@notriddle
Copy link
Contributor

I would expect it to search non-static methods, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants