ocaml-ppx / ocamlformat

Auto-formatter for OCaml code
MIT License
622 stars 175 forks source link

How to wrap documentation comments? #2546

Closed hirrolot closed 2 months ago

hirrolot commented 5 months ago

I'm seeing the option wrap-comments, but when set to true, it doesn't wrap documentation comments (only regular comments). Is there any way to wrap documentation comments?

From doc/manpage_ocamlformat.mld:

       --wrap-comments
           Wrap comments and docstrings. Comments and docstrings are divided
           into paragraphs by open lines (two or more consecutive newlines),
           and each paragraph is wrapped at the margin. Multi-line comments
           with vertically-aligned asterisks on the left margin are not
           wrapped. Consecutive comments with both left and right margin
           aligned are not wrapped either. The flag is unset by default.
Julow commented 2 months ago

Sorry for the slow reply. The option to format documentation comments is --parse-docstrings and there's no way to just wrap docstrings without applying the full formatting on them. I corrected the doc in https://github.com/ocaml-ppx/ocamlformat/pull/2568

Julow commented 2 months ago

I'll close this issue. Feel free to re-open if you have any questions.

hirrolot commented 1 month ago

Even with parse-docstrings set to true (in my config file), documentation strings are not wrapped. Am I doing something wrong? My config file is:

version = 0.26.2
profile = janestreet
module-item-spacing = sparse
let-binding-indent = 4
max-indent = 4
wrap-comments = true
parse-docstrings = true