-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for #[doc(alias = "...")] #50146
Comments
which pull request was this implemented in? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I tried using this feature today, it doesn't appear to actually be implemented. I tried adding |
Hm, it does appear to work for structs at least -- but not all items that otherwise appear in search. In particular it doesn't work on trait functions |
Ah? Interesting. I'll need to take a look at what's generated. |
As suggested here, I propose to stabilize this feature in order to make it usable outside of the std docs because of a few cases:
As for now, I don't see anything that could be an obstacle to stabilizing this feature? @rfcbot fcp merge |
Team member @GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Considering that 2 out of the 3 members of the current rustdoc team approved, I guess it's good to go? Opening the PR then... |
Sorry about not getting back to this sooner. What are some concrete use-cases for this? The @rfcbot concern use-cases The name "alias" alone doesn't make it clear this affects only search. I can't think of anything better than @rfcbot concern naming As pointed out by #50146 (comment) this doesn't yet work for associated items. @rfcbot concern associated-items Currently rustdoc is silently accepting things like: #[doc(alias)]
#[doc(alias(0))]
#[doc(alias("foo"))]
#[doc(alias = 0)] They have no effect but should of course be hard errors. @rfcbot concern invalid-forms |
This is a fair point. I personally like the current one but if another wording seems better, all good for me (even though I don't like much "search_keyword").
I intended to add a lint for the case where the alias was discarded, which seemed like an idea solution. So I guess it'd wrap this as well.
#71724 should fix this problem.
No, it wasn't the best example. Here a better one: I discovered recently that adding aliases for C library bindings would be very helpful (which was my original point, but here's why). For example, you type the name of the C function and the alias shows you the rust equivalent. It'd be a big plus instead of having to grep through the source code. |
Could you provide some links to crates which would benefit from this along the search terms that aren't producing useful results yet? |
…ts, r=ollie27 Doc alias improvements After [this message](rust-lang#50146 (comment)), I realized that the **doc alias**. So this PR does the followings: * Align the alias discovery on items added into the search-index. It brings a few nice advantages: * Instead of cloning the data between the two (in rustdoc source code), we now have the search-index one and aliases which reference to the first one. So we go from one big map containing a lot of duplicated data to just integers... * In the front-end (main.js), I improved the code around aliases to allow them to go through the same transformation as other items when we show the search results. * Improve the search tester in order to perform multiple requests into one file (I think it's better in this case than having a file for each case considering how many there are...) * I also had to add the new function inside the tester (`handleAliases`) Once this PR is merged, I intend to finally stabilize this feature. r? @ollie27 cc @rust-lang/rustdoc
…ts, r=ollie27 Doc alias improvements After [this message](rust-lang#50146 (comment)), I realized that the **doc alias**. So this PR does the followings: * Align the alias discovery on items added into the search-index. It brings a few nice advantages: * Instead of cloning the data between the two (in rustdoc source code), we now have the search-index one and aliases which reference to the first one. So we go from one big map containing a lot of duplicated data to just integers... * In the front-end (main.js), I improved the code around aliases to allow them to go through the same transformation as other items when we show the search results. * Improve the search tester in order to perform multiple requests into one file (I think it's better in this case than having a file for each case considering how many there are...) * I also had to add the new function inside the tester (`handleAliases`) Once this PR is merged, I intend to finally stabilize this feature. r? @ollie27 cc @rust-lang/rustdoc
…ts, r=ollie27 Doc alias improvements After [this message](rust-lang#50146 (comment)), I realized that the **doc alias**. So this PR does the followings: * Align the alias discovery on items added into the search-index. It brings a few nice advantages: * Instead of cloning the data between the two (in rustdoc source code), we now have the search-index one and aliases which reference to the first one. So we go from one big map containing a lot of duplicated data to just integers... * In the front-end (main.js), I improved the code around aliases to allow them to go through the same transformation as other items when we show the search results. * Improve the search tester in order to perform multiple requests into one file (I think it's better in this case than having a file for each case considering how many there are...) * I also had to add the new function inside the tester (`handleAliases`) Once this PR is merged, I intend to finally stabilize this feature. r? @ollie27 cc @rust-lang/rustdoc
…ts, r=ollie27 Doc alias improvements After [this message](rust-lang#50146 (comment)), I realized that the **doc alias**. So this PR does the followings: * Align the alias discovery on items added into the search-index. It brings a few nice advantages: * Instead of cloning the data between the two (in rustdoc source code), we now have the search-index one and aliases which reference to the first one. So we go from one big map containing a lot of duplicated data to just integers... * In the front-end (main.js), I improved the code around aliases to allow them to go through the same transformation as other items when we show the search results. * Improve the search tester in order to perform multiple requests into one file (I think it's better in this case than having a file for each case considering how many there are...) * I also had to add the new function inside the tester (`handleAliases`) Once this PR is merged, I intend to finally stabilize this feature. r? @ollie27 cc @rust-lang/rustdoc
It seems that this feature doesn't work with trait methods. |
@ollie27 Litterally all C bindings. Sometimes, to improve the API, you have to rename things and call a few functions from the C library inside a same function. Or just the renaming might be confusing sometimes (it happened a lot for me when using |
…eck, r=ollie27 Enforce doc alias check Part of rust-lang#50146. r? @ollie27
@lzutao It's the expected behaviour: it only matches against the exact alias name. |
…eck, r=ollie27 Enforce doc alias check Part of rust-lang#50146. r? @ollie27
…eck, r=ollie27 Enforce doc alias check Part of rust-lang#50146. r? @ollie27
…eck, r=ollie27 Enforce doc alias check Part of rust-lang#50146. r? @ollie27
…eck, r=ollie27 Enforce doc alias check Part of rust-lang#50146. r? @ollie27
Sorry for the delay. @rfcbot resolve use-cases
seems reasonable @rfcbot resolve naming I can't think of a better name. @rfcbot resolve associated-items Fixed by #71724 @rfcbot resolve invalid-forms This is mostly done, only #75888 to go. There is still a weird rust/src/librustdoc/clean/types.rs Line 665 in 3edf11c
I've noticed that
I'm not sure I agree with this. I personally would expect to be able to search for aliases the same way as everything else in the search index. I'm not aware of any other reasons to block stabilizing this though. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
Edit: Implemented in #49757. From the docs:
This feature allows you to add alias(es) to an item when using the
rustdoc
search through thedoc(alias)
attribute. Example:Then, when looking for it through the
rustdoc
search, if you enter "x" or "big", search will show theBigX
struct first.The text was updated successfully, but these errors were encountered: