-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Hiding of struct declarations means constructability isn't really documented #51860
Comments
cc @QuietMisdreavus @GuillaumeGomez I believe you two were involved in the initial hiding of these declarations, and might have more context to add to this discussion. |
You can change this in settings. We decided to have declarations hidden by default because they were mostly noise (especially in std lib). |
Makes sense! I agree that it's probably better to hide them, although I suppose in this case this was one of the few bits of information in them not replicated elsewhere. |
Not sure to understand your message. But like I said, you can totally change this behavior by clicking on the cog on the right of the search bar. There are other few options in there so I'll let you take a look. Having more feedbacks is always appreciated. :) |
Just noting, I'm resetting all browser state each time I close my browser, as a privacy measure. Therefore, using the settings menu is not tenable for me, unfortunately. |
@est31: Therefore, we have two solutions:
However, the big downside for both systems lies with the brand new laws on confidentiality (RGPD in europe for example) which would force us to add more mechanisms. Clearly, for docs, I'm not sure it's worth it. A third option could be possible: writing a browser plugin. If enough people want to have one, I'll just add it. |
Yeah cookies wouldn't work, I reset them as well. As for log-ins, I try to use documentation predominantly via the I'd prefer having the struct definition shown by default =). Just to give you feedback, as you've said you appreciate it. |
It's part of the numerous "two-sides" features unfortunately. :-/ But thanks for the feedback! |
Would it be possible to add a note to the Fields section in the main page? Say, after all the public fields are listed (or in the place of the fields section if there are no public fields), add something like " |
I disagree that it is mostly noise, the current implementation also hides away the signature which is valuable signal. Example: https://doc.rust-lang.org/std/str/struct.RMatches.html — you can't see it is I do agree that the interior of an item e.g. https://doc.rust-lang.org/std/iter/trait.Iterator.html is mostly noise since they are repeated below, so perhaps it is better to leave the exterior intact, and collapse the interior by default: The (Also, if the collapsed content is less than 2 lines then it's pointless to actually introduce a collapsible) |
I personally would like to see all the relevant information extracted from the declaration so that the expand declaration feature can be completely removed. After all, there would still be the link to the source. As best I can tell, there are only a couple pieces of information left in the declaration that don't appear elsewhere:
Provided that rustdoc can figure out the answers to these questions, none of them seem especially hard to expose. (3) would be just a matter of adding a new section. The other two points are all yes/no questions, so they could probably be addressed with a couple of strategically placed annotations elsewhere (for instance section heading that said |
In addition to the above:
I very often find I need information from the declaration (arguably it is the most important part of documentation for traits), so hiding it by default appears a strange choice to me (at least the doc settings appear to be working for now). |
This is fixed by allowing finer settings in #60778 |
I don't know if that really fixes this-- I think the constructability should be documented in addition to the definition. |
@clarfon Not sure to understand your point... |
@GuillaumeGomez depends on how you view the generated documentation — it's essentially a prettier, filtered version of Rust code, excepting the declarations which are not prettified (merely filtered). The declarations are available in the docs because they contain information which is not otherwise available — this information could be presented in a prettified manner, finally making the declaration section unnecessary. For example:
Note that generic parameters are already mentioned via an Personally I'm not sure whether breaking all this information out into new sections is better than simply always showing the existing declaration; possibly there should be a setting to choose between the two. But what is clear is that the current system is often hiding important information unless one clicks a "+" or tweaks the settings. |
I think since #83337 this is mostly resolved: structs contents are commonly shown now. |
I'm going to close this for now since I don't think it's really actionable. As @jsha said, this should be mostly resolved. |
This was found in review of #51854, which affects the documentation for
#[non_exhaustive]
and is a prerequisite for stabilisation.Previously, the
/* fields omitted */
comment would be a statement to the reader that the struct has private fields, and is thus not constructable. However, now that these declarations are hidden by default, this isn't really documented in something in the open.In order to properly document the non-exhaustiveness of a struct, it makes sense that the constructability of a struct also be documented, as this is the primary reason for marking a struct as non-exhaustive in the first place.
My thoughts: structs which are constructable are rarer than those that aren't, so I think that a message that states so on these types would be best. As I mentioned in the linked PR, it would be something along the lines of "all of this struct's fields are public, and it can be constructed normally with the Struct { .. } syntax."
The text was updated successfully, but these errors were encountered: