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

Bug: parse-docstrings with janestreet profile unexpected behavior #2643

Closed
mbarbin opened this issue Jan 6, 2025 · 4 comments
Closed

Bug: parse-docstrings with janestreet profile unexpected behavior #2643

mbarbin opened this issue Jan 6, 2025 · 4 comments

Comments

@mbarbin
Copy link
Contributor

mbarbin commented Jan 6, 2025

Consider this file:
a.ml:

(* Hello.
 * This is a comment with asterix chars
 * at the beginning of every lines.
 *
 * Yay!
 *)
let () = ()

I'm trying to enable parse-docstrings=true on it.

It formats well with the default profile:

$ ocamlformat --enable-outside-detected-project --parse-docstrings a.ml
(* Hello.
 * This is a comment with asterix chars
 * at the beginning of every lines.
 *
 * Yay!
 *)
let () = ()

However note how the rest of the lines get shifted to the right when using the janestreet profile:

$ ocamlformat --enable-outside-detected-project --parse-docstrings --profile=janestreet a.ml
(* Hello.
   * This is a comment with asterix chars
   * at the beginning of every lines.
   *
   * Yay!
*)
let () = ()

Sounds like perhaps 2 bugs:

  • parse-docstrings shouldn't attempt to edit this comment, because it is not a docstring comment
  • the left-padding should align with what the default profile does, which respects the original intent

If you know which option from the profile is causing this, perhaps I could look into tweaking that in my configs, if this doesn't come with other downsides, as a temporary workaround? Thanks!

@Julow
Copy link
Collaborator

Julow commented Jan 7, 2025

Similarly to #2642, formatting of comments with the janestreet profile is special and it doesn't support asterisk-prefixed comments. The indentation is added because each * is parsed as a word.

@mbarbin
Copy link
Contributor Author

mbarbin commented Jan 7, 2025

OK. It looks like the instances I have all look like headers (e.g. LICENSE), so I might use something like what headache produces, which does work currently.

(* Hello.                                    *)
(* This is a comment with asterisk chars     *)
(* at the beginning of every lines.          *)
(*                                           *)
(* Yay!                                      *)
let () = ()

Feel free to close the issue as "won't do" if not relevant, I'm happy with the workaround personally (up to you and/or other users). Thanks!

@mbarbin
Copy link
Contributor Author

mbarbin commented Jan 7, 2025

Oh, I hadn't seen that you fixed it already, nice! That's one less thing to think about when/if changing profile, so probably for the best. Thanks!

@Julow
Copy link
Collaborator

Julow commented Jan 8, 2025

Hi! I fixed that in #2645 at the same time as the wrap-comments bug as the two had a common root cause.
Thanks for submitting the issue!

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

No branches or pull requests

2 participants