odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Doc comments with `*` at the beginning of each lines.

Open panglesd opened this issue 1 year ago • 2 comments

I've seen several libraries use this style of comments:

    (** [decode_float dec buff ofs len] decodes [len] samples in each channel and puts
      * the result in [buff] starting at position [ofs].
      * @raise Hole_in_data if there was an interruption of the data.
      * @raise Invalid_parameters if all the data cannot fit in the buffer starting at the given position.
      *)

However, the * at the beginning of lines confuse odoc. Should this be dealt in the odoc parser, or upstream in OCaml?

Here are some examples, taken from @jonludlam's list in #1138:

  • ocaml-vorbis https://github.com/savonet/ocaml-vorbis/blob/v0.8.0/src/vorbis.mli#L223
  • ocaml-leveldb https://github.com/mfp/ocaml-leveldb/blob/1.3.0/src/levelDB.mli#L255
  • labltgtk https://github.com/garrigue/lablgtk/blob/3.1.5/src-rsvg2/rsvg2.mli#L45
  • gapi-ocaml https://github.com/astrada/gapi-ocaml/blob/v0.4.5-opam/src/netstring/neturl.mli#L423
  • ocaml-duppy https://github.com/savonet/ocaml-duppy/blob/v0.9.4/src/duppy.mli#L84
  • devkit https://github.com/ahrefs/devkit/blob/1.20240429/ocamlnet_lite/netconversion.mli#L346
  • csvfields https://github.com/janestreet/csvfields/blob/v0.17.0/ocaml-csv/lib/csv.mli#L44
  • FrontC https://github.com/BinaryAnalysisPlatform/FrontC/blob/v4.1.0/frontc/frontc.ml#L76

panglesd avatar Oct 29 '24 15:10 panglesd

I'm in favor of doing this in the ocaml parser directly. This would also make ocamlformat's job easier (assuming there is a flag to tell us whether there is a column of * to be printed or not).

gpetiot avatar Oct 30 '24 12:10 gpetiot

I think that's a good argument to do it in the ocaml parser. That might complicate upstream though, we should ask what the maintainers think.

panglesd avatar Oct 30 '24 14:10 panglesd