merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Include documentation of values in the type of modules

Open arvidj opened this issue 8 months ago • 1 comments

If I do type-enclosing on a module, I see the interface, but not the documentation of the functions. It'd be nice if the type could also include the doc comments (or an excerpt for brevity).

For instance, if I have the module:

module Foo : sig
  (** This is the [foo] module. *)

  (** A [bar] is a string that might be useful. *)
  val bar : string
end = struct
  let bar = "test"
end

let _ = Foo.bar

If I do type-enclosing on Foo, I get sig val bar : string end.

If I'm using ocaml-eglot, and put my cursor on Foo, I get:

sig
  val bar : string
end

------------

This is the [foo] module.

What I'd like to have is something like::

sig
  (** A [bar] is a string that might be useful. *)
  val bar : string
end

------------

This is the [foo] module.

This would be useful to me (and perhaps to others), as I often do type-enclosing on a module when I'm looking for a particular value in that module. However, without the doc string, I'm never quite sure if I found the right thing. I typically end up jumping to the .mli file of the module instead so that I can the signature along with the docs.

arvidj avatar Apr 04 '25 14:04 arvidj

While I understand the motivation, I don't think this is the role of the type-enclosing command. However, using ocaml-eglot, using ocaml-eglot-search-declaration with, for example, List, all List functions will be displayed with their documentation.

xvw avatar Apr 09 '25 19:04 xvw