From b6c914275ab62e039a8478d6726d6f6f263597be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Saue?= <47693595+AurelienSaue@users.noreply.github.com> Date: Fri, 28 Jul 2023 22:09:32 +0200 Subject: [PATCH] Display text of references in doc strings (#1166) * Display text of references --- CHANGES.md | 6 ++++++ ocaml-lsp-server/src/doc_to_md.ml | 7 +++++-- .../test/e2e/__tests__/textDocument-signatureHelp.ts | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5327552d9..c5a4cbd03 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# Unreleased + +## Features + +- Display text of references in doc strings (#1166) + # 1.16.2 ## Fixes diff --git a/ocaml-lsp-server/src/doc_to_md.ml b/ocaml-lsp-server/src/doc_to_md.ml index a2a80a5d6..1e2880105 100644 --- a/ocaml-lsp-server/src/doc_to_md.ml +++ b/ocaml-lsp-server/src/doc_to_md.ml @@ -61,9 +61,12 @@ let rec inline_element_to_inline let text = inline_element_list_to_inlines inlines in let meta = loc_to_meta location in style_inline ~meta style text - | { value = `Reference (_kind, _ref, _inlines); location = _location } -> + | { value = `Reference (kind, ref, inlines); location } -> ( (* TODO: add support for references *) - Inline.Break (Inline.Break.make `Hard, Meta.none) + let meta = loc_to_meta location in + match kind with + | `Simple -> Inline.Code_span (Inline.Code_span.of_string ref.value, meta) + | `With_text -> inline_element_list_to_inlines inlines) | { value = `Link (link, inlines); location } -> let text = inline_element_list_to_inlines inlines in let ref = diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts index 80c598a69..97ffa66b5 100644 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts +++ b/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts @@ -254,6 +254,8 @@ describe_opt("textDocument/completion", () => { External links: {{:https://ocaml.org/} OCaml's official website} + Cross-references: {!List.length} {{!List.length} Replacement text} + {3 Inline Formatting} {b Bold}, {i Italic}, {e Emphasize}, {^ Superscript}, {_ Subscript}, and [inline code] @@ -358,6 +360,8 @@ describe_opt("textDocument/completion", () => { External links: [OCaml's official website](https://ocaml.org/) + Cross-references: \`List.length\` Replacement text + #### Inline Formatting **Bold**, *Italic*, *Emphasize*, Superscript, Subscript, and \`inline code\`