Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support both ns.doc/res.doc and ns.optional/res.optional for diff… #642

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion analysis/src/ProcessAttributes.ml
Original file line number Diff line number Diff line change
@@ -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
[
{
4 changes: 4 additions & 0 deletions analysis/tests/src/DocComments.res
Original file line number Diff line number Diff line change
@@ -44,3 +44,7 @@ let docCommentNoNested1 = 12
*/
let docCommentNoNested2 = 12
// ^hov

@res.doc("New doc comment format")
let newDoc = 10
// ^hov
3 changes: 3 additions & 0 deletions analysis/tests/src/expected/DocComments.res.txt
Original file line number Diff line number Diff line change
@@ -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"}}

2 changes: 1 addition & 1 deletion analysis/vendor/compiler-libs-406/printtyp.ml
Original file line number Diff line number Diff line change
@@ -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