Skip to content

Commit 7a3e306

Browse files
zthGabriel Nordeborn
authored and
Gabriel Nordeborn
committed
fix linkable link ids
1 parent 781b36c commit 7a3e306

File tree

4 files changed

+33
-40
lines changed

4 files changed

+33
-40
lines changed

analysis/src/DocExtraction.ml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
type linkableType = {
22
name: string;
3+
modulePath: string list;
34
path: Path.t;
45
env: SharedTypes.QueryEnv.t;
56
loc: Location.t;
@@ -109,9 +110,17 @@ module Linkables = struct
109110
let fromConstructorPath ~env path =
110111
match References.digConstructor ~env ~package:full.package path with
111112
| None -> None
112-
| Some (env, {name = {txt}; extentLoc}) ->
113+
| Some (env, {name = {txt}; extentLoc; modulePath}) ->
113114
if Utils.isUncurriedInternal path then None
114-
else Some {name = txt; env; loc = extentLoc; path}
115+
else
116+
Some
117+
{
118+
name = txt;
119+
env;
120+
loc = extentLoc;
121+
modulePath = SharedTypes.ModulePath.toPath modulePath txt;
122+
path;
123+
}
115124
in
116125
let constructors = Shared.findTypeConstructors typesToSearch in
117126
constructors |> List.filter_map (fromConstructorPath ~env:envToSearch)
@@ -130,18 +139,16 @@ let stringifyLinkables ?(indentation = 0)
130139
linkables
131140
|> List.map (fun l ->
132141
let isExternal = originalEnv.file.uri <> l.env.file.uri in
142+
let linkId = l.env.file.moduleName :: l.modulePath in
133143
stringifyObject ~indentation:(indentation + 1)
134144
[
135145
( "linkId",
136-
Some
137-
((if isExternal then "" else l.env.file.moduleName ^ ".")
138-
^ (l.path |> SharedTypes.pathIdentToString)
139-
|> Json.escape |> wrapInQuotes) );
140-
( "path",
146+
Some (linkId |> SharedTypes.ident |> Json.escape |> wrapInQuotes)
147+
);
148+
( "name",
141149
Some
142150
(l.path |> SharedTypes.pathIdentToString |> Json.escape
143151
|> wrapInQuotes) );
144-
("moduleName", Some (l.env.file.moduleName |> wrapInQuotes));
145152
("external", Some (Printf.sprintf "%b" isExternal));
146153
])
147154
|> array

analysis/tests/src/expected/DocExtraction2.res.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ preferring found resi file for impl: src/DocExtraction2.resi
2222
"docstrings": ["Makerz of stuffz."],
2323
"linkables": [{
2424
"linkId": "DocExtraction2.t",
25-
"path": "t",
26-
"moduleName": "DocExtraction2",
25+
"name": "t",
2726
"external": false
2827
}]
2928
},
@@ -50,9 +49,8 @@ preferring found resi file for impl: src/DocExtraction2.resi
5049
"signature": "let make: unit => t",
5150
"docstrings": ["Maker of tea."],
5251
"linkables": [{
53-
"linkId": "DocExtraction2.t",
54-
"path": "t",
55-
"moduleName": "DocExtraction2",
52+
"linkId": "DocExtraction2.InnerModule.t",
53+
"name": "t",
5654
"external": false
5755
}]
5856
}]

analysis/tests/src/expected/DocExtraction2.resi.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ extracting docs for src/DocExtraction2.resi
2121
"docstrings": ["Makerz of stuffz."],
2222
"linkables": [{
2323
"linkId": "DocExtraction2.t",
24-
"path": "t",
25-
"moduleName": "DocExtraction2",
24+
"name": "t",
2625
"external": false
2726
}]
2827
},
@@ -49,9 +48,8 @@ extracting docs for src/DocExtraction2.resi
4948
"signature": "let make: unit => t",
5049
"docstrings": ["Maker of tea."],
5150
"linkables": [{
52-
"linkId": "DocExtraction2.t",
53-
"path": "t",
54-
"moduleName": "DocExtraction2",
51+
"linkId": "DocExtraction2.InnerModule.t",
52+
"name": "t",
5553
"external": false
5654
}]
5755
}]

