Skip to content

Feature request: --parse-docstrings and --wrap-comments shouldn't result in "inline styles" having no line-breaks #969

@ELLIOTTCABLE

Description

@ELLIOTTCABLE

I'm really happy to see a bunch of the improvements happening with docstring auto-formatting (especially #941! 🍿).

In preperation, I've started enabling --parse-docstrings in my projects, and I've run into this little annoyance:

Configuration:

parse-docstrings = true
wrap-comments = true

Input (previous behaviour, without parse-docstrings):

(*
    ...

    Any function that accesses either the {e value} of a flag, or accesses the
    {!positionals} at all, is going to “resolve” that word in the original source. If the
    word was ambiguously positioned, {e that access will result in the datastructure
    changing} — to prevent the word later becoming resolved in an incompatible way.

    ...
*)

Output (new behaviour, with parse-docstrings added):

(*
    ...

    Any function that accesses either the {e value} of a flag, or accesses the
    {!positionals} at all, is going to “resolve” that word in the original source. If
    the word was ambiguously positioned,
    {e that access will result in the datastructure changing} — to prevent the word
    later becoming resolved in an incompatible way.

    ...
*)

Note that ocamlformat has gone to some lengths here to ensure that the {e …} emphasis-block is on its own line, and doesn't contain a linebreak. There's some ocamldoc constructs (code-spans, for instance), which must not contain linebreaks; and for them, such backflips to ensure compatibility make sense — but in cases like this (especially when one might need to make long, inline formatting declarations!), it's perfectly reasonable for them to be formatted as running text, instead of separated onto their own lines, right?

Just a nitpick! (As an aside, ocamlformat has come so far in the last year, I'm genuinely impressed. Keep up the great work, folks! It's appreciated!)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions