Repository navigation
Clean up doc_alias feature #76705
Description
Activity
- addedT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
on Sep 14, 2020 Actually, the
"character has a meaning in the search (for "exact" search). But instead of just removing it, maybe we should instead emit an error when we encounter it. What do you think @ollie27 ?Actually, the
"character has a meaning in the search (for "exact" search).That doesn't work for
#[doc(alias = "...")]though, maybe it should?But instead of just removing it, maybe we should instead emit an error when we encounter it.
It would make sense to restrict allowed characters because even whitespace is allowed at the moment which seems questionable.
It sounds like we need to make sure this lands before we branch beta or so?
Let's forbid
", whitespaces and tabs in the the doc alias then.Can we avoid ad-hoc rules and say something like "must be a rust identifier"?
Even better! Great suggestion @Mark-Simulacrum !
Just thought about it, but it cannot be the case @Mark-Simulacrum : we allow things like "*" or "+" (for the traits for example), so it cannot be ident only. I'll stick to the listed characters above.
The documentation (https://doc.rust-lang.org/nightly/rustdoc/advanced-features.html?highlight=alias#add-aliases-for-an-item-in-documentation-search) has no mention of that -- can you elaborate?
Doc aliases can be something else than a rust identifier. For example, you can look for
&or+in the std docs, and you'll see aliases results.Ah, I see what you mean. Okay, then I agree that we need more than just Rust identifiers, and it might be reasonable to just allow as you suggest -- everything except whitespace and quotes. I'm a bit worried that'll hurt us in terms of how expansive it is but it's probably fine.
I don't expect
#[doc(alias = "..."")]attributes to be used widely, so we should be fine. ;)It would make sense to restrict allowed characters because even whitespace is allowed at the moment which seems questionable.
Is there more justification for removing whitespace support other than calling the characters questionable? If I have a struct or a function that implements an algorithm, I would like to alias the item to the plaintext name of the algorithm, for example
Mersenne twister.I just had in mind "idents", so no whitespace in them. However I don't see any reason to not allow
' 'specfically. I'll send a PR tomorrow.rustdoc only being ident-centric is something that I wish would be improved.
I wish that rustdoc search was for more than types and functions I already know the names of. I would hope that a search for "vector" would return
Vecnear the top instead of not at all.path-centric would be more accurate. ;)
From this comment: #50146 (comment)
Still remaining the
.replace().