Skip to content

docgen: convert items to array #822

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

Merged
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
6 changes: 4 additions & 2 deletions analysis/src/DocExtraction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ let rec stringifyDocItem ?(indentation = 0) ~originalEnv (item : docItem) =
("kind", Some (wrapInQuotes "module"));
( "items",
Some
(stringifyDocsForModule ~originalEnv ~indentation:(indentation + 1)
m) );
(m.items
|> List.map
(stringifyDocItem ~originalEnv ~indentation:(indentation + 1))
|> array) );
]
| ModuleAlias m ->
stringifyObject ~startOnNewline:true ~indentation
Expand Down
33 changes: 14 additions & 19 deletions analysis/tests/src/expected/DocExtraction2.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,21 @@ preferring found resi file for impl: src/DocExtraction2.resi
"id": "InnerModule.DocExtraction2",
"name": "InnerModule",
"kind": "module",
"items":
"items": [
{
"name": "InnerModule",
"docstrings": [],
"items": [
{
"id": "DocExtraction2.InnerModule.t",
"kind": "type",
"name": "t",
"signature": "type t",
"docstrings": ["This type is also t."]
},
{
"id": "DocExtraction2.InnerModule.make",
"kind": "value",
"name": "make",
"signature": "let make: unit => t",
"docstrings": ["Maker of tea."]
}]
}
"id": "DocExtraction2.InnerModule.t",
"kind": "type",
"name": "t",
"signature": "type t",
"docstrings": ["This type is also t."]
},
{
"id": "DocExtraction2.InnerModule.make",
"kind": "value",
"name": "make",
"signature": "let make: unit => t",
"docstrings": ["Maker of tea."]
}]
}]
}

33 changes: 14 additions & 19 deletions analysis/tests/src/expected/DocExtraction2.resi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,21 @@ extracting docs for src/DocExtraction2.resi
"id": "InnerModule.DocExtraction2",
"name": "InnerModule",
"kind": "module",
"items":
"items": [
{
"name": "InnerModule",
"docstrings": [],
"items": [
{
"id": "DocExtraction2.InnerModule.t",
"kind": "type",
"name": "t",
"signature": "type t",
"docstrings": ["This type is also t."]
},
{
"id": "DocExtraction2.InnerModule.make",
"kind": "value",
"name": "make",
"signature": "let make: unit => t",
"docstrings": ["Maker of tea."]
}]
}
"id": "DocExtraction2.InnerModule.t",
"kind": "type",
"name": "t",
"signature": "type t",
"docstrings": ["This type is also t."]
},
{
"id": "DocExtraction2.InnerModule.make",
"kind": "value",
"name": "make",
"signature": "let make: unit => t",
"docstrings": ["Maker of tea."]
}]
}]
}

