Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/analyze/flavors/custom-element/exclude-node.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/cli/analyzer-cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface AnalyzerCliConfig {
analyzeDependencies?: boolean;
analyzeDefaultLibrary?: boolean;
discoverNodeModules?: boolean;
excludeClasses: string;

markdown?: {
headerLevel?: number;
Expand Down
4 changes: 4 additions & 0 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/cli/util/analyze-globs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
});

Expand Down