From 878cfde521d7c7daa5ca5ce2272df3d2b202accd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sun, 17 Aug 2025 17:23:44 +0200 Subject: [PATCH 1/4] Add markdown divider between module doc and module type in hover information --- analysis/src/Hover.ml | 3 ++- tests/analysis_tests/tests/src/expected/Hover.res.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/analysis/src/Hover.ml b/analysis/src/Hover.ml index c66ac8f787..4e3dfb74f1 100644 --- a/analysis/src/Hover.ml +++ b/analysis/src/Hover.ml @@ -26,7 +26,8 @@ let showModuleTopLevel ~docstring ~isType ~name (topLevel : Module.item list) = let doc = match docstring with | [] -> "" - | _ :: _ -> "\n" ^ (docstring |> String.concat "\n") ^ "\n" + | _ :: _ -> + "\n" ^ (docstring |> String.concat "\n") ^ Markdown.divider in Some (doc ^ full) diff --git a/tests/analysis_tests/tests/src/expected/Hover.res.txt b/tests/analysis_tests/tests/src/expected/Hover.res.txt index a68c232167..2b3f4447a8 100644 --- a/tests/analysis_tests/tests/src/expected/Hover.res.txt +++ b/tests/analysis_tests/tests/src/expected/Hover.res.txt @@ -8,7 +8,7 @@ Hover src/Hover.res 6:7 {"contents": {"kind": "markdown", "value": "```rescript\nmodule Id: {\n type x = int\n}\n```"}} Hover src/Hover.res 19:11 -{"contents": {"kind": "markdown", "value": "\nThis module is commented\n```rescript\nmodule Dep: {\n let customDouble: int => int\n}\n```"}} +{"contents": {"kind": "markdown", "value": "\nThis module is commented\n---\n```rescript\nmodule Dep: {\n let customDouble: int => int\n}\n```"}} Hover src/Hover.res 22:11 {"contents": {"kind": "markdown", "value": "```rescript\nint => int\n```\n---\nSome doc comment"}} @@ -343,7 +343,7 @@ Path x {"contents": {"kind": "markdown", "value": "```rescript\nbool\n```"}} Hover src/Hover.res 278:8 -{"contents": {"kind": "markdown", "value": "\n [`Belt.Array`]()\n\n **mutable array**: Utilities functions\n\n```rescript\nmodule Array: {\n module Id\n module Array\n module SortArray\n module MutableQueue\n module MutableStack\n module List\n module Range\n module Set\n module Map\n module MutableSet\n module MutableMap\n module HashSet\n module HashMap\n module Option\n module Result\n module Int\n module Float\n}\n```"}} +{"contents": {"kind": "markdown", "value": "\n [`Belt.Array`]()\n\n **mutable array**: Utilities functions\n\n---\n```rescript\nmodule Array: {\n module Id\n module Array\n module SortArray\n module MutableQueue\n module MutableStack\n module List\n module Range\n module Set\n module Map\n module MutableSet\n module MutableMap\n module HashSet\n module HashMap\n module Option\n module Result\n module Int\n module Float\n}\n```"}} Hover src/Hover.res 281:6 {"contents": {"kind": "markdown", "value": "```rescript\ntype aliased = variant\n```\n\n---\n\n```\n \n```\n```rescript\ntype variant = CoolVariant | OtherCoolVariant\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C251%2C0%5D)\n"}} From c62d0d981204cdf8354409fc96824258e4f28d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sun, 17 Aug 2025 17:36:45 +0200 Subject: [PATCH 2/4] Add CHANGELOG entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eae7f7a28a..05151aea6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ #### :rocket: New Feature +- Add markdown divider between module doc and module type in hover information. https://github.com/rescript-lang/rescript/pull/7775 + #### :bug: Bug fix #### :memo: Documentation From e71d0363ad5ffc3c0548da2d58e0ee3f4bfa4cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sun, 17 Aug 2025 17:39:01 +0200 Subject: [PATCH 3/4] Format code --- analysis/src/Hover.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analysis/src/Hover.ml b/analysis/src/Hover.ml index 4e3dfb74f1..bf7d6242ad 100644 --- a/analysis/src/Hover.ml +++ b/analysis/src/Hover.ml @@ -26,8 +26,7 @@ let showModuleTopLevel ~docstring ~isType ~name (topLevel : Module.item list) = let doc = match docstring with | [] -> "" - | _ :: _ -> - "\n" ^ (docstring |> String.concat "\n") ^ Markdown.divider + | _ :: _ -> "\n" ^ (docstring |> String.concat "\n") ^ Markdown.divider in Some (doc ^ full) From 9ba2bb66ee4c88f2ea0d11a3b6f6aca8ccd86dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 18 Aug 2025 11:49:57 +0200 Subject: [PATCH 4/4] Add padding between module docstring and type hover information --- analysis/src/Hover.ml | 5 ++++- tests/analysis_tests/tests/src/expected/Hover.res.txt | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/analysis/src/Hover.ml b/analysis/src/Hover.ml index bb79bd25db..fc8a8d0573 100644 --- a/analysis/src/Hover.ml +++ b/analysis/src/Hover.ml @@ -26,7 +26,10 @@ let showModuleTopLevel ~docstring ~isType ~name (topLevel : Module.item list) = let doc = match docstring with | [] -> "" - | _ :: _ -> "\n" ^ (docstring |> String.concat "\n") ^ Markdown.divider + | _ :: _ -> + "\n" + ^ (docstring |> String.concat "\n") + ^ Markdown.divider ^ Markdown.spacing in Some (doc ^ full) diff --git a/tests/analysis_tests/tests/src/expected/Hover.res.txt b/tests/analysis_tests/tests/src/expected/Hover.res.txt index a4985da9b9..f9f1746e15 100644 --- a/tests/analysis_tests/tests/src/expected/Hover.res.txt +++ b/tests/analysis_tests/tests/src/expected/Hover.res.txt @@ -8,7 +8,7 @@ Hover src/Hover.res 6:7 {"contents": {"kind": "markdown", "value": "```rescript\nmodule Id: {\n type x = int\n}\n```"}} Hover src/Hover.res 19:11 -{"contents": {"kind": "markdown", "value": "\nThis module is commented\n---\n```rescript\nmodule Dep: {\n let customDouble: int => int\n}\n```"}} +{"contents": {"kind": "markdown", "value": "\nThis module is commented\n---\n\n```\n \n```\n```rescript\nmodule Dep: {\n let customDouble: int => int\n}\n```"}} Hover src/Hover.res 22:11 {"contents": {"kind": "markdown", "value": "```rescript\nint => int\n```\n---\nSome doc comment"}} @@ -343,7 +343,7 @@ Path x {"contents": {"kind": "markdown", "value": "```rescript\nbool\n```"}} Hover src/Hover.res 278:8 -{"contents": {"kind": "markdown", "value": "\n [`Belt.Array`]()\n\n **mutable array**: Utilities functions\n\n---\n```rescript\nmodule Array: {\n module Id\n module Array\n module SortArray\n module MutableQueue\n module MutableStack\n module List\n module Range\n module Set\n module Map\n module MutableSet\n module MutableMap\n module HashSet\n module HashMap\n module Option\n module Result\n module Int\n module Float\n}\n```"}} +{"contents": {"kind": "markdown", "value": "\n [`Belt.Array`]()\n\n **mutable array**: Utilities functions\n\n---\n\n```\n \n```\n```rescript\nmodule Array: {\n module Id\n module Array\n module SortArray\n module MutableQueue\n module MutableStack\n module List\n module Range\n module Set\n module Map\n module MutableSet\n module MutableMap\n module HashSet\n module HashMap\n module Option\n module Result\n module Int\n module Float\n}\n```"}} Hover src/Hover.res 281:6 {"contents": {"kind": "markdown", "value": "```rescript\ntype aliased = variant\n```\n\n---\n\n```\n \n```\n```rescript\ntype variant = CoolVariant | OtherCoolVariant\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C251%2C0%5D)\n"}}