Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 7d71397

Browse files
committed
More doc comment cleanup.
1 parent 7b886ef commit 7d71397

File tree

9 files changed

+35
-37
lines changed

9 files changed

+35
-37
lines changed

src/rescript-editor-support/Hover.re

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ let showModuleTopLevel =
3838
let full = "module " ++ name ++ " = {" ++ "\n" ++ contents ++ "\n}";
3939
let doc =
4040
switch (docstring) {
41-
| None => ""
42-
| Some(s) => "\n" ++ s ++ "\n"
41+
| [] => ""
42+
| [_, ..._] => "\n" ++ (docstring |> String.concat("\n")) ++ "\n"
4343
};
4444
Some(doc ++ codeBlock(full));
4545
};
@@ -133,10 +133,7 @@ let newHover = (~file: SharedTypes.file, ~getModule, loc) => {
133133
| None => (typeString, docstring)
134134
| Some((extra, extraDocstring)) => (
135135
typeString ++ "\n\n" ++ codeBlock(extra),
136-
switch (extraDocstring) {
137-
| None => []
138-
| Some(d) => [d]
139-
},
136+
extraDocstring,
140137
)
141138
};
142139
(typeString, docstring);

src/rescript-editor-support/NewCompletions.re

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ let mkItem = (~name, ~kind, ~detail, ~deprecated, ~docstring, ~uri, ~pos_lnum) =
587587
)
588588
++ (
589589
switch (docstring) {
590-
| None => ""
591-
| Some(s) => s ++ "\n\n"
590+
| [] => ""
591+
| [_, ..._] => (docstring |> String.concat("\n")) ++ "\n\n"
592592
}
593593
)
594594
++ "\n"
@@ -793,7 +793,7 @@ let processCompletable =
793793
~kind=4,
794794
~deprecated=None,
795795
~detail="",
796-
~docstring=None,
796+
~docstring=[],
797797
~uri=full.file.uri,
798798
~pos_lnum=fst(pos),
799799
);
@@ -869,7 +869,7 @@ let processCompletable =
869869
~kind=4,
870870
~deprecated=None,
871871
~detail=typ |> Shared.typeToString,
872-
~docstring=None,
872+
~docstring=[],
873873
~uri=full.file.uri,
874874
~pos_lnum=fst(pos),
875875
);

src/rescript-editor-support/ProcessAttributes.re

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open SharedTypes;
2-
open Infix;
32

43
/* TODO should I hang on to location? */
54
let rec findDocAttribute = attributes => {
@@ -73,7 +72,11 @@ let newDeclared =
7372
exported,
7473
modulePath,
7574
deprecated: findDeprecatedAttribute(attributes),
76-
docstring: findDocAttribute(attributes) |?>> processDoc,
75+
docstring:
76+
switch (findDocAttribute(attributes)) {
77+
| None => []
78+
| Some(d) => processDoc(d)
79+
},
7780
item,
7881
/* scopeType: Let, */
7982
/* scopeStart: env.scopeStart, */

src/rescript-editor-support/ProcessCmt.re

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let sigItemsExtent = items => {
4141

4242
type env = {
4343
stamps,
44-
processDoc: string => string,
44+
processDoc: string => list(string),
4545
modulePath: visibilityPath,
4646
scope: Location.t,
4747
};
@@ -203,7 +203,7 @@ and forSignatureType = (env, signature) => {
203203
signature,
204204
[],
205205
);
206-
{docstring: None, exported, topLevel};
206+
{docstring: [], exported, topLevel};
207207
}
208208
and forModuleType = (env, moduleType) =>
209209
switch (moduleType) {
@@ -376,7 +376,10 @@ let forSignature = (~env, items) => {
376376
| _ => []
377377
};
378378
let docstring =
379-
ProcessAttributes.findDocAttribute(attributes) |?>> env.processDoc;
379+
switch (ProcessAttributes.findDocAttribute(attributes)) {
380+
| None => []
381+
| Some(d) => env.processDoc(d)
382+
};
380383
{docstring, exported, topLevel};
381384
};
382385

@@ -573,7 +576,10 @@ and forStructure = (~env, items) => {
573576
| _ => []
574577
};
575578
let docstring =
576-
ProcessAttributes.findDocAttribute(attributes) |?>> env.processDoc;
579+
switch (ProcessAttributes.findDocAttribute(attributes)) {
580+
| None => []
581+
| Some(d) => env.processDoc(d)
582+
};
577583
{docstring, exported, topLevel};
578584
};
579585

