-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Markdown fails to be interpreted after #[doc] attribute is used #42760
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
|
A conversation on IRC (that i wasn't actually part of Rustdoc has a few passes it performs on doc comments before it hands the text to the markdown processor. The ones relevant to this discussion are The former is what @Havvy was thinking of, since it implies that rustc totally allows multiples of the same attribute on the same item. As a single However, the latter is what is really at fault here. SpaceManiac on IRC suggested adding a leading space to the spliced-in doc attribute, and that allows the whole doc text to be handled correctly. Without that leading space there, /// Item docs.
///
///Hello there!
///
/// # Example
///
/// ```rust
/// // some code here
/// ```
pub struct SomeStruct; Note at the "Hello there!" line does not have a leading space on it. I would assume that by the time rustdoc sees all the docs, it doesn't have any indication of whether the line came from a doc comment or a raw doc attribute. If the compiler has that information, then it may be possible to pass that over to rustdoc, which can then ignore "raw doc attributes" in the |
I'll take a look once I have enough time. |
rustdoc: include external files in documentation (RFC 1990) Part of rust-lang/rfcs#1990 (needs work on the error reporting, which i'm deferring to after this initial PR) cc #44732 Also fixes #42760, because the prep work for the error reporting made it easy to fix that at the same time.
Consider the following structure with documentation:
At present,
rustdoc
will render this as:When the following is expected:
In short, after a
#[doc]
attribute, a markdown header is not interpreted as markdown.This also applies to headers declared using
===
, whereis rendered by
rustdoc
as:as opposed to the expected:
I wouldn't be surprised if this is a more systemic issue and additional markdown syntax is interpreted literally as well.
The text was updated successfully, but these errors were encountered: