@@ -150,8 +150,8 @@ let expandTypes ~file ~package ~supportsMarkdownLinks typ =
150
150
`Default )
151
151
152
152
(* 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 =
155
155
let expandedTypes, expansionType =
156
156
expandTypes ~file ~package ~supports MarkdownLinks typ
157
157
in
@@ -164,7 +164,15 @@ let hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks ?constructor
164
164
typeString ^ " \n " ^ CompletionBackEnd. showConstructor constructor
165
165
| None -> typeString
166
166
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 "
168
176
| `InlineType -> expandedTypes |> String. concat " \n "
169
177
170
178
(* Leverages autocomplete functionality to produce a hover for a position. This
@@ -191,10 +199,10 @@ let getHoverViaCompletions ~debug ~path ~pos ~currentFile ~forHover
191
199
with
192
200
| Some (typ , _env ) ->
193
201
let typeString =
194
- hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks typ
202
+ hoverWithExpandedTypes ~file ~package ~docstring
203
+ ~supports MarkdownLinks typ
195
204
in
196
- let parts = docstring @ [typeString] in
197
- Some (Protocol. stringifyHover (String. concat " \n\n " parts))
205
+ Some (Protocol. stringifyHover typeString)
198
206
| None -> None )
199
207
| {env} :: _ -> (
200
208
let opens = CompletionBackEnd. getOpens ~debug ~raw Opens ~package ~env in
@@ -277,22 +285,15 @@ let newHover ~full:{file; package} ~supportsMarkdownLinks locItem =
277
285
| Const_int64 _ -> " int64"
278
286
| Const_bigint _ -> " bigint" ))
279
287
| 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
283
291
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
289
295
| Some (docstring , res ) -> (
290
296
match res with
291
- | `Declared | `Field ->
292
- let typeString = t |> fromType in
293
- typeString :: docstring
297
+ | `Declared | `Field -> t |> fromType ~docstring
294
298
| `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