Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescript tool tweaks #7160

Merged
merged 9 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion runtime/RescriptTools_Docgen.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ type constructor = {
payload?: constructorPayload,
}

type rec typeInSignature = {
path: string,
genericTypeParameters: array<typeInSignature>,
}

type signatureDetails = {
parameters: array<typeInSignature>,
returnType: typeInSignature,
}

@tag("kind")
type detail =
| @as("record") Record({items: array<field>})
| @as("variant") Variant({items: array<constructor>})
| @as("alias") Signature({details: signatureDetails})

type source = {
filepath: string,
Expand All @@ -38,6 +49,8 @@ type rec item =
name: string,
deprecated?: string,
source: source,
/** Additional documentation of signature, if available. */
detail?: detail,
})
| @as("type")
Type({
Expand Down Expand Up @@ -89,4 +102,4 @@ type doc = {
/**
`decodeFromJson(json)` parse JSON generated from `restool doc` command
*/
external decodeFromJson: Js.Json.t => doc = "%identity"
external decodeFromJson: JSON.t => doc = "%identity"
16 changes: 15 additions & 1 deletion runtime/RescriptTools_Docgen.resi
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ type constructor = {
deprecated?: string,
payload?: constructorPayload,
}

type rec typeInSignature = {
path: string,
genericTypeParameters: array<typeInSignature>,
}

type signatureDetails = {
parameters: array<typeInSignature>,
returnType: typeInSignature,
}

@tag("kind")
type detail =
| @as("record") Record({items: array<field>})
| @as("variant") Variant({items: array<constructor>})
| @as("signature") Signature({details: signatureDetails})

type source = {
filepath: string,
Expand All @@ -37,6 +49,8 @@ type rec item =
name: string,
deprecated?: string,
source: source,
/** Additional documentation of signature, if available. */
detail?: detail,
})
| @as("type")
Type({
Expand Down Expand Up @@ -85,4 +99,4 @@ type doc = {
items: array<item>,
}

let decodeFromJson: Js.Json.t => doc
let decodeFromJson: JSON.t => doc
1 change: 1 addition & 0 deletions tests/tools_tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions tests/tools_tests/src/expected/DocExtraction2.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
"filepath": "src/DocExtraction2.resi",
"line": 7,
"col": 1
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "unit"
}],
"returnType": {
"path": "t"
}
}
}
},
{
Expand Down Expand Up @@ -65,6 +77,18 @@
"filepath": "src/DocExtraction2.resi",
"line": 15,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "unit"
}],
"returnType": {
"path": "t"
}
}
}
}]
}]
Expand Down
24 changes: 24 additions & 0 deletions tests/tools_tests/src/expected/DocExtraction2.resi.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
"filepath": "src/DocExtraction2.resi",
"line": 7,
"col": 1
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "unit"
}],
"returnType": {
"path": "t"
}
}
}
},
{
Expand Down Expand Up @@ -65,6 +77,18 @@
"filepath": "src/DocExtraction2.resi",
"line": 15,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "unit"
}],
"returnType": {
"path": "t"
}
}
}
}]
}]
Expand Down
108 changes: 108 additions & 0 deletions tests/tools_tests/src/expected/DocExtractionRes.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"filepath": "src/DocExtractionRes.res",
"line": 17,
"col": 5
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "string"
}],
"returnType": {
"path": "t"
}
}
}
},
{
Expand All @@ -57,6 +69,18 @@
"filepath": "src/DocExtractionRes.res",
"line": 23,
"col": 5
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "t"
}],
"returnType": {
"path": "t"
}
}
}
},
{
Expand All @@ -69,6 +93,15 @@
"filepath": "src/DocExtractionRes.res",
"line": 26,
"col": 5
},
"detail":
{
"kind": "signature",
"details": {
"returnType": {
"path": "int"
}
}
}
},
{
Expand Down Expand Up @@ -184,6 +217,18 @@
"filepath": "src/DocExtractionRes.res",
"line": 49,
"col": 7
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "SomeInnerModule.status"
}],
"returnType": {
"path": "bool"
}
}
}
},
{
Expand Down Expand Up @@ -268,6 +313,18 @@
"filepath": "src/DocExtractionRes.res",
"line": 71,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "unit"
}],
"returnType": {
"path": "t"
}
}
}
}]
},
Expand Down Expand Up @@ -304,6 +361,18 @@
"filepath": "src/DocExtractionRes.res",
"line": 109,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "t"
}],
"returnType": {
"path": "t"
}
}
}
}]
},
Expand Down Expand Up @@ -341,6 +410,18 @@
"filepath": "src/DocExtractionRes.res",
"line": 128,
"col": 7
},
"detail":
{
"kind": "signature",
"details": {
"parameters": [{
"path": "int"
}],
"returnType": {
"path": "int"
}
}
}
}]
},
Expand All @@ -365,6 +446,15 @@
"filepath": "src/DocExtractionRes.res",
"line": 132,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"returnType": {
"path": "int"
}
}
}
}]
},
Expand All @@ -390,6 +480,15 @@
"filepath": "src/DocExtractionRes.res",
"line": 136,
"col": 7
},
"detail":
{
"kind": "signature",
"details": {
"returnType": {
"path": "int"
}
}
}
}]
},
Expand Down Expand Up @@ -426,6 +525,15 @@
"filepath": "src/DocExtractionRes.res",
"line": 141,
"col": 9
},
"detail":
{
"kind": "signature",
"details": {
"returnType": {
"path": "int"
}
}
}
}]
}]
Expand Down
9 changes: 9 additions & 0 deletions tests/tools_tests/src/expected/ModC.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
"filepath": "src/ModC.resi",
"line": 5,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"returnType": {
"path": "string"
}
}
}
}]
}]
Expand Down
9 changes: 9 additions & 0 deletions tests/tools_tests/src/expected/ModC.resi.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
"filepath": "src/ModC.resi",
"line": 5,
"col": 3
},
"detail":
{
"kind": "signature",
"details": {
"returnType": {
"path": "string"
}
}
}
}]
}]
Expand Down
2 changes: 1 addition & 1 deletion tools/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Usage: rescript-tools [command]

Commands:

doc Generate documentation
doc <file> Generate documentation
reanalyze Reanalyze
-v, --version Print version
-h, --help Print help|}
Expand Down
Loading