improve metadata parsing for new analyzer version

This commit is contained in:
Cory LaViska
2021-07-06 10:29:58 -04:00
parent 9f3bf24d06
commit 5bcce80b50
2 changed files with 6 additions and 19 deletions

View File

@@ -22,17 +22,11 @@ export default {
analyzePhase({ ts, node, moduleDoc, context }) {
switch (node.kind) {
case ts.SyntaxKind.ClassDeclaration:
const hasDefaultModifier = node?.modifiers?.some(mod => ts.SyntaxKind.DefaultKeyword === mod.kind);
const className = hasDefaultModifier ? 'default' : node?.name?.getText();
const className = node.name.getText();
const classDoc = moduleDoc?.declarations?.find(declaration => declaration.name === className);
const customTags = ['animation', 'dependency', 'since', 'status'];
let customComments = '/**';
// We only care about custom tags on classes
if (!classDoc) {
return;
}
node.jsDoc?.forEach(jsDoc => {
jsDoc?.tags?.forEach(tag => {
const tagName = tag.tagName.getText();

View File

@@ -248,17 +248,10 @@
function getAllComponents(metadata) {
const allComponents = [];
metadata.modules.map(module => {
module.exports.map(ex => {
if (ex.kind === 'custom-element-definition') {
const tagName = ex.name;
const className = ex.declaration.name;
const component = module?.declarations.find(dec => dec.name === 'default');
if (component) {
allComponents.push(Object.assign(component, { className, tagName }));
}
metadata.modules?.map(module => {
module.declarations?.map(declaration => {
if (declaration.customElement) {
allComponents.push(declaration);
}
});
});
@@ -327,7 +320,7 @@
result += `
<div class="component-header">
<div class="component-header__tag">
<code>&lt;${component.tagName}&gt; | ${component.className}</code>
<code>&lt;${component.tagName}&gt; | ${component.name}</code>
</div>
<div class="component-header__info">