diff --git a/api-generator/build-apidoc.js b/api-generator/build-apidoc.js index b11bd771a..2280246cd 100644 --- a/api-generator/build-apidoc.js +++ b/api-generator/build-apidoc.js @@ -12,7 +12,8 @@ const staticMessages = { functions: 'Defines the custom functions used by the module.', events: "Defines the custom events used by the component's emit.", interfaces: 'Defines the custom interfaces used by the module.', - types: 'Defines the custom types used by the module.' + types: 'Defines the custom types used by the module.', + tokens: 'Define design tokens used by the component.' }; const app = new TypeDoc.Application(); @@ -555,6 +556,81 @@ if (project) { }; }); + const module_namespaces_group = module.groups?.find((g) => g.title === 'Namespaces'); + + module_namespaces_group && + module_namespaces_group.children.forEach((pevent) => { + const module_interfaces_group = pevent?.groups?.find((g) => g.title === 'Interfaces'); + + module_interfaces_group && + module_interfaces_group.children.forEach((event) => { + const event_props_description = event.comment && event.comment.summary.map((s) => s.text || '').join(' '); + let component_prop = ''; + + if (event.comment && event.comment.getTag('@see')) { + const tag = event.comment.getTag('@see'); + const content = tag.content[0]; + + if (content.text.includes("['")) { + component_prop = `${content.target.name}${content.text}`; + } else { + component_prop = `${content.text === content.target?.name ? content.target.parent.name : content.target?.name}.${content.text}`; + } + } + + !doc[name]['tokens'] && + (doc[name]['tokens'] = { + description: staticMessages['tokens'], + values: {} + }); + + const props = []; + + const setProps = (_declaration, _name) => { + if (_declaration?.groups) { + const event_props_group = _declaration.groups.find((g) => g.title === 'Properties'); + + event_props_group && + event_props_group.children.forEach((prop) => { + if (prop.type?.declaration) { + setProps(prop.type?.declaration, prop.name); + } else if (prop.comment?.getTag('@designToken')) { + props.push({ + name: _name ? `${_name}.${prop.name}` : prop.name, + token: prop.comment.getTag('@designToken').content[0]?.text || '', + optional: prop.flags.isOptional, + readonly: prop.flags.isReadonly, + type: prop.type.toString(), + default: prop.comment && prop.comment.getTag('@defaultValue') ? prop.comment.getTag('@defaultValue').content[0]?.text || '' : '', // TODO: Check + description: + prop.comment && + prop.comment.summary + .map((s) => { + if (s.text.indexOf('[here]') > -1) { + return `${s.text.slice(0, s.text.indexOf('[here]'))} here ${s.text.slice( + s.text.indexOf(')') + 1 + )}`; + } + + return s.text || ''; + }) + .join(' '), + deprecated: prop.comment && prop.comment.getTag('@deprecated') ? parseText(prop.comment.getTag('@deprecated').content[0]?.text) : undefined + }); + } + }); + } + }; + + setProps(event); + + doc[name]['tokens'].values[event.name] = { + description: event_props_description, + props + }; + }); + }); + // app.generateJson(module, `./api-generator/module-typedoc.json`); }); diff --git a/components/doc/DocApiTable.vue b/components/doc/DocApiTable.vue index da7e65cde..03d757e2c 100644 --- a/components/doc/DocApiTable.vue +++ b/components/doc/DocApiTable.vue @@ -1,6 +1,6 @@