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: Spaces added to preformatted code style docstring elements #1732

Closed
jberdine opened this issue Jul 21, 2021 · 5 comments
Closed

Bug: Spaces added to preformatted code style docstring elements #1732

jberdine opened this issue Jul 21, 2021 · 5 comments

Comments

@jberdine
Copy link
Collaborator

Describe the bug
Formatting code such as:

type sp =
  | Cut  (** {[@,]} *)

adds spaces within the preformatted code element, producing

type sp =
  | Cut  (** {[ @, ]} *)

How to Reproduce
Change the Cut docstring in Fmt.mli as above and make test.

@Julow
Copy link
Collaborator

Julow commented Jul 21, 2021

That's the formatting we expect, to separate the heavier syntax {[ from the bigger piece of code. Perhaps the source can be changed to use [ ... ] instead, which is expected to contain a small bit of code and isn't formatted by ocamlformat.

Note that this code block will appear heavy in Odoc's output.

@gpetiot
Copy link
Collaborator

gpetiot commented Jul 21, 2021

I don't know what would look better in odoc's output, I'm neutral regarding using wrap "[@;<1 2>" "@ ]" or wrap "[@;<0 2>" "@,]", but I admit having spaces added can be surprising

@jberdine
Copy link
Collaborator Author

Maybe it is just me, but my interpretation of "preformatted" in the spec makes me think that adding spaces is quite surprising.

@Julow
Copy link
Collaborator

Julow commented Jul 21, 2021

Odoc doesn't follow ocamldoc in a lot of cases. Odoc is not sensitive to whitespaces around {[ and ]} and to the indentation of the whole block. It's reasonable to add spaces and newlines here and to indent the whole block. (we do all this)

@Julow
Copy link
Collaborator

Julow commented Dec 18, 2024

I think this can be closed since the parsing and formatting of code spans changed ocaml/odoc#1085

@Julow Julow closed this as completed Dec 18, 2024
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

3 participants