Skip to content

Commit b6c9142

Browse files
authored
Display text of references in doc strings (#1166)
* Display text of references
1 parent cfd6cd7 commit b6c9142

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Unreleased
2+
3+
## Features
4+
5+
- Display text of references in doc strings (#1166)
6+
17
# 1.16.2
28

39
## Fixes

ocaml-lsp-server/src/doc_to_md.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ let rec inline_element_to_inline
6161
let text = inline_element_list_to_inlines inlines in
6262
let meta = loc_to_meta location in
6363
style_inline ~meta style text
64-
| { value = `Reference (_kind, _ref, _inlines); location = _location } ->
64+
| { value = `Reference (kind, ref, inlines); location } -> (
6565
(* TODO: add support for references *)
66-
Inline.Break (Inline.Break.make `Hard, Meta.none)
66+
let meta = loc_to_meta location in
67+
match kind with
68+
| `Simple -> Inline.Code_span (Inline.Code_span.of_string ref.value, meta)
69+
| `With_text -> inline_element_list_to_inlines inlines)
6770
| { value = `Link (link, inlines); location } ->
6871
let text = inline_element_list_to_inlines inlines in
6972
let ref =

ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ describe_opt("textDocument/completion", () => {
254254
255255
External links: {{:https://ocaml.org/} OCaml's official website}
256256
257+
Cross-references: {!List.length} {{!List.length} Replacement text}
258+
257259
{3 Inline Formatting}
258260
259261
{b Bold}, {i Italic}, {e Emphasize}, {^ Superscript}, {_ Subscript}, and [inline code]
@@ -358,6 +360,8 @@ describe_opt("textDocument/completion", () => {
358360
359361
External links: [OCaml's official website](https://ocaml.org/)
360362
363+
Cross-references: \`List.length\` Replacement text
364+
361365
#### Inline Formatting
362366
363367
**Bold**, *Italic*, *Emphasize*, Superscript, Subscript, and \`inline code\`

0 commit comments

Comments
 (0)