Skip to content

Formatting cinaps comments #924

@ghost

Description

The cinaps tool recognises special comments with OCaml code inside them. I wanted to check what the ocamlformat team thought of adding knowledge of the cinaps syntax in ocamlformat so that the code inside such comment could be automatically formatted?

More precisely, cinaps recognises the following two syntaxes:

  • (*$ <ocaml-code> *)
  • (*$ <ocaml-code> $*)

For instance:

(*$ for i = 1 to 3 do Printf.printf "let x%d = %d\n" i i; done *)
let x1 = 1
let x2 = 2
let x3 = 3
(*$*)

To give a bit more context, we use this tool at Jane Street as a principled way of generating and committing parts of ml files. Its use has grown quite a lot since it was introduced a couple of years ago. It's now integrated in Dune via the cinaps stanza and used in a couple of open source projects outside of Jane Street, though Idon't know how much cinaps is used in the wild at the moment.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions