Issue 24871 - DDoc strips indent in triple slash comments
Summary: DDoc strips indent in triple slash comments
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 trivial
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2024-11-22 08:23 UTC by artha
Modified: 2024-11-25 08:35 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description artha 2024-11-22 08:23:26 UTC
Consider this example file with line comment documentation that contains a code snippet:

```d
import std.stdio;

/// Example
/// ---
/// void main() {
/// 	foreach (i; 0..10) {
/// 		writeln("Hello, world!");
/// 	}
/// }
/// ---
void main() {
    
    writeln("Hello, World!");
    
}
```

When rendered using `dmd -D`, the indent in the snippet is gone:

```d
<pre><code class="code"><span class="keyword">void</span> <span class="psymbol">main</span>() {
<span class="keyword">foreach</span> (i; 0..10) {
writeln(<span class="string_literal">"Hello, world!"</span>);
}
}
</code></pre>

This is not the case if block comments are used.
```
Comment 1 Dlang Bot 2024-11-22 11:58:02 UTC
@ArthaTi created dlang/dmd pull request #17082 "Fix bugzilla issue 24871 - DDoc strips indent in triple slash comments" fixing this issue:

- Fix bugzilla issue 24871 - DDoc strips indent in triple slash comments
  
  Removes code in the lexer responsible for removing leading spaces in
  triple slash doc comments.
  
  This affects the test file for issue 14413; two more spaces appear, but
  they are not significant in the HTML output.

https://github.com/dlang/dmd/pull/17082
Comment 2 Dlang Bot 2024-11-25 08:35:20 UTC
dlang/dmd pull request #17082 "Fix bugzilla issue 24871 - DDoc strips indent in triple slash comments" was merged into master:

- 303d95f680b6533885f28b6ec1651c0fe4e4a905 by Artha:
  Fix bugzilla issue 24871 - DDoc strips indent in triple slash comments
  
  Removes code in the lexer responsible for removing leading spaces in
  triple slash doc comments.
  
  This affects the test file for issue 14413; two more spaces appear, but
  they are not significant in the HTML output.

https://github.com/dlang/dmd/pull/17082