1 | import * as ts from 'typescript';
|
2 | import { SymbolDisplayPart } from 'typescript';
|
3 | export interface StringIndexedObject<T> {
|
4 | [key: string]: T;
|
5 | }
|
6 | export interface ComponentDoc {
|
7 | displayName: string;
|
8 | filePath: string;
|
9 | description: string;
|
10 | props: Props;
|
11 | methods: Method[];
|
12 | tags?: {};
|
13 | }
|
14 | export interface Props extends StringIndexedObject<PropItem> {
|
15 | }
|
16 | export interface PropItem {
|
17 | name: string;
|
18 | required: boolean;
|
19 | type: PropItemType;
|
20 | description: string;
|
21 | defaultValue: any;
|
22 | parent?: ParentType;
|
23 | declarations?: ParentType[];
|
24 | tags?: {};
|
25 | }
|
26 | export interface Method {
|
27 | name: string;
|
28 | docblock: string;
|
29 | modifiers: string[];
|
30 | params: MethodParameter[];
|
31 | returns?: {
|
32 | description?: string | null;
|
33 | type?: string;
|
34 | } | null;
|
35 | description: string;
|
36 | }
|
37 | export interface MethodParameter {
|
38 | name: string;
|
39 | description?: string | null;
|
40 | type: MethodParameterType;
|
41 | }
|
42 | export interface MethodParameterType {
|
43 | name: string;
|
44 | }
|
45 | export interface Component {
|
46 | name: string;
|
47 | }
|
48 | export interface PropItemType {
|
49 | name: string;
|
50 | value?: any;
|
51 | raw?: string;
|
52 | }
|
53 | export interface ParentType {
|
54 | name: string;
|
55 | fileName: string;
|
56 | }
|
57 | export declare type PropFilter = (props: PropItem, component: Component) => boolean;
|
58 | export declare type ComponentNameResolver = (exp: ts.Symbol, source: ts.SourceFile) => string | undefined | null | false;
|
59 | export interface ParserOptions {
|
60 | propFilter?: StaticPropFilter | PropFilter;
|
61 | componentNameResolver?: ComponentNameResolver;
|
62 | shouldExtractLiteralValuesFromEnum?: boolean;
|
63 | shouldRemoveUndefinedFromOptional?: boolean;
|
64 | shouldExtractValuesFromUnion?: boolean;
|
65 | skipChildrenPropWithoutDoc?: boolean;
|
66 | savePropValueAsString?: boolean;
|
67 | shouldIncludePropTagMap?: boolean;
|
68 | customComponentTypes?: string[];
|
69 | }
|
70 | export interface StaticPropFilter {
|
71 | skipPropsWithName?: string[] | string;
|
72 | skipPropsWithoutDoc?: boolean;
|
73 | }
|
74 | export declare const defaultParserOpts: ParserOptions;
|
75 | export interface FileParser {
|
76 | parse(filePathOrPaths: string | string[]): ComponentDoc[];
|
77 | parseWithProgramProvider(filePathOrPaths: string | string[], programProvider?: () => ts.Program): ComponentDoc[];
|
78 | }
|
79 | export declare const defaultOptions: ts.CompilerOptions;
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | export declare function parse(filePathOrPaths: string | string[], parserOpts?: ParserOptions): ComponentDoc[];
|
86 |
|
87 |
|
88 |
|
89 | export declare function withDefaultConfig(parserOpts?: ParserOptions): FileParser;
|
90 |
|
91 |
|
92 |
|
93 | export declare function withCustomConfig(tsconfigPath: string, parserOpts: ParserOptions): FileParser;
|
94 |
|
95 |
|
96 |
|
97 | export declare function withCompilerOptions(compilerOptions: ts.CompilerOptions, parserOpts?: ParserOptions): FileParser;
|
98 | interface JSDoc {
|
99 | description: string;
|
100 | fullComment: string;
|
101 | tags: StringIndexedObject<string>;
|
102 | }
|
103 | export declare class Parser {
|
104 | private readonly checker;
|
105 | private readonly propFilter;
|
106 | private readonly shouldRemoveUndefinedFromOptional;
|
107 | private readonly shouldExtractLiteralValuesFromEnum;
|
108 | private readonly shouldExtractValuesFromUnion;
|
109 | private readonly savePropValueAsString;
|
110 | private readonly shouldIncludePropTagMap;
|
111 | constructor(program: ts.Program, opts: ParserOptions);
|
112 | private getComponentFromExpression;
|
113 | getComponentInfo(exp: ts.Symbol, source: ts.SourceFile, componentNameResolver?: ComponentNameResolver, customComponentTypes?: ParserOptions['customComponentTypes']): ComponentDoc | null;
|
114 | extractPropsFromTypeIfStatelessComponent(type: ts.Type): ts.Symbol | null;
|
115 | extractPropsFromTypeIfStatefulComponent(type: ts.Type): ts.Symbol | null;
|
116 | extractMembersFromType(type: ts.Type): ts.Symbol[];
|
117 | getMethodsInfo(type: ts.Type): Method[];
|
118 | getModifiers(member: ts.Symbol): string[];
|
119 | getParameterInfo(callSignature: ts.Signature): MethodParameter[];
|
120 | getCallSignature(symbol: ts.Symbol): ts.Signature;
|
121 | isTaggedPublic(symbol: ts.Symbol): boolean;
|
122 | getReturnDescription(symbol: ts.Symbol): SymbolDisplayPart[] | undefined;
|
123 | private getValuesFromUnionType;
|
124 | private getInfoFromUnionType;
|
125 | getDocgenType(propType: ts.Type, isRequired: boolean): PropItemType;
|
126 | getPropsInfo(propsObj: ts.Symbol, defaultProps?: StringIndexedObject<string>): Props;
|
127 | findDocComment(symbol: ts.Symbol): JSDoc;
|
128 | /**
|
129 | * Extracts a full JsDoc comment from a symbol, even
|
130 | * though TypeScript has broken down the JsDoc comment into plain
|
131 | * text and JsDoc tags.
|
132 | */
|
133 | getFullJsDocComment(symbol: ts.Symbol): JSDoc;
|
134 | getFunctionStatement(statement: ts.Statement): ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | undefined;
|
135 | extractDefaultPropsFromComponent(symbol: ts.Symbol, source: ts.SourceFile): {};
|
136 | getLiteralValueFromImportSpecifier(property: ts.ImportSpecifier): string | boolean | number | null | undefined;
|
137 | getLiteralValueFromPropertyAssignment(property: ts.PropertyAssignment | ts.BindingElement): string | boolean | number | null | undefined;
|
138 | getPropMap(properties: ts.NodeArray<ts.PropertyAssignment | ts.BindingElement>): StringIndexedObject<string | boolean | number | null>;
|
139 | }
|
140 | export declare function getDefaultExportForFile(source: ts.SourceFile): string;
|
141 | export {};
|