207 changes: 96 additions & 111 deletions analysis/tests/src/expected/DocExtractionRes.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,134 +45,119 @@ extracting docs for src/DocExtractionRes.res
"id": "SomeInnerModule.DocExtractionRes",
"name": "SomeInnerModule",
"kind": "module",
"items":
"items": [
{
"name": "SomeInnerModule",
"docstrings": ["Another module level docstring here."],
"items": [
"id": "DocExtractionRes.SomeInnerModule.status",
"kind": "type",
"name": "status",
"signature": "type status = Started(t) | Stopped | Idle",
"docstrings": [],
"detail":
{
"id": "DocExtractionRes.SomeInnerModule.status",
"kind": "type",
"name": "status",
"signature": "type status = Started(t) | Stopped | Idle",
"docstrings": [],
"detail":
"kind": "variant",
"constructorDocs": [
{
"kind": "variant",
"constructorDocs": [
{
"constructorName": "Started",
"docstrings": ["If this is started or not"],
"signature": "Started(t)"
},
{
"constructorName": "Stopped",
"docstrings": ["Stopped?"],
"signature": "Stopped"
},
{
"constructorName": "Idle",
"docstrings": ["Now idle."],
"signature": "Idle"
}]
}
},
{
"id": "DocExtractionRes.SomeInnerModule.validInputs",
"kind": "type",
"name": "validInputs",
"signature": "type validInputs = [\\n | #\\\"needs-escaping\\\"\\n | #something\\n | #status(status)\\n | #withPayload(int)\\n]",
"docstrings": ["These are all the valid inputs."]
},
{
"id": "DocExtractionRes.SomeInnerModule.callback",
"kind": "type",
"name": "callback",
"signature": "type callback = (t, ~status: status) => unit",
"docstrings": []
}]
}
"constructorName": "Started",
"docstrings": ["If this is started or not"],
"signature": "Started(t)"
},
{
"constructorName": "Stopped",
"docstrings": ["Stopped?"],
"signature": "Stopped"
},
{
"constructorName": "Idle",
"docstrings": ["Now idle."],
"signature": "Idle"
}]
}
},
{
"id": "DocExtractionRes.SomeInnerModule.validInputs",
"kind": "type",
"name": "validInputs",
"signature": "type validInputs = [\\n | #\\\"needs-escaping\\\"\\n | #something\\n | #status(status)\\n | #withPayload(int)\\n]",
"docstrings": ["These are all the valid inputs."]
},
{
"id": "DocExtractionRes.SomeInnerModule.callback",
"kind": "type",
"name": "callback",
"signature": "type callback = (t, ~status: status) => unit",
"docstrings": []
}]
},
{
"id": "AnotherModule.DocExtractionRes",
"name": "AnotherModule",
"kind": "module",
"items":
"items": [
{
"name": "AnotherModule",
"docstrings": ["Mighty fine module here too!"],
"items": [
{
"id": "DocExtractionRes.AnotherModule.SomeInnerModule",
"kind": "moduleAlias",
"name": "LinkedModule",
"docstrings": ["This links another module. Neat."],
"signature": "module LinkedModule = SomeInnerModule"
},
{
"id": "DocExtractionRes.AnotherModule.callback",
"kind": "type",
"name": "callback",
"signature": "type callback = SomeInnerModule.status => unit",
"docstrings": ["Testing what this looks like."]
},
{
"id": "DocExtractionRes.AnotherModule.isGoodStatus",
"kind": "value",
"name": "isGoodStatus",
"signature": "let isGoodStatus: SomeInnerModule.status => bool",
"docstrings": []
},
"id": "DocExtractionRes.AnotherModule.SomeInnerModule",
"kind": "moduleAlias",
"name": "LinkedModule",
"docstrings": ["This links another module. Neat."],
"signature": "module LinkedModule = SomeInnerModule"
},
{
"id": "DocExtractionRes.AnotherModule.callback",
"kind": "type",
"name": "callback",
"signature": "type callback = SomeInnerModule.status => unit",
"docstrings": ["Testing what this looks like."]
},
{
"id": "DocExtractionRes.AnotherModule.isGoodStatus",
"kind": "value",
"name": "isGoodStatus",
"signature": "let isGoodStatus: SomeInnerModule.status => bool",
"docstrings": []
},
{
"id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords",
"kind": "type",
"name": "someVariantWithInlineRecords",
"signature": "type someVariantWithInlineRecords = SomeStuff({offline: bool})",
"docstrings": ["Trying how it looks with an inline record in a variant."],
"detail":
{
"id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords",
"kind": "type",
"name": "someVariantWithInlineRecords",
"signature": "type someVariantWithInlineRecords = SomeStuff({offline: bool})",
"docstrings": ["Trying how it looks with an inline record in a variant."],
"detail":
"kind": "variant",
"constructorDocs": [
{
"kind": "variant",
"constructorDocs": [
{
"constructorName": "SomeStuff",
"docstrings": ["This has inline records..."],
"signature": "SomeStuff"
}]
}
},
{
"id": "DocExtractionRes.AnotherModule.domRoot",
"kind": "type",
"name": "domRoot",
"signature": "type domRoot = unit => ReactDOM.Client.Root.t",
"docstrings": ["Callback to get the DOM root..."]
}]
}
"constructorName": "SomeStuff",
"docstrings": ["This has inline records..."],
"signature": "SomeStuff"
}]
}
},
{
"id": "DocExtractionRes.AnotherModule.domRoot",
"kind": "type",
"name": "domRoot",
"signature": "type domRoot = unit => ReactDOM.Client.Root.t",
"docstrings": ["Callback to get the DOM root..."]
}]
},
{
"id": "ModuleWithThingsThatShouldNotBeExported.DocExtractionRes",
"name": "ModuleWithThingsThatShouldNotBeExported",
"kind": "module",
"items":
"items": [
{
"name": "ModuleWithThingsThatShouldNotBeExported",
"docstrings": [],
"items": [
{
"id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.t",
"kind": "type",
"name": "t",
"signature": "type t",
"docstrings": ["The type t is stuff."]
},
{
"id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.make",
"kind": "value",
"name": "make",
"signature": "let make: unit => t",
"docstrings": ["The maker of stuff!"]
}]
}
"id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.t",
"kind": "type",
"name": "t",
"signature": "type t",
"docstrings": ["The type t is stuff."]
},
{
"id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.make",
"kind": "value",
"name": "make",
"signature": "let make: unit => t",
"docstrings": ["The maker of stuff!"]
}]
}]
}