fundoc icon indicating copy to clipboard operation
fundoc copied to clipboard

Keep indent when line doesn't have comment prefix

Open SWW13 opened this issue 3 years ago • 1 comments

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();
}

SWW13 avatar Jun 07 '21 12:06 SWW13

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.

thisismana avatar Jul 21 '22 08:07 thisismana