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

New syntax (*= ... *) for verbatim comments #2028

Merged
merged 6 commits into from
Mar 4, 2022

Conversation

gpetiot
Copy link
Collaborator

@gpetiot gpetiot commented Feb 28, 2022

Follow-up of #1810 and #2009

Introduces a new syntax (*= ... *) to print comments "verbatim".

Here is the preview on tezos' code: https://gitlab.com/tezos/tezos/-/merge_requests/4587

@gpetiot gpetiot changed the title New syntax (*= *) for verbatim comments New syntax (*= ... *) for verbatim comments Feb 28, 2022
@gpetiot
Copy link
Collaborator Author

gpetiot commented Mar 2, 2022

Any preference between this syntax and #2009?

@raphael-proust
Copy link

What's the interaction with mli docstrings? Specifically,

  • Do I ever need this new syntax for special comments ((**-*)) in an mli?
  • Do they show up in the generated html documentation?
  • Does it break other markup features of the html documentation generation? What does (**= {1 …} *) render to?

@gpetiot
Copy link
Collaborator Author

gpetiot commented Mar 3, 2022

What's the interaction with mli docstrings? Specifically,

* Do I ever need this new syntax for special comments (`(**`-`*)`) in an mli?

No, by default docstrings are not formatted unless --parse-docstrings is set, which is not the case on tezos codebase.

* Do they show up in the generated html documentation?

I think only docstrings comments appear in the html doc, not the regular comments.

* Does it break other markup features of the html documentation generation? What does `(**= {1 …} *)` render to?

It would break the odoc parser, we don't plan to add this syntax for docstrings since we do not format them by default (see 1st point).

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a syntax like this.

lib/Cmts.ml Outdated Show resolved Hide resolved
@gpetiot
Copy link
Collaborator Author

gpetiot commented Mar 3, 2022

I'm about to merge this PR, @raphael-proust is everything alright with you?

@raphael-proust
Copy link

Yep. That's fine.

@gpetiot gpetiot merged commit ddca4a3 into ocaml-ppx:main Mar 4, 2022
@gpetiot gpetiot deleted the eq-verbatim-comment branch March 4, 2022 09:44
mseri pushed a commit to ocaml/opam-repository that referenced this pull request May 26, 2022
CHANGES:

### Removed

- Profiles `compact` and `sparse` are now removed (ocaml-ppx/ocamlformat#2075, @gpetiot)
- Options `align-cases`, `align-constructors-decl` and `align-variants-decl` are now removed (ocaml-ppx/ocamlformat#2076, @gpetiot)
- Option `disable-outside-detected-project` is now removed (ocaml-ppx/ocamlformat#2077, @gpetiot)

### Deprecated

- Cancel the deprecations of options that are not set by the preset profiles (ocaml-ppx/ocamlformat#2074, @gpetiot)

### Bug fixes

- emacs: Remove temp files in the event of an error (ocaml-ppx/ocamlformat#2003, @gpetiot)
- Fix unstable comment formatting around prefix op (ocaml-ppx/ocamlformat#2046, @gpetiot)

### Changes

- Qtest comments are not re-formatted (ocaml-ppx/ocamlformat#2034, @gpetiot)
- ocamlformat-rpc is now distributed through the ocamlformat package (ocaml-ppx/ocamlformat#2035, @Julow)
- Doc-comments code blocks with a language other than 'ocaml' (set in metadata) are not parsed as OCaml (ocaml-ppx/ocamlformat#2037, @gpetiot)
- More comprehensible error message in case of version mismatch (ocaml-ppx/ocamlformat#2042, @gpetiot)
- The global configuration file (`$XDG_CONFIG_HOME` or `$HOME/.config`) is only applied when no project is detected, `--enable-outside-detected-project` is set, and no applicable `.ocamlformat` file has been found. Global and local configurations are no longer used at the same time. (ocaml-ppx/ocamlformat#2039, @gpetiot)
- Set `ocaml-version` to a fixed version (4.04.0) by default to avoid reproducibility issues and surprising behaviours (ocaml-ppx/ocamlformat#2064, @kit-ty-kate)
- Split option `--numeric=X-Y` into `--range=X-Y` and `--numeric` (flag). For now `--range` can only be used with `--numeric`. (ocaml-ppx/ocamlformat#2073, ocaml-ppx/ocamlformat#2082, @gpetiot)

### New features

- New syntax `(*= ... *)` for verbatim comments (ocaml-ppx/ocamlformat#2028, @gpetiot)
- Preserve the begin-end construction in the AST (ocaml-ppx/ocamlformat#1785, @hhugo, @gpetiot)
- Preserve position of comments located after the semi-colon of the last element of lists/arrays/records (ocaml-ppx/ocamlformat#2032, @gpetiot)
- Option `--print-config` displays a warning when an .ocamlformat file defines redundant options (already defined by a profile) (ocaml-ppx/ocamlformat#2084, @gpetiot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants