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

Respect original comment indentation for code blocks #132

Closed
bobbypriam opened this issue Apr 18, 2018 · 2 comments
Closed

Respect original comment indentation for code blocks #132

bobbypriam opened this issue Apr 18, 2018 · 2 comments
Labels

Comments

@bobbypriam
Copy link
Contributor

(I hope the title is clear enough.)

Basically code inside {[ ... ]} blocks are indented from the start of the line. It would be nicer if it can respect the indent of the first {[ token.

E.g. instead of having to write this:

(** A section of introduction.

    Some other introduction here, more and more sentences. The code block under
    this should be indented from the start:

{[
let foo = 10
let _ = print_endline (string_of_int foo)
]}

    Another sentence to close the introduction. *)

It would be great if we can write this:

(** A section of introduction.

    Some other introduction here, more and more sentences. Note that the code block
    has the same indentation as the other comments.

    {[
    let foo = 10
    let _ = print_endline (string_of_int foo)
    ]}

    Another sentence to close the introduction. *)

This is particularly annoying if we want to document an example of a function inside an inner module (2 or more indentation-level deep). Or was there another way of preferred docs indentation?

@aantron
Copy link
Contributor

aantron commented Apr 18, 2018

Agreed 100%, has been on my list for a long time, too :)

I would suggest to do the indentation from the left-most column of the code, so if someone has an instinct to write

(** A section of introduction.

    Some other introduction here, more and more sentences. Note that the code block
    has the same indentation as the other comments.

    {[
      let foo = 10
      let _ = print_endline (string_of_int foo)
    ]}

    Another sentence to close the introduction. *)

...the output will still be as they would expect.

@bobbypriam
Copy link
Contributor Author

Great to hear! And yes using the left-most column also works and would be cleaner.

One thing to consider is whether we want the same behavior on verbatim blocks ({v ... v}). I'm guessing consistency would be preferred here, but I could be wrong.

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

No branches or pull requests

3 participants