diff --git a/src/analyze/flavors/custom-element/exclude-node.ts b/src/analyze/flavors/custom-element/exclude-node.ts index 9b455931..369e36f0 100644 --- a/src/analyze/flavors/custom-element/exclude-node.ts +++ b/src/analyze/flavors/custom-element/exclude-node.ts @@ -1,5 +1,6 @@ import { Node } from "typescript"; import { AnalyzerVisitContext } from "../../analyzer-visit-context"; +import { getNodeName } from "../../util/ast-util"; /** * Excludes nodes from "lib.dom.d.ts" if analyzeLibDom is false @@ -11,6 +12,12 @@ export function excludeNode(node: Node, context: AnalyzerVisitContext): boolean return undefined; } + // Exclude polymer element related super classes + const declName = getNodeName(node, context); + if (declName === "PolymerElement") { + return true; + } + return isLibDom(node); } diff --git a/src/cli/analyzer-cli-config.ts b/src/cli/analyzer-cli-config.ts index 9b8012da..36030e5c 100644 --- a/src/cli/analyzer-cli-config.ts +++ b/src/cli/analyzer-cli-config.ts @@ -21,6 +21,7 @@ export interface AnalyzerCliConfig { analyzeDependencies?: boolean; analyzeDefaultLibrary?: boolean; discoverNodeModules?: boolean; + excludeClasses: string; markdown?: { headerLevel?: number; diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 46635e4f..704ceb7b 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -84,6 +84,10 @@ o {tagname}: The element's tag name`, boolean: true, alias: "d" }) + .option("excludeClasses", { + describe: `List of classes to exclude from parsing, separated by commas`, + string: true + }) .option("verbose", { boolean: true, hidden: true diff --git a/src/cli/util/analyze-globs.ts b/src/cli/util/analyze-globs.ts index b3e672ed..8d589a49 100644 --- a/src/cli/util/analyze-globs.ts +++ b/src/cli/util/analyze-globs.ts @@ -47,6 +47,12 @@ export async function analyzeGlobs( // Parse all the files with typescript const { program, files } = compileTypescript(filePaths); + // Index excluded classes + const excludedDeclarationNames: string[] = []; + if (config.excludeClasses) { + excludedDeclarationNames.push(...config.excludeClasses.split(",").map(s => s.trim())); + } + // Analyze each file with web component analyzer const results: AnalyzerResult[] = []; for (const file of files) { @@ -60,7 +66,8 @@ export async function analyzeGlobs( analyzeDependencies: config.analyzeDependencies, analyzeDefaultLib: config.analyzeDefaultLibrary, analyzeGlobalFeatures: config.analyzeGlobalFeatures, - analyzeAllDeclarations: config.format == "json2" // TODO: find a better way to construct the config + analyzeAllDeclarations: config.format == "json2", // TODO: find a better way to construct the config + excludedDeclarationNames: excludedDeclarationNames } });