Skip to content

Commit 85f7a2b

Browse files
zthGabriel Nordeborn
authored and
Gabriel Nordeborn
committed
produce what id to link to in linkables
1 parent bfe7cb6 commit 85f7a2b

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

analysis/src/DocExtraction.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,20 @@ let stringifyLinkables ?(indentation = 0)
121121
let open Protocol in
122122
linkables
123123
|> List.map (fun l ->
124+
let isExternal = originalEnv.file.uri <> l.env.file.uri in
124125
stringifyObject ~indentation:(indentation + 1)
125126
[
127+
( "linkId",
128+
Some
129+
((if isExternal then "" else l.env.file.moduleName ^ ".")
130+
^ (l.path |> SharedTypes.pathIdentToString)
131+
|> Json.escape |> wrapInQuotes) );
126132
( "path",
127133
Some
128134
(l.path |> SharedTypes.pathIdentToString |> Json.escape
129135
|> wrapInQuotes) );
130136
("moduleName", Some (l.env.file.moduleName |> wrapInQuotes));
131-
( "external",
132-
Some
133-
(Printf.sprintf "%b" (originalEnv.file.uri <> l.env.file.uri))
134-
);
137+
("external", Some (Printf.sprintf "%b" isExternal));
135138
])
136139
|> array
137140

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ preferring found resi file for impl: src/DocExtraction2.resi
2121
"signature": "let make: unit => t",
2222
"docstrings": ["Makerz of stuffz."],
2323
"linkables": [{
24+
"linkId": "DocExtraction2.t",
2425
"path": "t",
2526
"moduleName": "DocExtraction2",
2627
"external": false
@@ -49,6 +50,7 @@ preferring found resi file for impl: src/DocExtraction2.resi
4950
"signature": "let make: unit => t",
5051
"docstrings": ["Maker of tea."],
5152
"linkables": [{
53+
"linkId": "DocExtraction2.t",
5254
"path": "t",
5355
"moduleName": "DocExtraction2",
5456
"external": false

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extracting docs for src/DocExtraction2.resi
2020
"signature": "let make: unit => t",
2121
"docstrings": ["Makerz of stuffz."],
2222
"linkables": [{
23+
"linkId": "DocExtraction2.t",
2324
"path": "t",
2425
"moduleName": "DocExtraction2",
2526
"external": false
@@ -48,6 +49,7 @@ extracting docs for src/DocExtraction2.resi
4849
"signature": "let make: unit => t",
4950
"docstrings": ["Maker of tea."],
5051
"linkables": [{
52+
"linkId": "DocExtraction2.t",
5153
"path": "t",
5254
"moduleName": "DocExtraction2",
5355
"external": false

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extracting docs for src/DocExtractionRes.res
3333
"signature": "let make: string => t",
3434
"docstrings": ["Create stuff.\\n\\n```rescript example\\nlet stuff = make(\\\"My name\\\")\\n```"],
3535
"linkables": [{
36+
"linkId": "DocExtractionRes.t",
3637
"path": "t",
3738
"moduleName": "DocExtractionRes",
3839
"external": false
@@ -45,6 +46,7 @@ extracting docs for src/DocExtractionRes.res
4546
"signature": "let asOffline: t => t",
4647
"docstrings": ["Stuff goes offline."],
4748
"linkables": [{
49+
"linkId": "DocExtractionRes.t",
4850
"path": "t",
4951
"moduleName": "DocExtractionRes",
5052
"external": false
@@ -65,6 +67,7 @@ extracting docs for src/DocExtractionRes.res
6567
"signature": "type status = Started(t) | Stopped | Idle",
6668
"docstrings": [],
6769
"linkables": [{
70+
"linkId": "DocExtractionRes.t",
6871
"path": "t",
6972
"moduleName": "DocExtractionRes",
7073
"external": false
@@ -105,10 +108,12 @@ extracting docs for src/DocExtractionRes.res
105108
"signature": "type callback = (t, ~status: status) => unit",
106109
"docstrings": [],
107110
"linkables": [{
111+
"linkId": "DocExtractionRes.t",
108112
"path": "t",
109113
"moduleName": "DocExtractionRes",
110114
"external": false
111115
}, {
116+
"linkId": "DocExtractionRes.status",
112117
"path": "status",
113118
"moduleName": "DocExtractionRes",
114119
"external": false
@@ -131,6 +136,7 @@ extracting docs for src/DocExtractionRes.res
131136
"signature": "type callback = SomeInnerModule.status => unit",
132137
"docstrings": ["Testing what this looks like."],
133138
"linkables": [{
139+
"linkId": "DocExtractionRes.SomeInnerModule.status",
134140
"path": "SomeInnerModule.status",
135141
"moduleName": "DocExtractionRes",
136142
"external": false
@@ -143,6 +149,7 @@ extracting docs for src/DocExtractionRes.res
143149
"signature": "let isGoodStatus: SomeInnerModule.status => bool",
144150
"docstrings": [],
145151
"linkables": [{
152+
"linkId": "DocExtractionRes.SomeInnerModule.status",
146153
"path": "SomeInnerModule.status",
147154
"moduleName": "DocExtractionRes",
148155
"external": false
@@ -173,6 +180,7 @@ extracting docs for src/DocExtractionRes.res
173180
"signature": "type domRoot = unit => ReactDOM.Client.Root.t",
174181
"docstrings": ["Callback to get the DOM root..."],
175182
"linkables": [{
183+
"linkId": "ReactDOM.Client.Root.t",
176184
"path": "ReactDOM.Client.Root.t",
177185
"moduleName": "ReactDOM",
178186
"external": true
@@ -203,6 +211,7 @@ extracting docs for src/DocExtractionRes.res
203211
"signature": "let make: unit => t",
204212
"docstrings": ["The maker of stuff!"],
205213
"linkables": [{
214+
"linkId": "DocExtractionRes.t",
206215
"path": "t",
207216
"moduleName": "DocExtractionRes",
208217
"external": false

0 commit comments

Comments
 (0)