Skip to content

Commit bc8e8fa

Browse files
authored
Rollup merge of rust-lang#46387 - chrisduerr:master, r=QuietMisdreavus
Fix rustdoc 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. I'm not sure if the rustdoc test is written correctly, if there's anything to improve, just let me know. :) This fixes rust-lang#46377. This is how it looks when rendered out now: ![Rendered](https://i.imgur.com/7u8jUAM.png)
2 parents ae24366 + 91a4106 commit bc8e8fa

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: 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
})

Diff for: 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)