mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
improve metadata parsing for new analyzer version
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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><${component.tagName}> | ${component.className}</code>
|
||||
<code><${component.tagName}> | ${component.name}</code>
|
||||
</div>
|
||||
|
||||
<div class="component-header__info">
|
||||
|
||||
Reference in New Issue
Block a user