From 6e4e49e343fabdab237fd699fb2f3c135c364428 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Tue, 9 Jan 2024 10:30:03 +0100 Subject: [PATCH 1/5] support inline record fields in doc extraction --- analysis/src/CompletionBackEnd.ml | 13 +- analysis/src/DocExtraction.ml | 72 +++++--- analysis/tests/src/DocExtractionRes.res | 7 +- .../src/expected/DocExtractionRes.res.txt | 15 +- tools/CHANGELOG.md | 1 + tools/src/Tools_Docgen.res | 174 +----------------- tools/src/Tools_Docgen.resi | 6 +- 7 files changed, 77 insertions(+), 211 deletions(-) diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index 975fef31a..f77fa4195 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -3,7 +3,18 @@ open SharedTypes let showConstructor {Constructor.cname = {txt}; args; res} = txt ^ (match args with - | Args [] | InlineRecord _ -> "" + | Args [] -> "" + | InlineRecord fields -> + "({" + ^ (fields + |> List.map (fun (field : field) -> + Printf.sprintf "%s%s: %s" field.fname.txt + (if field.optional then "?" else "") + (Shared.typeToString + (if field.optional then Utils.unwrapIfOption field.typ + else field.typ))) + |> String.concat ", ") + ^ "})" | Args args -> "(" ^ (args diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index d646bd175..b806b6968 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -11,6 +11,7 @@ type constructorDoc = { docstrings: string list; signature: string; deprecated: string option; + inlineRecordFields: fieldDoc list option; } type docItemDetail = @@ -54,6 +55,20 @@ let stringifyDocstrings docstrings = |> List.map (fun docstring -> docstring |> String.trim |> wrapInQuotes) |> array +let stringifyFieldDoc ~indentation (fieldDoc : fieldDoc) = + let open Protocol in + stringifyObject ~indentation:(indentation + 1) + [ + ("name", Some (wrapInQuotes fieldDoc.fieldName)); + ( "deprecated", + match fieldDoc.deprecated with + | Some d -> Some (wrapInQuotes d) + | None -> None ); + ("optional", Some (string_of_bool fieldDoc.optional)); + ("docstrings", Some (stringifyDocstrings fieldDoc.docstrings)); + ("signature", Some (wrapInQuotes fieldDoc.signature)); + ] + let stringifyDetail ?(indentation = 0) (detail : docItemDetail) = let open Protocol in match detail with @@ -62,22 +77,8 @@ let stringifyDetail ?(indentation = 0) (detail : docItemDetail) = [ ("kind", Some (wrapInQuotes "record")); ( "items", - Some - (fieldDocs - |> List.map (fun fieldDoc -> - stringifyObject ~indentation:(indentation + 1) - [ - ("name", Some (wrapInQuotes fieldDoc.fieldName)); - ( "deprecated", - match fieldDoc.deprecated with - | Some d -> Some (wrapInQuotes d) - | None -> None ); - ("optional", Some (string_of_bool fieldDoc.optional)); - ( "docstrings", - Some (stringifyDocstrings fieldDoc.docstrings) ); - ("signature", Some (wrapInQuotes fieldDoc.signature)); - ]) - |> array) ); + Some (fieldDocs |> List.map (stringifyFieldDoc ~indentation) |> array) + ); ] | Variant {constructorDocs} -> stringifyObject ~startOnNewline:true ~indentation @@ -100,6 +101,16 @@ let stringifyDetail ?(indentation = 0) (detail : docItemDetail) = Some (stringifyDocstrings constructorDoc.docstrings) ); ( "signature", Some (wrapInQuotes constructorDoc.signature) ); + ( "inlineRecordFields", + match constructorDoc.inlineRecordFields with + | None -> None + | Some fieldDocs -> + Some + (fieldDocs + |> List.map + (stringifyFieldDoc + ~indentation:(indentation + 1)) + |> array) ); ]) |> array) ); ] @@ -185,24 +196,20 @@ and stringifyDocsForModule ?(indentation = 0) ~originalEnv (d : docsForModule) = |> array) ); ] +let fieldToFieldDoc (field : SharedTypes.field) : fieldDoc = + { + fieldName = field.fname.txt; + docstrings = field.docstring; + optional = field.optional; + signature = Shared.typeToString field.typ; + deprecated = field.deprecated; + } + let typeDetail typ ~env ~full = let open SharedTypes in match TypeUtils.extractTypeFromResolvedType ~env ~full typ with | Some (Trecord {fields}) -> - Some - (Record - { - fieldDocs = - fields - |> List.map (fun (field : field) -> - { - fieldName = field.fname.txt; - docstrings = field.docstring; - optional = field.optional; - signature = Shared.typeToString field.typ; - deprecated = field.deprecated; - }); - }) + Some (Record {fieldDocs = fields |> List.map fieldToFieldDoc}) | Some (Tvariant {constructors}) -> Some (Variant @@ -215,6 +222,11 @@ let typeDetail typ ~env ~full = docstrings = c.docstring; signature = CompletionBackEnd.showConstructor c; deprecated = c.deprecated; + inlineRecordFields = + (match c.args with + | InlineRecord fields -> + Some (fields |> List.map fieldToFieldDoc) + | _ -> None); }); }) | _ -> None diff --git a/analysis/tests/src/DocExtractionRes.res b/analysis/tests/src/DocExtractionRes.res index 582e3bcbe..9ccd611c7 100644 --- a/analysis/tests/src/DocExtractionRes.res +++ b/analysis/tests/src/DocExtractionRes.res @@ -49,7 +49,12 @@ module AnotherModule = { let isGoodStatus = (status: SomeInnerModule.status) => status == Stopped /** Trying how it looks with an inline record in a variant. */ - type someVariantWithInlineRecords = | /** This has inline records...*/ SomeStuff({offline: bool}) + type someVariantWithInlineRecords = + | /** This has inline records...*/ + SomeStuff({ + offline: bool, + /** Is the user online? */ online?: bool, + }) open ReactDOM diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index fdf2b3c0f..53f5ad989 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -125,7 +125,7 @@ extracting docs for src/DocExtractionRes.res "id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords", "kind": "type", "name": "someVariantWithInlineRecords", - "signature": "type someVariantWithInlineRecords =\n | SomeStuff({offline: bool})", + "signature": "type someVariantWithInlineRecords =\n | SomeStuff({offline: bool, online?: bool})", "docstrings": ["Trying how it looks with an inline record in a variant."], "detail": { @@ -134,7 +134,18 @@ extracting docs for src/DocExtractionRes.res { "name": "SomeStuff", "docstrings": ["This has inline records..."], - "signature": "SomeStuff" + "signature": "SomeStuff({offline: bool, online?: bool})", + "inlineRecordFields": [{ + "name": "offline", + "optional": false, + "docstrings": [], + "signature": "bool" + }, { + "name": "online", + "optional": true, + "docstrings": ["Is the user online?"], + "signature": "option" + }] }] } }, diff --git a/tools/CHANGELOG.md b/tools/CHANGELOG.md index 6e728b690..a904df179 100644 --- a/tools/CHANGELOG.md +++ b/tools/CHANGELOG.md @@ -14,6 +14,7 @@ #### :bug: Bug Fix +- Support inline record fields in constructors. - Fix docstrings for module alias. Get internal docstrings of module file. https://github.com/rescript-lang/rescript-vscode/pull/878 - Fix extracted docs of types include escaped linebreaks in signature. https://github.com/rescript-lang/rescript-vscode/pull/891 diff --git a/tools/src/Tools_Docgen.res b/tools/src/Tools_Docgen.res index a7e008d32..71829fc9c 100644 --- a/tools/src/Tools_Docgen.res +++ b/tools/src/Tools_Docgen.res @@ -11,6 +11,7 @@ type constructor = { docstrings: array, signature: string, deprecated?: string, + inlineRecordFields?: array, } @tag("kind") @@ -54,159 +55,6 @@ type rec item = items: array, }) -let decodeDocstrings = item => { - open Js.Json - switch item->Js.Dict.get("docstrings") { - | Some(Array(arr)) => - arr->Js.Array2.map(s => - switch s { - | String(s) => s - | _ => assert(false) - } - ) - | _ => [] - } -} - -let decodeStringByField = (item, field) => { - open Js.Json - switch item->Js.Dict.get(field) { - | Some(String(s)) => s - | _ => assert(false) - } -} - -let decodeDepreacted = item => { - open Js.Json - switch item->Js.Dict.get("deprecated") { - | Some(String(s)) => Some(s) - | _ => None - } -} - -let decodeRecordFields = fields => { - open Js.Json - let items = fields->Js.Array2.map(field => { - switch field { - | Object(doc) => { - let name = doc->decodeStringByField("name") - let docstrings = doc->decodeDocstrings - let signature = doc->decodeStringByField("signature") - let deprecated = doc->decodeDepreacted - let optional = switch Js.Dict.get(doc, "optional") { - | Some(Boolean(bool)) => bool - | _ => assert(false) - } - - {name, docstrings, signature, optional, ?deprecated} - } - - | _ => assert(false) - } - }) - Record({items: items}) -} - -let decodeConstructorFields = fields => { - open Js.Json - let items = fields->Js.Array2.map(field => { - switch field { - | Object(doc) => { - let name = doc->decodeStringByField("name") - let docstrings = doc->decodeDocstrings - let signature = doc->decodeStringByField("signature") - let deprecated = doc->decodeDepreacted - - {name, docstrings, signature, ?deprecated} - } - - | _ => assert(false) - } - }) - Variant({items: items}) -} - -let decodeDetail = detail => { - open Js.Json - - switch detail { - | Object(detail) => - switch (detail->Js.Dict.get("kind"), detail->Js.Dict.get("items")) { - | (Some(String(kind)), Some(Array(items))) => - switch kind { - | "record" => decodeRecordFields(items) - | "variant" => decodeConstructorFields(items) - | _ => assert(false) - } - | _ => assert(false) - } - - | _ => assert(false) - } -} - -let rec decodeValue = item => { - let id = item->decodeStringByField("id") - let signature = item->decodeStringByField("signature") - let name = item->decodeStringByField("name") - let deprecated = item->decodeDepreacted - let docstrings = item->decodeDocstrings - Value({id, docstrings, signature, name, ?deprecated}) -} -and decodeType = item => { - let id = item->decodeStringByField("id") - let signature = item->decodeStringByField("signature") - let name = item->decodeStringByField("name") - let deprecated = item->decodeDepreacted - let docstrings = item->decodeDocstrings - let detail = switch item->Js_dict.get("detail") { - | Some(field) => decodeDetail(field)->Some - | None => None - } - Type({id, docstrings, signature, name, ?deprecated, ?detail}) -} -and decodeModuleAlias = item => { - open Js.Json - let id = item->decodeStringByField("id") - let name = item->decodeStringByField("name") - let docstrings = item->decodeDocstrings - let items = switch Js.Dict.get(item, "items") { - | Some(Array(items)) => items->Js.Array2.map(item => decodeItem(item)) - | _ => assert(false) - } - ModuleAlias({id, items, name, docstrings}) -} -and decodeModule = item => { - open Js.Json - let id = item->decodeStringByField("id") - let name = item->decodeStringByField("name") - let deprecated = item->decodeDepreacted - let docstrings = item->decodeDocstrings - let items = switch Js.Dict.get(item, "items") { - | Some(Array(items)) => items->Js.Array2.map(item => decodeItem(item)) - | _ => assert(false) - } - Module({id, name, docstrings, ?deprecated, items}) -} -and decodeItem = item => { - open Js.Json - switch item { - | Object(value) => - switch Js.Dict.get(value, "kind") { - | Some(String(kind)) => - switch kind { - | "type" => decodeType(value) - | "value" => decodeValue(value) - | "module" => decodeModule(value) - | "moduleAlias" => decodeModuleAlias(value) - | _ => assert(false) - } - | _ => assert(false) - } - | _ => assert(false) - } -} - type doc = { name: string, deprecated: option, @@ -217,22 +65,4 @@ type doc = { /** `decodeFromJson(json)` parse JSON generated from `restool doc` command */ -let decodeFromJson = json => { - open Js.Json - - switch json { - | Object(mod) => { - let name = mod->decodeStringByField("name") - let deprecated = mod->decodeDepreacted - let docstrings = mod->decodeDocstrings - let items = switch Js.Dict.get(mod, "items") { - | Some(Array(items)) => items->Js.Array2.map(item => decodeItem(item)) - | _ => assert(false) - } - - {name, deprecated, docstrings, items} - } - - | _ => assert(false) - } -} +external decodeFromJson: Js.Json.t => doc = "%identity" diff --git a/tools/src/Tools_Docgen.resi b/tools/src/Tools_Docgen.resi index 513471b59..f573b4941 100644 --- a/tools/src/Tools_Docgen.resi +++ b/tools/src/Tools_Docgen.resi @@ -10,6 +10,7 @@ type constructor = { docstrings: array, signature: string, deprecated?: string, + inlineRecordFields?: array, } @tag("kind") type detail = @@ -54,9 +55,4 @@ type rec item = type doc = {name: string, deprecated: option, docstrings: array, items: array} -let decodeValue: Js.Dict.t => item -let decodeType: Js.Dict.t => item -let decodeModule: Js.Dict.t => item -let decodeModuleAlias: Js.Dict.t => item -let decodeItem: Js.Json.t => item let decodeFromJson: Js.Json.t => doc From 74463de61a6022f9369516e6312e26a05a03b0c1 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Tue, 9 Jan 2024 10:31:28 +0100 Subject: [PATCH 2/5] changelog --- tools/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/CHANGELOG.md b/tools/CHANGELOG.md index a904df179..d9dcb0c17 100644 --- a/tools/CHANGELOG.md +++ b/tools/CHANGELOG.md @@ -14,7 +14,7 @@ #### :bug: Bug Fix -- Support inline record fields in constructors. +- Support inline record fields in constructors. https://github.com/rescript-lang/rescript-vscode/pull/889 - Fix docstrings for module alias. Get internal docstrings of module file. https://github.com/rescript-lang/rescript-vscode/pull/878 - Fix extracted docs of types include escaped linebreaks in signature. https://github.com/rescript-lang/rescript-vscode/pull/891 From e16a60dc605e6e4447d6a53168071cd6168c725c Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 10 Jan 2024 08:20:05 +0100 Subject: [PATCH 3/5] fix missing docstrings in module --- analysis/src/DocExtraction.ml | 1 + analysis/tests/src/expected/DocExtraction2.res.txt | 1 + analysis/tests/src/expected/DocExtraction2.resi.txt | 1 + analysis/tests/src/expected/DocExtractionRes.res.txt | 3 +++ 4 files changed, 6 insertions(+) diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index b806b6968..0941b394a 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -156,6 +156,7 @@ let rec stringifyDocItem ?(indentation = 0) ~originalEnv (item : docItem) = ("id", Some (wrapInQuotes m.id)); ("name", Some (wrapInQuotes m.name)); ("kind", Some (wrapInQuotes "module")); + ("docstrings", Some (stringifyDocstrings m.docstring)); ( "items", Some (m.items diff --git a/analysis/tests/src/expected/DocExtraction2.res.txt b/analysis/tests/src/expected/DocExtraction2.res.txt index 7645cfac0..74f2e9cc1 100644 --- a/analysis/tests/src/expected/DocExtraction2.res.txt +++ b/analysis/tests/src/expected/DocExtraction2.res.txt @@ -24,6 +24,7 @@ preferring found resi file for impl: src/DocExtraction2.resi "id": "DocExtraction2.InnerModule", "name": "InnerModule", "kind": "module", + "docstrings": [], "items": [ { "id": "DocExtraction2.InnerModule.t", diff --git a/analysis/tests/src/expected/DocExtraction2.resi.txt b/analysis/tests/src/expected/DocExtraction2.resi.txt index 51d938f0c..074ce4ccf 100644 --- a/analysis/tests/src/expected/DocExtraction2.resi.txt +++ b/analysis/tests/src/expected/DocExtraction2.resi.txt @@ -23,6 +23,7 @@ extracting docs for src/DocExtraction2.resi "id": "DocExtraction2.InnerModule", "name": "InnerModule", "kind": "module", + "docstrings": [], "items": [ { "id": "DocExtraction2.InnerModule.t", diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index 53f5ad989..75e96a39c 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -52,6 +52,7 @@ extracting docs for src/DocExtractionRes.res "id": "DocExtractionRes.SomeInnerModule", "name": "SomeInnerModule", "kind": "module", + "docstrings": ["Another module level docstring here."], "items": [ { "id": "DocExtractionRes.SomeInnerModule.status", @@ -99,6 +100,7 @@ extracting docs for src/DocExtractionRes.res "id": "DocExtractionRes.AnotherModule", "name": "AnotherModule", "kind": "module", + "docstrings": ["Mighty fine module here too!"], "items": [ { "id": "DocExtractionRes.LinkedModule", @@ -161,6 +163,7 @@ extracting docs for src/DocExtractionRes.res "id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported", "name": "ModuleWithThingsThatShouldNotBeExported", "kind": "module", + "docstrings": [], "items": [ { "id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.t", From 786380fed9f0948341a8e2e2756a5769a2f58f46 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 10 Jan 2024 08:27:37 +0100 Subject: [PATCH 4/5] rename constructor payload field and prepare for potentially adding more detail for other constructor payload types as well --- analysis/src/DocExtraction.ml | 43 +++++++++++++------ .../src/expected/DocExtractionRes.res.txt | 25 ++++++----- tools/src/Tools_Docgen.res | 5 ++- tools/src/Tools_Docgen.resi | 6 ++- 4 files changed, 54 insertions(+), 25 deletions(-) diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index 0941b394a..8ce46d444 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -6,12 +6,14 @@ type fieldDoc = { deprecated: string option; } +type constructorPayload = InlineRecord of {fieldDocs: fieldDoc list} + type constructorDoc = { constructorName: string; docstrings: string list; signature: string; deprecated: string option; - inlineRecordFields: fieldDoc list option; + items: constructorPayload option; } type docItemDetail = @@ -69,6 +71,21 @@ let stringifyFieldDoc ~indentation (fieldDoc : fieldDoc) = ("signature", Some (wrapInQuotes fieldDoc.signature)); ] +let stringifyConstructorPayload ~indentation + (constructorPayload : constructorPayload) = + let open Protocol in + match constructorPayload with + | InlineRecord {fieldDocs} -> + stringifyObject ~indentation:(indentation + 1) + [ + ("kind", Some (wrapInQuotes "inlineRecord")); + ( "fields", + Some + (fieldDocs + |> List.map (stringifyFieldDoc ~indentation:(indentation + 1)) + |> array) ); + ] + let stringifyDetail ?(indentation = 0) (detail : docItemDetail) = let open Protocol in match detail with @@ -101,16 +118,14 @@ let stringifyDetail ?(indentation = 0) (detail : docItemDetail) = Some (stringifyDocstrings constructorDoc.docstrings) ); ( "signature", Some (wrapInQuotes constructorDoc.signature) ); - ( "inlineRecordFields", - match constructorDoc.inlineRecordFields with + ( "items", + match constructorDoc.items with | None -> None - | Some fieldDocs -> + | Some constructorPayload -> Some - (fieldDocs - |> List.map - (stringifyFieldDoc - ~indentation:(indentation + 1)) - |> array) ); + (stringifyConstructorPayload + ~indentation:(indentation + 1) + constructorPayload) ); ]) |> array) ); ] @@ -223,10 +238,12 @@ let typeDetail typ ~env ~full = docstrings = c.docstring; signature = CompletionBackEnd.showConstructor c; deprecated = c.deprecated; - inlineRecordFields = + items = (match c.args with | InlineRecord fields -> - Some (fields |> List.map fieldToFieldDoc) + Some + (InlineRecord + {fieldDocs = fields |> List.map fieldToFieldDoc}) | _ -> None); }); }) @@ -325,7 +342,9 @@ let extractDocs ~path ~debug = id; name = item.name; items; - docstring = item.docstring @ internalDocstrings |> List.map String.trim; + docstring = + item.docstring @ internalDocstrings + |> List.map String.trim; }) | Module (Structure m) -> (* module Whatever = {} in res or module Whatever: {} in resi. *) diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index 75e96a39c..f69e272c7 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -137,17 +137,20 @@ extracting docs for src/DocExtractionRes.res "name": "SomeStuff", "docstrings": ["This has inline records..."], "signature": "SomeStuff({offline: bool, online?: bool})", - "inlineRecordFields": [{ - "name": "offline", - "optional": false, - "docstrings": [], - "signature": "bool" - }, { - "name": "online", - "optional": true, - "docstrings": ["Is the user online?"], - "signature": "option" - }] + "items": { + "kind": "inlineRecord", + "fields": [{ + "name": "offline", + "optional": false, + "docstrings": [], + "signature": "bool" + }, { + "name": "online", + "optional": true, + "docstrings": ["Is the user online?"], + "signature": "option" + }] + } }] } }, diff --git a/tools/src/Tools_Docgen.res b/tools/src/Tools_Docgen.res index 71829fc9c..3595c9b37 100644 --- a/tools/src/Tools_Docgen.res +++ b/tools/src/Tools_Docgen.res @@ -6,12 +6,15 @@ type field = { deprecated?: string, } +@tag("kind") +type constructorPayload = | @as("inlineRecord") InlineRecord({fields: array}) + type constructor = { name: string, docstrings: array, signature: string, deprecated?: string, - inlineRecordFields?: array, + constructorPayload?: constructorPayload, } @tag("kind") diff --git a/tools/src/Tools_Docgen.resi b/tools/src/Tools_Docgen.resi index f573b4941..28796560d 100644 --- a/tools/src/Tools_Docgen.resi +++ b/tools/src/Tools_Docgen.resi @@ -5,12 +5,16 @@ type field = { optional: bool, deprecated?: string, } + +@tag("kind") +type constructorPayload = | @as("inlineRecord") InlineRecord({fields: array}) + type constructor = { name: string, docstrings: array, signature: string, deprecated?: string, - inlineRecordFields?: array, + constructorPayload?: constructorPayload, } @tag("kind") type detail = From 430d44e537786453c62d8f81be1adaca0d1e0e85 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Thu, 11 Jan 2024 08:25:39 +0100 Subject: [PATCH 5/5] rename --- analysis/src/DocExtraction.ml | 2 +- analysis/tests/src/expected/DocExtractionRes.res.txt | 2 +- tools/src/Tools_Docgen.res | 2 +- tools/src/Tools_Docgen.resi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index 8ce46d444..59320d94a 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -118,7 +118,7 @@ let stringifyDetail ?(indentation = 0) (detail : docItemDetail) = Some (stringifyDocstrings constructorDoc.docstrings) ); ( "signature", Some (wrapInQuotes constructorDoc.signature) ); - ( "items", + ( "payload", match constructorDoc.items with | None -> None | Some constructorPayload -> diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index f69e272c7..a197ecf56 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -137,7 +137,7 @@ extracting docs for src/DocExtractionRes.res "name": "SomeStuff", "docstrings": ["This has inline records..."], "signature": "SomeStuff({offline: bool, online?: bool})", - "items": { + "payload": { "kind": "inlineRecord", "fields": [{ "name": "offline", diff --git a/tools/src/Tools_Docgen.res b/tools/src/Tools_Docgen.res index 3595c9b37..d62458d00 100644 --- a/tools/src/Tools_Docgen.res +++ b/tools/src/Tools_Docgen.res @@ -14,7 +14,7 @@ type constructor = { docstrings: array, signature: string, deprecated?: string, - constructorPayload?: constructorPayload, + payload?: constructorPayload, } @tag("kind") diff --git a/tools/src/Tools_Docgen.resi b/tools/src/Tools_Docgen.resi index 28796560d..f1c338a8a 100644 --- a/tools/src/Tools_Docgen.resi +++ b/tools/src/Tools_Docgen.resi @@ -14,7 +14,7 @@ type constructor = { docstrings: array, signature: string, deprecated?: string, - constructorPayload?: constructorPayload, + payload?: constructorPayload, } @tag("kind") type detail =