@@ -12,6 +12,13 @@ let digConstructor = (~env, ~getModule, path) => {
12
12
};
13
13
};
14
14
15
+ let codeBlock = (~markdown, code) =>
16
+ if (markdown) {
17
+ Printf . sprintf("```rescript\n % s \n ```" , code);
18
+ } else {
19
+ code;
20
+ };
21
+
15
22
let showModuleTopLevel =
16
23
(
17
24
~name,
@@ -32,7 +39,7 @@ let showModuleTopLevel =
32
39
)
33
40
|> String . concat("\n " );
34
41
let full = "module " ++ name ++ " = {" ++ "\n " ++ contents ++ "\n }" ;
35
- Some (markdown ? "```rescript \n " ++ full ++ " \n ```" : full );
42
+ Some (codeBlock(~ markdown, full) );
36
43
};
37
44
38
45
let showModule =
@@ -55,7 +62,9 @@ let newHover =
55
62
(~rootUri, ~file: SharedTypes . file , ~getModule, ~markdown, ~showPath, loc) => {
56
63
switch (loc) {
57
64
| SharedTypes . Explanation (text ) => Some (text)
58
- | TypeDefinition (_name , _tdecl , _stamp ) => None
65
+ | TypeDefinition (name , decl , _stamp ) =>
66
+ let typeDef = Shared . declToString(name, decl);
67
+ Some (codeBlock(~markdown, typeDef));
59
68
| LModule (LocalReference (stamp , _tip )) =>
60
69
let %opt md = Hashtbl.find_opt(file.stamps.modules, stamp);
61
70
let %opt (file, declared) =
@@ -110,15 +119,13 @@ let newHover =
110
119
/* Some(typ.toString()) */
111
120
};
112
121
113
- let codeBlock = text =>
114
- markdown ? "```rescript\n " ++ text ++ "\n ```" : text;
115
- let typeString = codeBlock(typeString);
122
+ let typeString = codeBlock(~markdown, typeString);
116
123
let typeString =
117
124
typeString
118
125
++ (
119
126
switch (extraTypeInfo) {
120
127
| None => ""
121
- | Some (extra ) => "\n\n " ++ codeBlock(extra)
128
+ | Some (extra ) => "\n\n " ++ codeBlock(~markdown , extra)
122
129
}
123
130
);
124
131
@@ -138,6 +145,7 @@ let newHover =
138
145
Some (typeString),
139
146
Some (
140
147
codeBlock(
148
+ ~markdown,
141
149
txt
142
150
++ "("
143
151
++ (
0 commit comments