diff --git a/apps/website/auto-api.ts b/apps/website/auto-api.ts index 25d0ad768..5d50e02e5 100644 --- a/apps/website/auto-api.ts +++ b/apps/website/auto-api.ts @@ -8,27 +8,30 @@ const parser = new Parser(); /** * Tree-Sitter query docs: https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax - * Pay particular attention to the following sections: capturing nodes, wildcard nodes, and anchors. + * Pay particular attention to the following sections: capturing nodes, wildcard nodes,predicates,alternations, and anchors. * * To have a way of being able to see the Tree-Sitter AST in real-time: the ideal setup comes included in Neovim. In ex mode, simply run * the command below and you'll have the file's AST viewer open in real-time: `:InspectTree` **/ - +const commentPropType = ` + (object_type + (comment) @comment + . + (property_signature + name: (_) @prop + type: (type_annotation (_) @type) + ) + )`; +const nestedTypeDef = `(_ ${commentPropType})`; const query = new Query( TS.tsx, `(type_alias_declaration - name: (type_identifier) @subComponentName - (intersection_type - (object_type - (comment) @comment - . - (property_signature - name: (_) @prop - type: (type_annotation (_) @type) - ) - ) - ) - ) + name: (type_identifier) @subComponentName (#match? @subComponentName "^Public") + [ + (${nestedTypeDef}) + (${commentPropType}) + ] + ) `, ); diff --git a/apps/website/src/components/api-table/auto-api.tsx b/apps/website/src/components/api-table/auto-api.tsx index b216be717..704bac2b0 100644 --- a/apps/website/src/components/api-table/auto-api.tsx +++ b/apps/website/src/components/api-table/auto-api.tsx @@ -37,7 +37,8 @@ const currentHeader = $(() => { }); const currentSubHeader = $((text: string) => { - let subHeader = text.replace(/(p|P)rops/, ''); + const removePublicPrefix = text.replace(/^Public/, ''); + let subHeader = removePublicPrefix.replace(/(p|P)rops/, ''); const hasCapital = /[a-z][A-Z]/.exec(subHeader)?.index; if (hasCapital != undefined) { subHeader =