src/rescript-editor-support/ProcessExtra.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ module F =
405405
loc_end: currentScopeExtent().loc_end,
406406
},
407407
~modulePath=NotVisible,
408-
~processDoc=x => x,
408+
~processDoc=x => [x],
409409
~item=val_desc.ctyp_type,
410410
false,
411411
val_attributes,
@@ -443,7 +443,7 @@ module F =
443443
},
444444
~modulePath=NotVisible,
445445
~extent=pat_loc,
446-
~processDoc=x => x,
446+
~processDoc=x => [x],
447447
~item=pat_type,
448448
false,
449449
pat_attributes,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let fileForCmt:
2-
(~moduleName: string, ~uri: Uri2.t, string, string => string) =>
2+
(~moduleName: string, ~uri: Uri2.t, string, string => list(string)) =>
33
result(SharedTypes.file, string);
44

55
let fullForCmt:
6-
(~moduleName: string, ~uri: Uri2.t, string, string => string) =>
6+
(~moduleName: string, ~uri: Uri2.t, string, string => list(string)) =>
77
result(SharedTypes.full, string);

src/rescript-editor-support/References.re

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ let definedForLoc = (~file, ~getModule, locKind) => {
114114
);
115115
let%opt declared =
116116
Query.declaredForTip(~stamps=file.stamps, stamp, tip);
117-
let docstring =
118-
switch (declared.docstring) {
119-
| None => []
120-
| Some(d) => [d]
121-
};
122-
Some((docstring, `Declared));
117+
Some((declared.docstring, `Declared));
123118
};
124119
};
125120

src/rescript-editor-support/SharedTypes.re

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type declared('t) = {
5454
modulePath: visibilityPath,
5555
exported: bool,
5656
deprecated: option(string),
57-
docstring: option(string),
57+
docstring: list(string),
5858
item: 't,
5959
/* TODO maybe add a uri? */
6060
/* scopeType: scope, */
@@ -69,7 +69,7 @@ let emptyDeclared = name => {
6969
modulePath: NotVisible,
7070
exported: false,
7171
deprecated: None,
72-
docstring: None,
72+
docstring: [],
7373
item: (),
7474
};
7575

@@ -142,7 +142,7 @@ type moduleItem =
142142
| MType(Type.t, Types.rec_status)
143143
| Module(moduleKind)
144144
and moduleContents = {
145-
docstring: option(string),
145+
docstring: list(string),
146146
exported,
147147
topLevel: list(declared(moduleItem)),
148148
}
@@ -178,7 +178,7 @@ let emptyFile = (moduleName, uri) => {
178178
stamps: initStamps(),
179179
moduleName,
180180
contents: {
181-
docstring: None,
181+
docstring: [],
182182
exported: initExported(),
183183
topLevel: [],
184184
},

src/rescript-editor-support/State.re

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ let odocToMd = text => MarkdownOfOCamldoc.convert(text);
99
let compose = (fn1, fn2, arg) => fn1(arg) |> fn2;
1010

1111
let converter = src => {
12-
let mlToOutput = compose(odocToMd, Omd.to_markdown);
13-
fold(src, mlToOutput, src => isMl(src) ? mlToOutput : (x => x));
12+
let mlToOutput = s => [compose(odocToMd, Omd.to_markdown, s)];
13+
fold(src, mlToOutput, src => isMl(src) ? mlToOutput : (x => [x]));
1414
};
1515

1616
let newDocsForCmt = (~moduleName, cmtCache, changed, cmt, src) => {
@@ -62,11 +62,8 @@ let getFullFromCmt = (~state, ~uri) => {
6262
switch (Hashtbl.find_opt(package.pathsForModule, moduleName)) {
6363
| Some(paths) =>
6464
let cmt =
65-
SharedTypes.getCmt(
66-
~interface=Utils.endsWith(path, "i"),
67-
paths,
68-
);
69-
let%try full = Process_406.fullForCmt(~moduleName, ~uri, cmt, x => x);
65+
SharedTypes.getCmt(~interface=Utils.endsWith(path, "i"), paths);
66+
let%try full = Process_406.fullForCmt(~moduleName, ~uri, cmt, x => [x]);
7067
Hashtbl.replace(
7168
package.interModuleDependencies,
7269
moduleName,

0 commit comments

Comments
 (0)