analysis/tests/src/expected/DocExtractionRes.res.txt

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ extracting docs for src/DocExtractionRes.res
3636
"docstrings": ["Create stuff.\\n\\n```rescript example\\nlet stuff = make(\\\"My name\\\")\\n```"],
3737
"linkables": [{
3838
"linkId": "DocExtractionRes.t",
39-
"path": "t",
40-
"moduleName": "DocExtractionRes",
39+
"name": "t",
4140
"external": false
4241
}]
4342
},
@@ -49,8 +48,7 @@ extracting docs for src/DocExtractionRes.res
4948
"docstrings": ["Stuff goes offline."],
5049
"linkables": [{
5150
"linkId": "DocExtractionRes.t",
52-
"path": "t",
53-
"moduleName": "DocExtractionRes",
51+
"name": "t",
5452
"external": false
5553
}]
5654
},
@@ -70,8 +68,7 @@ extracting docs for src/DocExtractionRes.res
7068
"docstrings": [],
7169
"linkables": [{
7270
"linkId": "DocExtractionRes.t",
73-
"path": "t",
74-
"moduleName": "DocExtractionRes",
71+
"name": "t",
7572
"external": false
7673
}],
7774
"detail":
@@ -84,8 +81,7 @@ extracting docs for src/DocExtractionRes.res
8481
"signature": "Started(t)",
8582
"linkables": [{
8683
"linkId": "DocExtractionRes.t",
87-
"path": "t",
88-
"moduleName": "DocExtractionRes",
84+
"name": "t",
8985
"external": false
9086
}]
9187
},
@@ -119,13 +115,11 @@ extracting docs for src/DocExtractionRes.res
119115
"docstrings": [],
120116
"linkables": [{
121117
"linkId": "DocExtractionRes.t",
122-
"path": "t",
123-
"moduleName": "DocExtractionRes",
118+
"name": "t",
124119
"external": false
125120
}, {
126-
"linkId": "DocExtractionRes.status",
127-
"path": "status",
128-
"moduleName": "DocExtractionRes",
121+
"linkId": "DocExtractionRes.SomeInnerModule.status",
122+
"name": "status",
129123
"external": false
130124
}]
131125
}]
@@ -147,8 +141,7 @@ extracting docs for src/DocExtractionRes.res
147141
"docstrings": ["Testing what this looks like."],
148142
"linkables": [{
149143
"linkId": "DocExtractionRes.SomeInnerModule.status",
150-
"path": "SomeInnerModule.status",
151-
"moduleName": "DocExtractionRes",
144+
"name": "SomeInnerModule.status",
152145
"external": false
153146
}]
154147
},
@@ -160,8 +153,7 @@ extracting docs for src/DocExtractionRes.res
160153
"docstrings": [],
161154
"linkables": [{
162155
"linkId": "DocExtractionRes.SomeInnerModule.status",
163-
"path": "SomeInnerModule.status",
164-
"moduleName": "DocExtractionRes",
156+
"name": "SomeInnerModule.status",
165157
"external": false
166158
}]
167159
},
@@ -192,8 +184,7 @@ extracting docs for src/DocExtractionRes.res
192184
"docstrings": ["Callback to get the DOM root..."],
193185
"linkables": [{
194186
"linkId": "ReactDOM.Client.Root.t",
195-
"path": "ReactDOM.Client.Root.t",
196-
"moduleName": "ReactDOM",
187+
"name": "ReactDOM.Client.Root.t",
197188
"external": true
198189
}]
199190
}]
@@ -222,9 +213,8 @@ extracting docs for src/DocExtractionRes.res
222213
"signature": "let make: unit => t",
223214
"docstrings": ["The maker of stuff!"],
224215
"linkables": [{
225-
"linkId": "DocExtractionRes.t",
226-
"path": "t",
227-
"moduleName": "DocExtractionRes",
216+
"linkId": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.t",
217+
"name": "t",
228218
"external": false
229219
}]
230220
}]

0 commit comments

Comments
 (0)