Skip to content

Doc comments with code at beginning includes all of code in doc output #54975

Closed

Description

@Munksgaard

Putting code at the top of a docstring results in the entire code bit being included in the short summary of the docstring.

The following code

/// ```
/// foo
/// bar
/// ```
pub struct Foo;

Results in the following foo/index.html page

bla

Having large code samples there generates ugly documentation. For instance, I ran across the following while working through #54824 (in src/test/rustdoc/issue-47183.rs)

bla2

Which is generated by the following code:

/// ```no_run
/// # # space
/// # comment
/// ## single
/// ### double
/// #### triple
/// ##[outer]
/// ##![inner]
/// ```
pub struct Foo;

My suggestion would be that rustdoc should detect whether the first line of a doc comment is the beginning of a code block, and if so, it should leave it out of the "preview".

Activity

  1. added
    T-rustdoc
    on Oct 10, 2018
  2. GuillaumeGomez commented on Oct 13, 2018

    @GuillaumeGomez
    Member

    Makes sense. I'll send a patch as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

T-rustdoc

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions