Skip to content

No way to not comment a line beginning with a # in rustdoc #41783

Closed
@jFransham

Description

@jFransham

I have a doctest in my shell_parse crate that includes a shell-style comment at the start of a line, inside a code block. Minimal example:

/// ```rust
/// let test_string = r#"
/// # Help me
/// "#;
/// ```

This causes the hash to be stripped out in cargo doc output (which is annoying, because it's part of the example), and causes the parsing to fail and the doctest to fail as a result. Using the same code in a normal test does not fail, and replacing the # with ## causes it to appear in documentation output and the test to succeed. This is the approach I've taken as a workaround, but it's not what I actually want.

Metadata

Metadata

Labels

T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions