Skip to content

Commit 91a4106

Browse files
committed
Fix rustoc item summaries that are headers
Rustoc item summaries that are headers were not displayed at all because they started with whitespace. This PR fixes this and now removes the whitespace and then displays the block.
1 parent 0a2e9ad commit 91a4106

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustdoc/html/render.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,9 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
18191819

18201820
fn shorter<'a>(s: Option<&'a str>) -> String {
18211821
match s {
1822-
Some(s) => s.lines().take_while(|line|{
1822+
Some(s) => s.lines()
1823+
.skip_while(|s| s.chars().all(|c| c.is_whitespace()))
1824+
.take_while(|line|{
18231825
(*line).chars().any(|chr|{
18241826
!chr.is_whitespace()
18251827
})

src/test/rustdoc/issue-46377.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// @has 'issue_46377/index.html' '//*[@class="docblock-short"]' 'Check out this struct!'
12+
/// # Check out this struct!
13+
pub struct SomeStruct;

0 commit comments

Comments
 (0)