Skip to content

Commit 10818a4

Browse files
committed
tools: fix dir_sep and update rescript files
1 parent 79e7e1e commit 10818a4

File tree

10 files changed

+64
-16
lines changed

10 files changed

+64
-16
lines changed

tools/npm/RescriptTools.bs.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/npm/Tools_Docgen.bs.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/npm/Tools_Docgen.res

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ type detail =
2222
| @as("record") Record({items: array<field>})
2323
| @as("variant") Variant({items: array<constructor>})
2424

25+
type source = {
26+
filepath: string,
27+
line: int,
28+
col: int,
29+
}
30+
2531
@tag("kind")
2632
type rec item =
2733
| @as("value")
@@ -31,6 +37,7 @@ type rec item =
3137
signature: string,
3238
name: string,
3339
deprecated?: string,
40+
source: source,
3441
})
3542
| @as("type")
3643
Type({
@@ -39,6 +46,7 @@ type rec item =
3946
signature: string,
4047
name: string,
4148
deprecated?: string,
49+
source: source,
4250
/** Additional documentation for constructors and record fields, if available. */
4351
detail?: detail,
4452
})
@@ -48,20 +56,23 @@ type rec item =
4856
docstrings: array<string>,
4957
deprecated?: string,
5058
name: string,
59+
source: source,
5160
items: array<item>,
5261
})
5362
| @as("moduleAlias")
5463
ModuleAlias({
5564
id: string,
5665
docstrings: array<string>,
5766
name: string,
67+
source: source,
5868
items: array<item>,
5969
})
6070

6171
type doc = {
6272
name: string,
6373
deprecated: option<string>,
6474
docstrings: array<string>,
75+
source: source,
6576
items: array<item>,
6677
}
6778

tools/npm/Tools_Docgen.resi

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ type detail =
2121
| @as("record") Record({items: array<field>})
2222
| @as("variant") Variant({items: array<constructor>})
2323

24+
type source = {
25+
filepath: string,
26+
line: int,
27+
col: int,
28+
}
29+
2430
@tag("kind")
2531
type rec item =
2632
| @as("value")
@@ -30,6 +36,7 @@ type rec item =
3036
signature: string,
3137
name: string,
3238
deprecated?: string,
39+
source: source,
3340
})
3441
| @as("type")
3542
Type({
@@ -38,6 +45,7 @@ type rec item =
3845
signature: string,
3946
name: string,
4047
deprecated?: string,
48+
source: source,
4149
/** Additional documentation for constructors and record fields, if available. */
4250
detail?: detail,
4351
})
@@ -47,16 +55,24 @@ type rec item =
4755
docstrings: array<string>,
4856
deprecated?: string,
4957
name: string,
58+
source: source,
5059
items: array<item>,
5160
})
5261
| @as("moduleAlias")
5362
ModuleAlias({
5463
id: string,
5564
docstrings: array<string>,
5665
name: string,
66+
source: source,
5767
items: array<item>,
5868
})
5969

60-
type doc = {name: string, deprecated: option<string>, docstrings: array<string>, items: array<item>}
70+
type doc = {
71+
name: string,
72+
deprecated: option<string>,
73+
docstrings: array<string>,
74+
source: source,
75+
items: array<item>,
76+
}
6177

6278
let decodeFromJson: Js.Json.t => doc

tools/src/tools.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ let typeDetail typ ~env ~full =
280280
let makeId modulePath ~identifier =
281281
identifier :: modulePath |> List.rev |> SharedTypes.ident
282282

283+
(**
284+
Get relative path to res/resi file
285+
*)
283286
let findRelativePath ~rootPath ~path =
284287
let open Filename in
285288
let realPath =
@@ -290,7 +293,7 @@ let findRelativePath ~rootPath ~path =
290293
in
291294
let rec loop dirPath acc =
292295
match dirname dirPath = realPath with
293-
| true -> basename dirPath :: acc |> String.concat dir_sep
296+
| true -> basename dirPath :: acc |> String.concat "/"
294297
| false -> (
295298
match dirPath with
296299
| "/" -> failwith "Failed to find relative path of package"
@@ -359,8 +362,8 @@ let extractDocs ~entryPointFile ~debug =
359362
| true -> file.uri |> Uri.toPath
360363
| false ->
361364
findRelativePath ~rootPath ~path:(file.uri |> Uri.toPath));
362-
line = 0;
363-
col = 0;
365+
line = 1;
366+
col = 1;
364367
};
365368
items =
366369
structure.items

tools/tests/src/expected/DocExtraction2.res.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"docstrings": ["Module level doc here."],
55
"source": {
66
"filepath": "src/DocExtraction2.resi",
7-
"line": 0,
8-
"col": 0
7+
"line": 1,
8+
"col": 1
99
},
1010
"items": [
1111
{

tools/tests/src/expected/DocExtraction2.resi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"docstrings": ["Module level doc here."],
55
"source": {
66
"filepath": "src/DocExtraction2.resi",
7-
"line": 0,
8-
"col": 0
7+
"line": 1,
8+
"col": 1
99
},
1010
"items": [
1111
{

tools/tests/src/expected/DocExtractionRes.res.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"docstrings": ["Module level documentation goes here."],
55
"source": {
66
"filepath": "src/DocExtractionRes.res",
7-
"line": 0,
8-
"col": 0
7+
"line": 1,
8+
"col": 1
99
},
1010
"items": [
1111
{
@@ -242,8 +242,8 @@
242242
"docstrings": [],
243243
"source": {
244244
"filepath": "src/DocExtractionRes.res",
245-
"line": 0,
246-
"col": 0
245+
"line": 1,
246+
"col": 1
247247
},
248248
"items": [
249249
{

tools/tests/src/expected/ModC.res.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"docstrings": [],
55
"source": {
66
"filepath": "src/ModC.resi",
7-
"line": 0,
8-
"col": 0
7+
"line": 1,
8+
"col": 1
99
},
1010
"items": [
1111
{

tools/tests/src/expected/ModC.resi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"docstrings": [],
55
"source": {
66
"filepath": "src/ModC.resi",
7-
"line": 0,
8-
"col": 0
7+
"line": 1,
8+
"col": 1
99
},
1010
"items": [
1111
{

0 commit comments

Comments
 (0)