From 68fbc5572b1288869d785c9aabb2e8cf59e8f3c1 Mon Sep 17 00:00:00 2001 From: Ulysse <5031221+voodoos@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:06:43 +0200 Subject: [PATCH] hover: use `***` to print dividers. (#1318) * hover: use `***` to print dividers. vscode renderer treats the section before a `---` divider as a title. --- CHANGES.md | 4 +++- ocaml-lsp-server/src/hover_req.ml | 2 +- ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml | 4 ++-- .../test/e2e/__tests__/ocamllsp-hoverExtended.ts | 4 ++-- .../test/e2e/__tests__/textDocument-hover.test.ts | 6 +++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ec7790ea3..9ef6c41c3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -55,7 +55,7 @@ - Disable automatic completion and signature help inside comments (#1246) - Includes a new optional/configurable option to toggle syntax documentation. If - toggled on, allows display of sytax documentation on hover tooltips. Can be + toggled on, allows display of syntax documentation on hover tooltips. Can be controlled via environment variables and by GUI for VS code. (#1218) - For completions on labels that the LSP gets from merlin, take into account @@ -69,6 +69,8 @@ - Fix parenthesizing of function types in `SignatureHelp` (#1296) +- Fix syntax documentation rendering (#1318) + # 1.17.0 ## Fixes diff --git a/ocaml-lsp-server/src/hover_req.ml b/ocaml-lsp-server/src/hover_req.ml index 8ff2c25ea..c1fcad48d 100644 --- a/ocaml-lsp-server/src/hover_req.ml +++ b/ocaml-lsp-server/src/hover_req.ml @@ -193,7 +193,7 @@ let hover_at_cursor parsetree (`Logical (cursor_line, cursor_col)) = in !result -let print_dividers sections = String.concat ~sep:"\n---\n" sections +let print_dividers sections = String.concat ~sep:"\n***\n" sections let format_as_code_block ~highlighter strings = sprintf "```%s\n%s\n```" highlighter (String.concat ~sep:" " strings) diff --git a/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml b/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml index 116a0e22f..6c1d5a1e6 100644 --- a/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml +++ b/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml @@ -82,7 +82,7 @@ type color = Red|Blue { "contents": { "kind": "plaintext", - "value": "type color = Red | Blue\n---\n`syntax` Variant Type: Represent's data that may take on multiple different forms.. See [Manual](https://v2.ocaml.org/releases/4.14/htmlman/typedecl.html#ss:typedefs)" + "value": "type color = Red | Blue\n***\n`syntax` Variant Type: Represent's data that may take on multiple different forms.. See [Manual](https://v2.ocaml.org/releases/4.14/htmlman/typedecl.html#ss:typedefs)" }, "range": { "end": { "character": 21, "line": 1 }, @@ -129,7 +129,7 @@ type t = .. { "contents": { "kind": "plaintext", - "value": "type t = ..\n---\n`syntax` Extensible Variant Type: Can be extended with new variant constructors using `+=`.. See [Manual](https://v2.ocaml.org/releases/4.14/htmlman/extensiblevariants.html)" + "value": "type t = ..\n***\n`syntax` Extensible Variant Type: Can be extended with new variant constructors using `+=`.. See [Manual](https://v2.ocaml.org/releases/4.14/htmlman/extensiblevariants.html)" }, "range": { "end": { "character": 11, "line": 1 }, diff --git a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts index 912654ca5..868f4a846 100644 --- a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts +++ b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts @@ -135,7 +135,7 @@ Object { "value": "\`\`\`ocaml 'a -> 'a \`\`\` ---- +*** This function has a nice documentation", }, "range": Object { @@ -211,7 +211,7 @@ Object { "value": "\`\`\`ocaml int -> int -> int \`\`\` ---- +*** This function has a nice documentation. It performs division of two integer numbers. diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts index 0c6148440..f341b04de 100644 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts +++ b/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts @@ -133,7 +133,7 @@ Object { "value": "\`\`\`ocaml 'a -> 'a \`\`\` ---- +*** This function has a nice documentation", }, "range": Object { @@ -188,7 +188,7 @@ Object { "value": "\`\`\`ocaml 'a -> 'a \`\`\` ---- +*** This function has a nice documentation", }, "range": Object { @@ -263,7 +263,7 @@ Object { "value": "\`\`\`ocaml int -> int -> int \`\`\` ---- +*** This function has a nice documentation. It performs division of two integer numbers.