web-component-analyzer
- Version 2.0.0
- Published
- 722 kB
- 4 dependencies
- MIT license
Install
npm i web-component-analyzer
yarn add web-component-analyzer
pnpm add web-component-analyzer
Overview
CLI that analyzes web components
Index
Variables
Functions
- analyzeHTMLElement()
- analyzeSourceFile()
- analyzeText()
- getExtendsHeritageClauses()
- getExtendsHeritageClausesInChain()
- getJsDoc()
- getJsDocType()
- getMixinHeritageClauses()
- getMixinHeritageClausesInChain()
- getSuperclassHeritageClause()
- parseSimpleJsDocTypeExpression()
- transformAnalyzerResult()
- visitAllHeritageClauses()
Classes
Interfaces
Type Aliases
Variables
variable ALL_COMPONENT_FEATURES
const ALL_COMPONENT_FEATURES: ComponentFeature[];
variable VERSION
const VERSION: string;
Functions
function analyzeHTMLElement
analyzeHTMLElement: ( program: Program, ts?: any) => ComponentDeclaration | undefined;
This function only analyzes the HTMLElement declaration found in "lib.dom.d.ts" source file provided by Typescript.
Parameter program
Parameter ts
function analyzeSourceFile
analyzeSourceFile: ( sourceFile: SourceFile, options: AnalyzerOptions) => AnalyzerResult;
Analyzes all components in a source file.
Parameter sourceFile
Parameter options
function analyzeText
analyzeText: ( inputFiles: VirtualSourceFile[] | VirtualSourceFile, config?: Partial<AnalyzerOptions>) => AnalyzeTextResult;
Analyzes components in code
Parameter inputFiles
Parameter config
function getExtendsHeritageClauses
getExtendsHeritageClauses: ( declaration: ComponentDeclaration) => ComponentHeritageClause[];
Returns all extends heritage clauses for the declaration
Parameter declaration
function getExtendsHeritageClausesInChain
getExtendsHeritageClausesInChain: ( declaration: ComponentDeclaration) => ComponentHeritageClause[];
Returns extends heritage clauses for the declaration and all inherited declarations
Parameter declaration
function getJsDoc
getJsDoc: (node: Node, ts: any, tagNames?: string[]) => JsDoc | undefined;
Returns jsdoc for a given node.
Parameter node
Parameter ts
Parameter tagNames
function getJsDocType
getJsDocType: ( jsDoc: JsDoc, context: { program: Program; ts: typeof tsModule }) => SimpleType | undefined;
Finds a jsdoc tag in the jsdoc and returns the corresponding simple type
Parameter jsDoc
Parameter context
function getMixinHeritageClauses
getMixinHeritageClauses: ( declaration: ComponentDeclaration) => ComponentHeritageClause[];
Returns mixin heritage clauses for the declaration
Parameter declaration
function getMixinHeritageClausesInChain
getMixinHeritageClausesInChain: ( declaration: ComponentDeclaration) => ComponentHeritageClause[];
Returns mixin heritage clauses for the declaration and all inherited declarations
Parameter declaration
function getSuperclassHeritageClause
getSuperclassHeritageClause: ( declaration: ComponentDeclaration) => ComponentHeritageClause | undefined;
Returns the superclass heritage clause
Parameter declaration
function parseSimpleJsDocTypeExpression
parseSimpleJsDocTypeExpression: ( str: string, context: { program: Program; ts: typeof tsModule }) => SimpleType;
Converts a given string to a SimpleType Defaults to ANY See http://usejsdoc.org/tags-type.html
Parameter str
Parameter context
function transformAnalyzerResult
transformAnalyzerResult: ( kind: TransformerKind, results: AnalyzerResult | AnalyzerResult[], program: Program, config?: Partial<TransformerConfig>) => string;
Transforms the analyzer results into a string representation based on the transformer kind
Parameter kind
Parameter results
Parameter program
Parameter config
function visitAllHeritageClauses
visitAllHeritageClauses: ( declaration: ComponentDeclaration, emit: (clause: ComponentHeritageClause) => void) => void;
A helper function that makes it possible to visit all heritage clauses in the inheritance chain.
Parameter declaration
Parameter emit
Classes
class JsDocFlavor
class JsDocFlavor implements AnalyzerFlavor {}
Flavors for analyzing jsdoc related features
property discoverDefinitions
discoverDefinitions: ( node: Node, context: AnalyzerVisitContext) => DefinitionNodeResult[];
property discoverFeatures
discoverFeatures: Partial<FeatureDiscoverVisitMap<AnalyzerVisitContext>>;
property discoverGlobalFeatures
discoverGlobalFeatures: Partial<FeatureDiscoverVisitMap<AnalyzerVisitContext>>;
property refineDeclaration
refineDeclaration: ( declaration: ComponentDeclaration, context: AnalyzerVisitContext) => ComponentDeclaration;
property refineFeature
refineFeature: Partial<FeatureRefineVisitMap>;
Interfaces
interface AnalyzerConfig
interface AnalyzerConfig {}
Configuration to give when analyzing components.
property analyzeAllDeclarations
analyzeAllDeclarations?: boolean;
property analyzeDefaultLib
analyzeDefaultLib?: boolean;
property analyzeDependencies
analyzeDependencies?: boolean;
property analyzeGlobalFeatures
analyzeGlobalFeatures?: boolean;
property excludedDeclarationNames
excludedDeclarationNames?: string[];
property features
features?: ComponentFeature[];
interface AnalyzerDeclarationVisitContext
interface AnalyzerDeclarationVisitContext extends AnalyzerVisitContext {}
property declarationNode
declarationNode: Node;
property getDeclaration
getDeclaration: () => ComponentDeclaration;
property sourceFile
sourceFile: SourceFile;
interface AnalyzerFlavor
interface AnalyzerFlavor {}
property discoverFeatures
discoverFeatures?: Partial< FeatureDiscoverVisitMap<AnalyzerDeclarationVisitContext>>;
property discoverGlobalFeatures
discoverGlobalFeatures?: Partial<FeatureDiscoverVisitMap<AnalyzerVisitContext>>;
property refineFeature
refineFeature?: Partial<FeatureRefineVisitMap>;
method discoverDefinitions
discoverDefinitions: ( node: Node, context: AnalyzerVisitContext) => DefinitionNodeResult[] | undefined;
method discoverInheritance
discoverInheritance: ( node: Node, context: AnalyzerVisitContext) => InheritanceResult | undefined;
method excludeNode
excludeNode: (node: Node, context: AnalyzerVisitContext) => boolean | undefined;
method refineDeclaration
refineDeclaration: ( declaration: ComponentDeclaration, context: AnalyzerDeclarationVisitContext) => ComponentDeclaration | undefined;
interface AnalyzerOptions
interface AnalyzerOptions {}
Options to give when analyzing components
interface AnalyzerResult
interface AnalyzerResult {}
The result returned after components have been analyzed.
property componentDefinitions
componentDefinitions: ComponentDefinition[];
property declarations
declarations?: ComponentDeclaration[];
property globalFeatures
globalFeatures?: ComponentFeatures;
property sourceFile
sourceFile: SourceFile;
interface AnalyzerVisitContext
interface AnalyzerVisitContext {}
This context is used in the entire analyzer. A new instance of this is created whenever the analyzer runs.
property cache
cache: { featureCollection: WeakMap<Node, ComponentFeatureCollection>; componentDeclarationCache: WeakMap<Node, ComponentDeclaration>; general: Map<unknown, unknown>;};
property checker
checker: TypeChecker;
property config
config: AnalyzerConfig;
property flavors
flavors: AnalyzerFlavor[];
property program
program: Program;
property ts
ts: typeof tsModule;
method emitContinue
emitContinue: () => void;
interface AnalyzeTextResult
interface AnalyzeTextResult {}
property analyzedSourceFiles
analyzedSourceFiles: SourceFile[];
property checker
checker: TypeChecker;
property program
program: Program;
property results
results: AnalyzerResult[];
interface ComponentCssPart
interface ComponentCssPart extends ComponentFeatureBase {}
property name
name: string;
interface ComponentCssProperty
interface ComponentCssProperty extends ComponentFeatureBase {}
interface ComponentDeclaration
interface ComponentDeclaration extends ComponentFeatures {}
property declarationNodes
declarationNodes: Set<Node>;
property deprecated
deprecated?: boolean | string;
property heritageClauses
heritageClauses: ComponentHeritageClause[];
property jsDoc
jsDoc?: JsDoc;
property kind
kind: ComponentDeclarationKind;
property node
node: Node;
property sourceFile
sourceFile: SourceFile;
property symbol
symbol?: Symbol;
interface ComponentDefinition
interface ComponentDefinition {}
property declaration
declaration?: ComponentDeclaration;
property identifierNodes
identifierNodes: Set<Node>;
property sourceFile
sourceFile: SourceFile;
property tagName
tagName: string;
property tagNameNodes
tagNameNodes: Set<Node>;
interface ComponentEvent
interface ComponentEvent extends ComponentFeatureBase {}
property deprecated
deprecated?: boolean | string;
property name
name: string;
property node
node: Node;
property type
type?: () => SimpleType | Type;
property typeHint
typeHint?: string;
property visibility
visibility?: VisibilityKind;
interface ComponentFeatureBase
interface ComponentFeatureBase {}
property declaration
declaration?: ComponentDeclaration;
property jsDoc
jsDoc?: JsDoc;
interface ComponentFeatureCollection
interface ComponentFeatureCollection {}
interface ComponentFeatures
interface ComponentFeatures {}
interface ComponentHeritageClause
interface ComponentHeritageClause {}
property declaration
declaration: ComponentDeclaration | undefined;
property identifier
identifier: Node;
property kind
kind: ComponentHeritageClauseKind;
interface ComponentMemberAttribute
interface ComponentMemberAttribute extends ComponentMemberBase {}
interface ComponentMemberBase
interface ComponentMemberBase extends ComponentFeatureBase {}
property default
default?: unknown;
property deprecated
deprecated?: boolean | string;
property kind
kind: ComponentMemberKind;
property meta
meta?: LitElementPropertyConfig;
property modifiers
modifiers?: Set<ModifierKind>;
property node
node: Node;
property priority
priority?: PriorityKind;
property reflect
reflect?: ComponentMemberReflectKind;
property required
required?: boolean;
property type
type: undefined | (() => Type | SimpleType);
property typeHint
typeHint?: string;
property visibility
visibility?: VisibilityKind;
interface ComponentMemberProperty
interface ComponentMemberProperty extends ComponentMemberBase {}
interface ComponentMethod
interface ComponentMethod extends ComponentFeatureBase {}
property name
name: string;
property node
node?: Node;
property type
type?: () => SimpleType | Type;
property visibility
visibility?: VisibilityKind;
interface ComponentSlot
interface ComponentSlot extends ComponentFeatureBase {}
property name
name?: string;
property permittedTagNames
permittedTagNames?: string[];
interface DefinitionNodeResult
interface DefinitionNodeResult {}
property analyzerFlavor
analyzerFlavor?: AnalyzerFlavor;
property declarationNode
declarationNode?: Node;
property identifierNode
identifierNode?: Node;
property tagName
tagName: string;
property tagNameNode
tagNameNode?: Node;
interface FeatureVisitReturnTypeMap
interface FeatureVisitReturnTypeMap {}
interface InheritanceResult
interface InheritanceResult {}
property declarationKind
declarationKind?: ComponentDeclarationKind;
property declarationNodes
declarationNodes?: Node[];
property heritageClauses
heritageClauses?: ComponentHeritageClause[];
interface IVirtualSourceFile
interface IVirtualSourceFile {}
property analyze
analyze?: boolean;
property fileName
fileName: string;
property includeLib
includeLib?: boolean;
property text
text?: string;
interface JsDoc
interface JsDoc {}
interface JsDocTag
interface JsDocTag {}
interface JsDocTagParsed
interface JsDocTagParsed {}
interface LitElementPropertyConfig
interface LitElementPropertyConfig {}
property attribute
attribute?: string | boolean;
property default
default?: unknown;
property hasConverter
hasConverter?: boolean;
property node
node?: { type?: Node; attribute?: Node; decorator?: CallExpression;};
property reflect
reflect?: boolean;
property state
state?: boolean;
property type
type?: SimpleType | string;
interface TransformerConfig
interface TransformerConfig {}
property cwd
cwd?: string;
property inlineTypes
inlineTypes?: boolean;
property markdown
markdown?: { titleLevel?: number; headerLevel?: number;};
property visibility
visibility?: VisibilityKind;
Type Aliases
type ComponentDeclarationKind
type ComponentDeclarationKind = 'mixin' | 'interface' | 'class';
type ComponentFeature
type ComponentFeature = | 'member' | 'method' | 'cssproperty' | 'csspart' | 'event' | 'slot';
type ComponentHeritageClauseKind
type ComponentHeritageClauseKind = 'implements' | 'extends' | 'mixin';
type ComponentMember
type ComponentMember = ComponentMemberProperty | ComponentMemberAttribute;
type ComponentMemberKind
type ComponentMemberKind = 'property' | 'attribute';
type ComponentMemberReflectKind
type ComponentMemberReflectKind = 'to-attribute' | 'to-property' | 'both';
type FeatureDiscoverVisitMap
type FeatureDiscoverVisitMap<Context extends AnalyzerVisitContext> = { [K in ComponentFeature]: ( node: Node, context: Context ) => FeatureVisitReturnTypeMap[K][] | undefined;};
type FeatureRefineVisitMap
type FeatureRefineVisitMap = { [K in ComponentFeature]: ( feature: FeatureVisitReturnTypeMap[K], context: AnalyzerVisitContext ) => FeatureVisitReturnTypeMap[K] | FeatureVisitReturnTypeMap[K][] | undefined;};
type ModifierKind
type ModifierKind = 'readonly' | 'static';
type PriorityKind
type PriorityKind = 'low' | 'medium' | 'high';
type TransformerKind
type TransformerKind = 'md' | 'markdown' | 'json' | 'vscode' | 'debug' | 'json2';
type VirtualSourceFile
type VirtualSourceFile = IVirtualSourceFile | string;
type VisibilityKind
type VisibilityKind = 'public' | 'protected' | 'private';
Package Files (29)
- lib/cjs/analyze/analyze-html-element.d.ts
- lib/cjs/analyze/analyze-source-file.d.ts
- lib/cjs/analyze/analyze-text.d.ts
- lib/cjs/analyze/analyzer-visit-context.d.ts
- lib/cjs/analyze/constants.d.ts
- lib/cjs/analyze/flavors/analyzer-flavor.d.ts
- lib/cjs/analyze/flavors/js-doc/js-doc-flavor.d.ts
- lib/cjs/analyze/types/analyzer-config.d.ts
- lib/cjs/analyze/types/analyzer-options.d.ts
- lib/cjs/analyze/types/analyzer-result.d.ts
- lib/cjs/analyze/types/component-declaration.d.ts
- lib/cjs/analyze/types/component-definition.d.ts
- lib/cjs/analyze/types/features/component-css-part.d.ts
- lib/cjs/analyze/types/features/component-css-property.d.ts
- lib/cjs/analyze/types/features/component-event.d.ts
- lib/cjs/analyze/types/features/component-feature.d.ts
- lib/cjs/analyze/types/features/component-member.d.ts
- lib/cjs/analyze/types/features/component-method.d.ts
- lib/cjs/analyze/types/features/component-slot.d.ts
- lib/cjs/analyze/types/features/lit-element-property-config.d.ts
- lib/cjs/analyze/types/js-doc.d.ts
- lib/cjs/analyze/types/modifier-kind.d.ts
- lib/cjs/analyze/types/visibility-kind.d.ts
- lib/cjs/analyze/util/component-declaration-util.d.ts
- lib/cjs/analyze/util/js-doc-util.d.ts
- lib/cjs/api.d.ts
- lib/cjs/transformers/transform-analyzer-result.d.ts
- lib/cjs/transformers/transformer-config.d.ts
- lib/cjs/transformers/transformer-kind.d.ts
Dependencies (4)
Dev Dependencies (23)
- @rollup/plugin-node-resolve
- @rollup/plugin-replace
- @rollup/plugin-typescript
- @types/node
- @types/yargs
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- ava
- cross-env
- eslint
- eslint-config-prettier
- husky
- lint-staged
- prettier
- rimraf
- rollup
- rollup-plugin-copy
- ts-node
- tslib
- typescript-4.8
- typescript-4.9
- typescript-5.0
- typescript-5.1
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/web-component-analyzer
.
- Markdown[](https://www.jsdocs.io/package/web-component-analyzer)
- HTML<a href="https://www.jsdocs.io/package/web-component-analyzer"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5410 ms. - Missing or incorrect documentation? Open an issue for this package.