-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rustdoc does not display a table in some cases involving whitespaces #65802
Comments
The table was not renderd correctly because of rust-lang/rust#65802
The reason this happens is that rustdoc needs to determine what indentation you're using in your doc comments, but you're mixing two different indentation levels, so it picks the smaller of the two (i.e., indent of zero). Thus, no indentation is stripped. Since Markdown doesn't recognize indented tables, the table that has a space before it is rendered wrong. If you instead use a consistent indentation level for each item's (i.e., each function, module, etc.) documentation, you'll see that the issue goes away. In other words, the following renders both tables correctly: /// # Lorem ispum cratus test amet
///
///This table has no space between the `//!` and the table start character `|`:
///
///| a | s | d | f | g |
///|---|---|---|---|---|
///| h | j | k | l | ; |
///
pub fn foo() {}
/// # Lorem ispum cratus test amet
///
/// This table has space between the `//!` and the table start character `|`:
///
/// | a | s | d | f | g |
/// |---|---|---|---|---|
/// | h | j | k | l | ; |
///
pub fn bar() {} I'm not sure if rustdoc can necessarily do better than this while respecting that different users may use different indentation levels for their doc comments. It's just like how Python doesn't allow you to mix 2-space and 4-space indentation or tab and space-based indentation in a file; there's no good way to disambiguate. |
Note that the incorrect table rendering from the commit fed93af that linked to this issue is due to the incorrect double-comment One possible change we could consider is to base the indentation of the block on only the very first line. We could then report warnings if the indentation were less than that on later lines. |
Another question is how we handle doc comments like the following /// fn main() {}
pub fn foo() {} Do we consider this to be the unindented text |
This was fixed in pulldown-cmark, so this now works correctly as of #127127. |
When placing a space between the line comment start
//!
and the start of the table|
, the table does not render properly:If you remove the spaces, it works:
I have made a example repo.
To test this, just clone the repo and run
cargo doc --open
I have validated that this bug affects stable, beta and nightly
The text was updated successfully, but these errors were encountered: