@@ -150,8 +150,8 @@ let expandTypes ~file ~package ~supportsMarkdownLinks typ =
150150 `Default )
151151
152152(* Produces a hover with relevant types expanded in the main type being hovered. *)
153- let hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks ?constructor
154- typ =
153+ let hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks ?docstring
154+ ? constructor typ =
155155 let expandedTypes, expansionType =
156156 expandTypes ~file ~package ~supports MarkdownLinks typ
157157 in
@@ -164,7 +164,15 @@ let hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks ?constructor
164164 typeString ^ " \n " ^ CompletionBackEnd. showConstructor constructor
165165 | None -> typeString
166166 in
167- Markdown. codeBlock typeString :: expandedTypes |> String. concat " \n "
167+ let typeString =
168+ match docstring with
169+ | Some [] | None -> Markdown. codeBlock typeString
170+ | Some docstring ->
171+ Markdown. codeBlock typeString
172+ ^ Markdown. divider
173+ ^ (docstring |> String. concat " \n " )
174+ in
175+ typeString :: expandedTypes |> String. concat " \n "
168176 | `InlineType -> expandedTypes |> String. concat " \n "
169177
170178(* Leverages autocomplete functionality to produce a hover for a position. This
@@ -191,10 +199,10 @@ let getHoverViaCompletions ~debug ~path ~pos ~currentFile ~forHover
191199 with
192200 | Some (typ , _env ) ->
193201 let typeString =
194- hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks typ
202+ hoverWithExpandedTypes ~file ~package ~docstring
203+ ~supports MarkdownLinks typ
195204 in
196- let parts = docstring @ [typeString] in
197- Some (Protocol. stringifyHover (String. concat " \n\n " parts))
205+ Some (Protocol. stringifyHover typeString)
198206 | None -> None )
199207 | {env} :: _ -> (
200208 let opens = CompletionBackEnd. getOpens ~debug ~raw Opens ~package ~env in
@@ -277,22 +285,15 @@ let newHover ~full:{file; package} ~supportsMarkdownLinks locItem =
277285 | Const_int64 _ -> " int64"
278286 | Const_bigint _ -> " bigint" ))
279287 | Typed (_ , t , locKind ) ->
280- let fromType ?constructor typ =
281- hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks ?constructor
282- typ
288+ let fromType ?docstring ? constructor typ =
289+ hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks ?docstring
290+ ?constructor typ
283291 in
284- let parts =
285- match References. definedForLoc ~file ~package locKind with
286- | None ->
287- let typeString = t |> fromType in
288- [typeString]
292+ Some
293+ (match References. definedForLoc ~file ~package locKind with
294+ | None -> t |> fromType
289295 | Some (docstring , res ) -> (
290296 match res with
291- | `Declared | `Field ->
292- let typeString = t |> fromType in
293- typeString :: docstring
297+ | `Declared | `Field -> t |> fromType ~docstring
294298 | `Constructor constructor ->
295- let typeString = t |> fromType ~constructor in
296- typeString :: constructor.docstring)
297- in
298- Some (String. concat Markdown. divider parts)
299+ t |> fromType ~docstring: constructor.docstring ~constructor ))
0 commit comments