Skip to content
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

Paragraphs in block doc comments are broken #62552

Closed
Cldfire opened this issue Jul 10, 2019 · 6 comments · Fixed by #62789
Closed

Paragraphs in block doc comments are broken #62552

Cldfire opened this issue Jul 10, 2019 · 6 comments · Fixed by #62789
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Cldfire
Copy link
Contributor

Cldfire commented Jul 10, 2019

I returned to a crate of mine for the first time in quite a while and was perplexed to see that all of the paragraphs in my doc comments were gone, and instead had been turned into line breaks (so all of the paragraphs were squashed together).

Upon investigation I discovered that this was due to my usage of block doc comments (/** */) rather than the more common /// style. It occurs on both the current stable and nightly release.

Source comment:

    /**
    Gets the checksum of the config stored in this `Device`'s infoROM.
    
    Can be used to make sure that two GPUs have the exact same configuration.
    The current checksum takes into account configuration stored in PWR and ECC
    infoROM objects. The checksum can change between driver released or when the
    user changes the configuration (e.g. disabling/enabling ECC).
    
    # Errors

    * `CorruptedInfoROM`, if this `Device`'s checksum couldn't be retrieved due to infoROM corruption
    * `Uninitialized`, if the library has not been successfully initialized
    * `NotSupported`, if this `Device` does not support this feature
    * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
    * `Unknown`, on any unexpected error
    
    # Device Support

    Supports all devices with an infoROM.
    */

Output when using block doc comments:
image

And the HTML:
image

Output after deleting the block doc comment start / end syntax and placing /// in front of each line (this is the expected output for both):
image

And the HTML for that:
image

@Centril Centril added C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 10, 2019
@Centril
Copy link
Contributor

Centril commented Jul 10, 2019

@Cldfire Could you try bisecting the regression to an old Rust version to see when it about happened?

@Cldfire
Copy link
Contributor Author

Cldfire commented Jul 10, 2019

Yeah, I plan on investigating this and putting a PR together today.

@Cldfire
Copy link
Contributor Author

Cldfire commented Jul 11, 2019

Update: I've pinpointed the cause of the issue to #60140 (commit 3030164). The broken behavior was introduced by the upgrade to pulldown-cmark 0.4.1.

I looked over the commit and nothing stood out to me as being the potential cause, which implies that the issue is within pulldown-cmark itself. In any case, I don't really have the time to go digging deeper into the library at the moment; perhaps someone with knowledge in this area has an idea of what specifically could be responsible for this?

@Cldfire
Copy link
Contributor Author

Cldfire commented Jul 11, 2019

I investigated a little more and found out that this issue appears only when I have whitespace in the blank lines between paragraphs (something that my editor inserts due to how it handles indentation).

Let's work from this example.

/**
This is a doc comment!

It should have blank lines.

Between these paragraphs.
*/
pub fn a_function() {

}

Documenting this results in:
image

Correct!

Indenting all lines of the comment (like you would to align the comment with the indent of a method in an impl block, for instance):

    /**
    This is a doc comment!

    It should have blank lines.

    Between these paragraphs.
    */
pub fn a_function() {

}

Doc output:
image

Correct again!

However, if I add indentation in the blank lines (screenshot from editor):
image

The output is broken:
image

The same exact behavior happens with /// comments, actually. Inserting > 3 spaces in a blank line between a paragraph replaces the blank line with a line break. This also does not occur on 1.35.0 (before the pulldown-cmark upgrade). On 1.35.0 I can insert as much whitespace as I want between paragraphs and it doesn't turn into a line break.

So I guess this is less "paragraphs are broken in block doc comments" and more "the way pulldown-cmark handles whitespace changed." The question now is, is the new behavior correct? If so this issue can be closed and I will adjust my crate accordingly (aka remove all usages of block doc comments, because this particular behavior would make them far more of a hassle to use than what they're worth).

@ehuss
Copy link
Contributor

ehuss commented Jul 11, 2019

is the new behavior correct?

I do not think so. My reading of the commonmark spec is that a "blank line" may contain spaces. I have filed pulldown-cmark/pulldown-cmark#370 for this issue.

@Cldfire
Copy link
Contributor Author

Cldfire commented Jul 11, 2019

Cool, thanks!

bors added a commit that referenced this issue Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants