Description
Given the following code:
/// ```rust
/// // Hello!
/// ```
fn main() {}
The current output of rustdoc is:
$ rustdoc src/main.rs --document-private-items
warning: Rust code block is empty
--> src/main.rs:1:5
|
1 | /// ```rust
| _____^
2 | | /// // Hello!
3 | | /// ```
| |_______^
|
= note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default
warning: `rustdoc-sample` (bin "rustdoc-sample" doc) generated 1 warning
Ideally, the output should not give any warnings.
While a standalone comment in a code block is not a common situation, the resulting webpage will highlight it as a comment. I have a code generator, which creates rust code for build scripts. There is a function to generate a comment, and part of the documentation is the resulting comment. Using ```text would solve the warning, but it would not be highlighted as a comment in the resulting webpage. As far as I can tell, this doesn't seem like an empty code block, and I don't think this lint should trigger over it.
Using stable and switching editions doesn't change the output.
Here is a link to a sample repository: https://github.com/macmv/rustdoc-empty-code-block-sample
Metadata
Metadata
Assignees
Labels
Type
Projects
Status