Skip to content

Change struct rendering to include a case for all fields being omitted #34713

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

Closed
coder543 opened this issue Jul 7, 2016 · 10 comments
Closed
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@coder543
Copy link

coder543 commented Jul 7, 2016

The Path documentation provides a good case-in-point. The struct for Path is being rendered as

pub struct Path {
    // some fields omitted
}

when it could be rendered as

pub struct Path {
    // all fields omitted
}

since there are no fields which have not been emitted. It just feels like an understatement when it says "some" fields have been omitted, and there are no fields being shown at all.

@steveklabnik steveklabnik added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jul 7, 2016
@bugaevc
Copy link

bugaevc commented Jul 8, 2016

Why not "private fields omitted"? It may be confusing to somebody new ("why are they omitting some/all fields?")

@abonander
Copy link
Contributor

abonander commented Jul 18, 2016

@bugaevc has a good point, though one (weak) counterpoint is pub fields annotated with #[doc(hidden)], which Rustdoc will treat as private but the compiler will still allow access to (necessary for the implementation details of some macros).

However, since hidden fields are effectively private to most API users, I don't think they necessitate a different wording, especially since those who know enough to know the difference won't shouldn't be confused by it.

@bugaevc
Copy link

bugaevc commented Jul 18, 2016

When there are hidden fields, we may want to go with "private and hidden fields omitted", if it's worth it.

@ollie27
Copy link
Member

ollie27 commented Aug 14, 2016

I've uploaded an alternative which just renders { .. } for completely opaque structs: #35667.

@bugaevc
Copy link

bugaevc commented Aug 14, 2016

I've uploaded an alternative which just renders { .. } for completely opaque structs: #34713.

You've linked to this very issue ;) The correct link is #35667

@ollie27
Copy link
Member

ollie27 commented Aug 14, 2016

oops, my bad, thanks

@bugaevc
Copy link

bugaevc commented Aug 14, 2016

My proposal

Why not "private fields omitted"? It may be confusing to somebody new ("why are they omitting some/all fields?")

stays if your alternative gets merged, for partly opaque structs.

By the way, are they a common thing? Are there statistics for stdlib & crates.io?

@ollie27
Copy link
Member

ollie27 commented Aug 14, 2016

I think the only instance in std is std::process::Child so I don't think they're very common at all.

I guess we could also change "some fields omitted" to "private fields omitted" or "private/hidden fields omitted". There's also "some variants omitted" on enums although in that case it's only from #[doc(hidden)]: std::io::ErrorKind.

@bugaevc
Copy link

bugaevc commented Aug 16, 2016

A bit off-topic: is there a reason why these prototypes are not syntax-highlighted?

bors added a commit that referenced this issue Sep 14, 2016
rustdoc: Don't add extra newlines for fully opaque structs

Changes the definition for braced structs with only private or hidden fields to save space on the page.

Before:
```
pub struct Vec<T> {
    // some fields omitted
}
```
After:
```
pub struct Vec<T> { /* fields omitted */ }
```

This also cleans up empty braced structs.

Before:
```
pub struct Foo {
}
```
After:
```
pub struct Foo {}
```

[before](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html) [after](https://ollie27.github.io/rust_doc_test/std/vec/struct.Vec.html)

cc #34713
@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@steveklabnik
Copy link
Member

Triage: this now says fields omitted, which works in both cases. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. 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

5 participants