-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add support for tuple struct field documentation #87451
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
Changes from 4 commits
ec76b6e
19f30b7
2b79094
fbf78e1
c4aa735
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1730,9 +1730,7 @@ impl Clean<Variant> for hir::VariantData<'_> { | |
fn clean(&self, cx: &mut DocContext<'_>) -> Variant { | ||
match self { | ||
hir::VariantData::Struct(..) => Variant::Struct(self.clean(cx)), | ||
hir::VariantData::Tuple(..) => { | ||
Variant::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect()) | ||
} | ||
hir::VariantData::Tuple(..) => Variant::Struct(self.clean(cx)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this cause #87887? It seems like tuple variants no longer exist in the outputted json, but shouldn't tuple variants be described as tuple variants? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's very likely yes. |
||
hir::VariantData::Unit(..) => Variant::CLike, | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
+-------------------------------------+------------+------------+------------+------------+ | ||
| File | Documented | Percentage | Examples | Percentage | | ||
+-------------------------------------+------------+------------+------------+------------+ | ||
| ...est/rustdoc-ui/coverage/enums.rs | 6 | 75.0% | 0 | 0.0% | | ||
| ...est/rustdoc-ui/coverage/enums.rs | 6 | 66.7% | 0 | 0.0% | | ||
+-------------------------------------+------------+------------+------------+------------+ | ||
| Total | 6 | 75.0% | 0 | 0.0% | | ||
| Total | 6 | 66.7% | 0 | 0.0% | | ||
+-------------------------------------+------------+------------+------------+------------+ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![crate_name = "foo"] | ||
|
||
// @has foo/struct.Foo.html | ||
// @has - '//h2[@id="fields"]' 'Tuple Fields' | ||
// @has - '//h3[@class="sidebar-title"]/a[@href="#fields"]' 'Tuple Fields' | ||
// @has - '//*[@id="structfield.0"]' '0: u32' | ||
// @has - '//*[@id="main"]/div[@class="docblock"]' 'hello' | ||
// @!has - '//*[@id="structfield.1"]' | ||
// @has - '//*[@id="structfield.2"]' '2: char' | ||
// @has - '//*[@id="structfield.3"]' '3: i8' | ||
// @has - '//*[@id="main"]/div[@class="docblock"]' 'not hello' | ||
pub struct Foo( | ||
/// hello | ||
pub u32, | ||
char, | ||
pub char, | ||
/// not hello | ||
pub i8, | ||
); | ||
GuillaumeGomez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// @has foo/enum.Bar.html | ||
// @has - '//pre[@class="rust enum"]' 'BarVariant(String),' | ||
// @matches - '//*[@id="variant.BarVariant.fields"]/h3' '^Tuple Fields of BarVariant$' | ||
// @has - '//*[@id="variant.BarVariant.field.0"]' '0: String' | ||
// @has - '//*[@id="variant.BarVariant.fields"]//*[@class="docblock"]' 'Hello docs' | ||
// @matches - '//*[@id="variant.FooVariant.fields"]/h3' '^Fields of FooVariant$' | ||
pub enum Bar { | ||
BarVariant( | ||
/// Hello docs | ||
String | ||
), | ||
FooVariant { | ||
/// hello | ||
x: u32, | ||
}, | ||
} |
Uh oh!
There was an error while loading. Please reload this page.