fundoc
fundoc copied to clipboard
Keep indent when line doesn't have comment prefix
It would be nice if fundoc could also keep indent when no comment prefix is used. I prefer using comment blocks without prefix as for me they are cleaner to read and write.
This could be implemented by trimming the lines by the indent of the first comment line. (In the example below this would be 4 spaces prepending @Article Struct
).
I'm not sure if there are edge cases I haven't thought of, it could also be optional with a setting.
impl Struct {
/**
@Article Struct
## function
Example:
```rust
fn main() {
// call function
function();
}
```
*/
fn function() { }
}
Would result in:
## function
Example:
```rust
fn main() {
// call function
function();
}
My workaround is to add the comment prefix *
only to to the code blocks to keep the indent. As for the text blocks, I'm totally with you removing those prefixes for readability.
Indentation is quite tricky using this doc generator, same with @CodeBlockStart
and @CodeBlockEnd
which come with the same issue (stripping all whitespace and messing up indentation)
update: tried to update the parser.rs for this purpose (at least to keep the indentation for @CodeBlockStart
and @CodeBlockEnd
). Man, this is some wild state machine. It kinda worked, but I destroyed my file structure in the process.