From 0b3abfae285b751c15044943d9a7b89d67654177 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Fri, 25 Jun 2021 09:58:26 -0400 Subject: [PATCH] fix animations and support dash separators in descriptions --- custom-elements-manifest.config.js | 48 ++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/custom-elements-manifest.config.js b/custom-elements-manifest.config.js index 692e1e42a..d6784293e 100644 --- a/custom-elements-manifest.config.js +++ b/custom-elements-manifest.config.js @@ -17,6 +17,35 @@ export default { customElementsManifest.package = { name, description, version, author, homepage, license }; } }, + + // Strip dashes from jsDoc comments + { + name: 'shoelace-jsdoc-dashes', + packageLinkPhase({ customElementsManifest, context }) { + for (const module of customElementsManifest?.modules) { + for (const declaration of module?.declarations) { + const items = [ + declaration.animations, + declaration.attributes, + declaration.cssParts, + declaration.cssProperties, + declaration.events, + declaration.members, + declaration?.members?.flatMap(member => member.parameters), + declaration.slots + ]; + + items.flat().map(item => { + // Remove dash prefix and trim whitespace from the description + if (item?.description) { + item.description = item.description.replace(/^-/, '').trim(); + } + }); + } + } + } + }, + // Parse custom jsDoc tags { name: 'shoelace-custom-tags', @@ -42,11 +71,18 @@ export default { const parsed = commentParser.parse(customComments + '\n */'); parsed[0].tags?.map(t => { switch (t.tag) { - case 'since': - case 'status': - classDoc[t.tag] = t.name; + // Animations + case 'animation': + if (!Array.isArray(classDoc['animations'])) { + classDoc['animations'] = []; + } + classDoc['animations'].push({ + name: t.name, + description: t.description + }); break; + // Dependencies case 'dependency': if (!Array.isArray(classDoc['dependencies'])) { classDoc['dependencies'] = []; @@ -54,6 +90,12 @@ export default { classDoc['dependencies'].push(t.name); break; + // Value-only metadata tags + case 'since': + case 'status': + classDoc[t.tag] = t.name; + break; + // All other tags default: if (!Array.isArray(classDoc[t.tag])) {