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: show struct field docs when inlined #16025

Closed
wants to merge 3 commits into from
Closed

rustdoc: show struct field docs when inlined #16025

wants to merge 3 commits into from

Conversation

emberian
Copy link
Member

Some minor changes to the compiler to expose this information. Very
inconvenient since struct fields aren't an item.

@emberian
Copy link
Member Author

@alexcrichton this is leaving docs like "/// Foo bar" on inlined structs. Where do we do the stripping of that stuff now? I can't find it anywhere...

@alexcrichton
Copy link
Member

Where do we do the stripping of that stuff now?

I think it's the collapse/unindent doc pass in src/librustdoc/passes.rs

I imagine that most use cases don't want the attributes of a field on the ty::field_ty, and this may have the possibility of impacting performance of the rest of the compiler. Would it be possible for these to be serialized, but off to the side? Rustdoc could then ask for them specifically via load_attrs

@emberian
Copy link
Member Author

I have no idea. I'll look into it.

@emberian
Copy link
Member Author

So the comment stripping happens in libsyntax now. It wasn't getting stripped because we weren't encoding the is_sugared_doc field.

emberian added 3 commits July 28, 2014 01:03
Some minor changes to the compiler to expose this information. Very
inconvenient since struct fields aren't an item. Adds (yet another) table to
metadata.

Closes #15739
The impl of Clean for Vec obsoleted these long, long ago.
@emberian
Copy link
Member Author

I really dislike that rustdoc is abusing metadata like this, instead of processing its own JSON output from other crates as it was designed to do... regardless, r? @alexcrichton

ebml_w: ebml_w
}, krate, ());
ebml_w.end_tag();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to already be a encode_struct_fields method which seems like this call to encode_attributes should be placed inside (rather than having a separate section). Did you try that and end up having it fall short of what should happen? It may also allow hooking into the existing load_attrs function instead of having to redefined the decode_* variants.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encode_struct_fields is only used when encoding complete structs. There's this weird index + custom hashmap that indexes actual items, and the interaction between struct fields and the rest of the struct is weird and I don't really understand it. In particular, struct fields themselves aren't considered items so load_attrs would never see them. Short of sticking the attributes in the field_ty, I don't really see how to handle that.

So yes, I did try that, you rejected it and I wrote this instead 🐈

bors added a commit that referenced this pull request Jul 28, 2014
Some minor changes to the compiler to expose this information. Very
inconvenient since struct fields aren't an item.
@bors bors closed this Jul 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants