Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep indent when line doesn't have comment prefix #30

Open
SWW13 opened this issue Jun 7, 2021 · 1 comment
Open

Keep indent when line doesn't have comment prefix #30

SWW13 opened this issue Jun 7, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@SWW13
Copy link

SWW13 commented Jun 7, 2021

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();
}
@daynin daynin added the enhancement New feature or request label Aug 26, 2021
@thisismana
Copy link

thisismana commented Jul 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants