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

Doc comments on function parameters #927

Open
lukemaurer opened this issue Feb 10, 2023 · 3 comments
Open

Doc comments on function parameters #927

lukemaurer opened this issue Feb 10, 2023 · 3 comments
Labels
enhancement New feature or request parser

Comments

@lukemaurer
Copy link
Contributor

It would be nice to attach an odoc comment to a function parameter rather than having to mention each parameter in the comment for the whole function. Something like:

(** Do the special thing. *)
val do_it :
  (** What does the thing *)
  t ->
  (** What the thing is done to *)
  target:t ->
  (** The special sauce to use *)
  sauce:Sauce.t ->
  unit

(There's already a wrinkle in that putting the arrows at the starts of lines would would probably cause the comments to attach to different parameters.)

@lpw25
Copy link
Contributor

lpw25 commented Feb 10, 2023

I had thought that the compiler already collected these, but looking at the parser it seems not. I think that the attachment rules consistent with the existing ones would have it as:

(** Do the special thing. *)
val do_it :
  t -> (** What does the thing *)
  target:t ->  (** What the thing is done to *)
  sauce:Sauce.t -> (** The special sauce to use *)
  unit

and also including support for:

(** Do the special thing. *)
val do_it :
  t (** What does the thing *)
  -> target:t  (** What the thing is done to *)
  -> sauce:Sauce.t (** The special sauce to use *)
  -> unit

similar to how it's done for ; in records and object types.

@lukemaurer
Copy link
Contributor Author

Makes sense. Certainly, consistency with record syntax is ideal.

@dbuenzli dbuenzli added parser enhancement New feature or request labels Mar 2, 2023
@trefis
Copy link
Contributor

trefis commented Aug 23, 2023

The attachment rules are indeed "incomplete": they are only there for labelled/optional parameters.
But for those they are already there, and it would be nice if odoc propagated them already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser
Projects
None yet
Development

No branches or pull requests

4 participants