diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index 6dc61cd19..71a74e329 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -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 diff --git a/analysis/tests/src/expected/DocExtraction2.res.txt b/analysis/tests/src/expected/DocExtraction2.res.txt index afdbb4c33..4f7f4dbbd 100644 --- a/analysis/tests/src/expected/DocExtraction2.res.txt +++ b/analysis/tests/src/expected/DocExtraction2.res.txt @@ -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."] + }] }] } diff --git a/analysis/tests/src/expected/DocExtraction2.resi.txt b/analysis/tests/src/expected/DocExtraction2.resi.txt index 7b53697a0..923680e52 100644 --- a/analysis/tests/src/expected/DocExtraction2.resi.txt +++ b/analysis/tests/src/expected/DocExtraction2.resi.txt @@ -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."] + }] }] } diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index 1f50a641d..4a6edea83 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -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!"] + }] }] }