diff --git a/CHANGELOG.md b/CHANGELOG.md index 165577736..95713ffa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Remove spacing between type definition in clients that do not support markdown links. https://github.com/rescript-lang/rescript-vscode/pull/619 - Rename custom LSP methods names. https://github.com/rescript-lang/rescript-vscode/pull/611 +- Accept both `@ns.doc` and the new `@res.doc` for the internal representation of doc comments. And both `@ns.optional` and `@res.optional` for the optional fields. https://github.com/rescript-lang/rescript-vscode/pull/642 #### :bug: Bug Fix diff --git a/analysis/src/ProcessAttributes.ml b/analysis/src/ProcessAttributes.ml index f7a432d20..c610d1e79 100644 --- a/analysis/src/ProcessAttributes.ml +++ b/analysis/src/ProcessAttributes.ml @@ -5,7 +5,7 @@ let rec findDocAttribute attributes = let open Parsetree in match attributes with | [] -> None - | ( {Asttypes.txt = "ocaml.doc" | "ns.doc"}, + | ( {Asttypes.txt = "ocaml.doc" | "ns.doc" | "res.doc"}, PStr [ { diff --git a/analysis/tests/src/DocComments.res b/analysis/tests/src/DocComments.res index a6c3c15fc..defdc43c8 100644 --- a/analysis/tests/src/DocComments.res +++ b/analysis/tests/src/DocComments.res @@ -44,3 +44,7 @@ let docCommentNoNested1 = 12 */ let docCommentNoNested2 = 12 // ^hov + +@res.doc("New doc comment format") +let newDoc = 10 +// ^hov \ No newline at end of file diff --git a/analysis/tests/src/expected/DocComments.res.txt b/analysis/tests/src/expected/DocComments.res.txt index 427781673..2342210b2 100644 --- a/analysis/tests/src/expected/DocComments.res.txt +++ b/analysis/tests/src/expected/DocComments.res.txt @@ -10,3 +10,6 @@ Hover src/DocComments.res 33:9 Hover src/DocComments.res 44:6 {"contents": {"kind": "markdown", "value": "```rescript\nint\n```\n\n\n Doc comment with a triple-backquote example\n \n ```res example\n let a = 10\n let b = 20\n ```\n"}} +Hover src/DocComments.res 48:5 +{"contents": {"kind": "markdown", "value": "```rescript\nint\n```\n\nNew doc comment format"}} + diff --git a/analysis/vendor/compiler-libs-406/printtyp.ml b/analysis/vendor/compiler-libs-406/printtyp.ml index 6b0c4ce4d..21b18399c 100644 --- a/analysis/vendor/compiler-libs-406/printtyp.ml +++ b/analysis/vendor/compiler-libs-406/printtyp.ml @@ -926,7 +926,7 @@ and tree_of_constructor cd = (name, args, Some ret) and tree_of_label l = - let opt = l.ld_attributes |> List.exists (fun ({txt}, _) -> txt = "ns.optional") in + let opt = l.ld_attributes |> List.exists (fun ({txt}, _) -> txt = "ns.optional" || txt = "res.optional") in let typ = match l.ld_type.desc with | Tconstr (p, [t1], _) when opt && Path.same p Predef.path_option -> t1 | _ -> l.ld_type in