Rollup merge of #109351 - GuillaumeGomez:no-footnote-in-summary, r=notriddle
rustdoc: Remove footnote references from doc summary Since it's one line, we don't have the footnote definition so it doesn't make sense to have the reference. Part of https://github.com/rust-lang/rust/issues/109024. r? `@notriddle`
This commit is contained in:
commit
39e09ac334
@ -556,7 +556,15 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_forbidden_tag(t: &Tag<'_>) -> bool {
|
fn is_forbidden_tag(t: &Tag<'_>) -> bool {
|
||||||
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
|
matches!(
|
||||||
|
t,
|
||||||
|
Tag::CodeBlock(_)
|
||||||
|
| Tag::Table(_)
|
||||||
|
| Tag::TableHead
|
||||||
|
| Tag::TableRow
|
||||||
|
| Tag::TableCell
|
||||||
|
| Tag::FootnoteDefinition(_)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
|
impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
|
||||||
@ -589,6 +597,10 @@ fn next(&mut self) -> Option<Self::Item> {
|
|||||||
is_start = false;
|
is_start = false;
|
||||||
check_if_allowed_tag(c)
|
check_if_allowed_tag(c)
|
||||||
}
|
}
|
||||||
|
Event::FootnoteReference(_) => {
|
||||||
|
self.skipped_tags += 1;
|
||||||
|
false
|
||||||
|
}
|
||||||
_ => true,
|
_ => true,
|
||||||
};
|
};
|
||||||
if !is_allowed_tag {
|
if !is_allowed_tag {
|
||||||
|
17
tests/rustdoc/footnote-in-summary.rs
Normal file
17
tests/rustdoc/footnote-in-summary.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// This test ensures that no footnote reference is generated inside
|
||||||
|
// summary doc.
|
||||||
|
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
// @has 'foo/index.html'
|
||||||
|
// @has - '//*[@class="desc docblock-short"]' 'hello bla'
|
||||||
|
// @!has - '//*[@class="desc docblock-short"]/sup' '1'
|
||||||
|
|
||||||
|
// @has 'foo/struct.S.html'
|
||||||
|
// @has - '//*[@class="docblock"]//sup' '1'
|
||||||
|
// @has - '//*[@class="docblock"]' 'hello 1 bla'
|
||||||
|
|
||||||
|
/// hello [^foot] bla
|
||||||
|
///
|
||||||
|
/// [^foot]: blabla
|
||||||
|
pub struct S;
|
Loading…
Reference in New Issue
Block a user