Skip to content

Commit 3018283

Browse files
committed
Correct signature detail in JSON
1 parent 1e14581 commit 3018283

File tree

7 files changed

+90
-20
lines changed

7 files changed

+90
-20
lines changed

tools/npm/Tools_Docgen.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type signatureDetais = {
3131
type detail =
3232
| @as("record") Record({items: array<field>})
3333
| @as("variant") Variant({items: array<constructor>})
34-
| @as("alias") Signature(signatureDetais)
34+
| @as("signature") Signature(signatureDetais)
3535

3636
type source = {
3737
filepath: string,

tools/src/tools.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,16 @@ let stringifyDetail ?(indentation = 0) (detail : docItemDetail) =
173173
ps |> List.map (stringifyTypeDoc ~indentation:(indentation + 1))
174174
|> fun ps -> Some (array ps)
175175
in
176-
stringifyObject ~startOnNewline:false ~indentation
176+
stringifyObject ~startOnNewline:true ~indentation
177177
[
178-
("parameters", ps);
179-
("returnType", Some (stringifyTypeDoc ~indentation returnType));
178+
("kind", Some (wrapInQuotes "signature"));
179+
( "items",
180+
Some
181+
(stringifyObject ~startOnNewline:false ~indentation
182+
[
183+
("parameters", ps);
184+
("returnType", Some (stringifyTypeDoc ~indentation returnType));
185+
]) );
180186
]
181187

182188
let stringifySource ~indentation source =

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@
3131
"line": 7,
3232
"col": 1
3333
},
34-
"detail": {
34+
"detail":
35+
{
36+
"kind": "signature",
37+
"items": {
3538
"parameters": [{
3639
"path": "unit"
3740
}],
3841
"returnType": {
3942
"path": "t"
4043
}
4144
}
45+
}
4246
},
4347
{
4448
"id": "DocExtraction2.InnerModule",
@@ -74,14 +78,18 @@
7478
"line": 15,
7579
"col": 3
7680
},
77-
"detail": {
81+
"detail":
82+
{
83+
"kind": "signature",
84+
"items": {
7885
"parameters": [{
7986
"path": "unit"
8087
}],
8188
"returnType": {
8289
"path": "t"
8390
}
8491
}
92+
}
8593
}]
8694
}]
8795
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@
3131
"line": 7,
3232
"col": 1
3333
},
34-
"detail": {
34+
"detail":
35+
{
36+
"kind": "signature",
37+
"items": {
3538
"parameters": [{
3639
"path": "unit"
3740
}],
3841
"returnType": {
3942
"path": "t"
4043
}
4144
}
45+
}
4246
},
4347
{
4448
"id": "DocExtraction2.InnerModule",
@@ -74,14 +78,18 @@
7478
"line": 15,
7579
"col": 3
7680
},
77-
"detail": {
81+
"detail":
82+
{
83+
"kind": "signature",
84+
"items": {
7885
"parameters": [{
7986
"path": "unit"
8087
}],
8188
"returnType": {
8289
"path": "t"
8390
}
8491
}
92+
}
8593
}]
8694
}]
8795
}

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

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@
4646
"line": 17,
4747
"col": 5
4848
},
49-
"detail": {
49+
"detail":
50+
{
51+
"kind": "signature",
52+
"items": {
5053
"parameters": [{
5154
"path": "string"
5255
}],
5356
"returnType": {
5457
"path": "t"
5558
}
5659
}
60+
}
5761
},
5862
{
5963
"id": "DocExtractionRes.asOffline",
@@ -66,14 +70,18 @@
6670
"line": 23,
6771
"col": 5
6872
},
69-
"detail": {
73+
"detail":
74+
{
75+
"kind": "signature",
76+
"items": {
7077
"parameters": [{
7178
"path": "t"
7279
}],
7380
"returnType": {
7481
"path": "t"
7582
}
7683
}
84+
}
7785
},
7886
{
7987
"id": "DocExtractionRes.SomeConstant",
@@ -86,11 +94,15 @@
8694
"line": 26,
8795
"col": 5
8896
},
89-
"detail": {
97+
"detail":
98+
{
99+
"kind": "signature",
100+
"items": {
90101
"returnType": {
91102
"path": "int"
92103
}
93104
}
105+
}
94106
},
95107
{
96108
"id": "DocExtractionRes.SomeInnerModule",
@@ -206,14 +218,18 @@
206218
"line": 49,
207219
"col": 7
208220
},
209-
"detail": {
221+
"detail":
222+
{
223+
"kind": "signature",
224+
"items": {
210225
"parameters": [{
211226
"path": "SomeInnerModule.status"
212227
}],
213228
"returnType": {
214229
"path": "bool"
215230
}
216231
}
232+
}
217233
},
218234
{
219235
"id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords",
@@ -298,14 +314,18 @@
298314
"line": 71,
299315
"col": 3
300316
},
301-
"detail": {
317+
"detail":
318+
{
319+
"kind": "signature",
320+
"items": {
302321
"parameters": [{
303322
"path": "unit"
304323
}],
305324
"returnType": {
306325
"path": "t"
307326
}
308327
}
328+
}
309329
}]
310330
},
311331
{
@@ -342,14 +362,18 @@
342362
"line": 109,
343363
"col": 3
344364
},
345-
"detail": {
365+
"detail":
366+
{
367+
"kind": "signature",
368+
"items": {
346369
"parameters": [{
347370
"path": "t"
348371
}],
349372
"returnType": {
350373
"path": "t"
351374
}
352375
}
376+
}
353377
}]
354378
},
355379
{
@@ -387,14 +411,18 @@
387411
"line": 128,
388412
"col": 7
389413
},
390-
"detail": {
414+
"detail":
415+
{
416+
"kind": "signature",
417+
"items": {
391418
"parameters": [{
392419
"path": "int"
393420
}],
394421
"returnType": {
395422
"path": "int"
396423
}
397424
}
425+
}
398426
}]
399427
},
400428
{
@@ -419,11 +447,15 @@
419447
"line": 132,
420448
"col": 3
421449
},
422-
"detail": {
450+
"detail":
451+
{
452+
"kind": "signature",
453+
"items": {
423454
"returnType": {
424455
"path": "int"
425456
}
426457
}
458+
}
427459
}]
428460
},
429461
{
@@ -449,11 +481,15 @@
449481
"line": 136,
450482
"col": 7
451483
},
452-
"detail": {
484+
"detail":
485+
{
486+
"kind": "signature",
487+
"items": {
453488
"returnType": {
454489
"path": "int"
455490
}
456491
}
492+
}
457493
}]
458494
},
459495
{
@@ -490,11 +526,15 @@
490526
"line": 141,
491527
"col": 9
492528
},
493-
"detail": {
529+
"detail":
530+
{
531+
"kind": "signature",
532+
"items": {
494533
"returnType": {
495534
"path": "int"
496535
}
497536
}
537+
}
498538
}]
499539
}]
500540
}]

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@
3030
"line": 5,
3131
"col": 3
3232
},
33-
"detail": {
33+
"detail":
34+
{
35+
"kind": "signature",
36+
"items": {
3437
"returnType": {
3538
"path": "string"
3639
}
3740
}
41+
}
3842
}]
3943
}]
4044
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@
3030
"line": 5,
3131
"col": 3
3232
},
33-
"detail": {
33+
"detail":
34+
{
35+
"kind": "signature",
36+
"items": {
3437
"returnType": {
3538
"path": "string"
3639
}
3740
}
41+
}
3842
}]
3943
}]
4044
}

0 commit comments

Comments
 (0)