1 |
|
2 |
|
3 | declare module 'react-docgen' {
|
4 | import { Tag, Type } from 'doctrine';
|
5 | import { ASTNode } from 'ast-types';
|
6 | import { NodePath } from 'ast-types/lib/node-path';
|
7 | type Handler = (documentation: Documentation, path: NodePath) => void;
|
8 | interface Documentation {
|
9 | addComposes(moduleName: string): void;
|
10 | set(key: string, value: any): void;
|
11 | get(key: string): any;
|
12 | getPropDescriptor(propName: string): PropDescriptor;
|
13 | getContextDescriptor(propName: string): PropDescriptor;
|
14 | getChildContextDescriptor(propName: string): PropDescriptor;
|
15 | toObject(): DocumentationObject;
|
16 | }
|
17 | interface TagObject extends Omit<Tag, 'description'> {
|
18 | description?: string;
|
19 | }
|
20 | interface TagParamObject extends TagObject {
|
21 | name: string;
|
22 | type?: Type | null;
|
23 | default?: string;
|
24 | }
|
25 | interface TagProps {
|
26 | deprecated?: TagObject[];
|
27 | see?: TagObject[];
|
28 | link?: TagObject[];
|
29 | author?: TagObject[];
|
30 | version?: TagObject[];
|
31 | since?: TagObject[];
|
32 | returns?: TagParamObject[];
|
33 | return?: TagParamObject[];
|
34 | arg?: TagParamObject[];
|
35 | argument?: TagParamObject[];
|
36 | param?: TagParamObject[];
|
37 | [title: string]: TagObject[] | undefined;
|
38 | }
|
39 | interface PropTypeDescriptor {
|
40 | name: 'arrayOf' | 'custom' | 'enum' | 'array' | 'bool' | 'func' | 'number' | 'object' | 'string' | 'any' | 'element' | 'node' | 'symbol' | 'objectOf' | 'shape' | 'exact' | 'instanceOf' | 'elementType';
|
41 | value?: any;
|
42 | raw?: string;
|
43 | computed?: boolean;
|
44 | description?: string;
|
45 | required?: boolean;
|
46 | }
|
47 | interface PropDescriptor {
|
48 | name: string;
|
49 | type?: PropTypeDescriptor;
|
50 | required?: boolean;
|
51 | defaultValue?: any;
|
52 | description?: string;
|
53 | tags?: TagProps;
|
54 | }
|
55 | interface MethodDescriptor {
|
56 | name: string;
|
57 | description?: string;
|
58 | docblock?: string;
|
59 | returns?: {
|
60 | name: string;
|
61 | [key: string]: any;
|
62 | } | null;
|
63 | params?: any[];
|
64 | modifiers?: string[];
|
65 | tags?: TagProps;
|
66 | }
|
67 | interface DocumentationObject {
|
68 | displayName?: string;
|
69 | description?: string;
|
70 | tags?: TagProps;
|
71 | props?: {
|
72 | [propName: string]: PropDescriptor;
|
73 | };
|
74 | methods?: MethodDescriptor[];
|
75 | context?: {
|
76 | [constextName: string]: PropDescriptor;
|
77 | };
|
78 | childContext?: {
|
79 | [chilCOntextName: string]: PropDescriptor;
|
80 | };
|
81 | composes?: string[];
|
82 | }
|
83 | interface Options {
|
84 | filename?: string;
|
85 | cwd?: string;
|
86 | babelrc?: string;
|
87 | babelrcRoots?: boolean | string | string[];
|
88 | root?: string;
|
89 | rootMode?: 'root' | 'upward' | 'upward-optional';
|
90 | configFile?: string;
|
91 | envName?: string;
|
92 | }
|
93 | const defaultHandlers: Handler[];
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 | function parse(source: string | Buffer, resolver?: (ast: ASTNode, parser: {
|
100 | parse: (code: string) => ASTNode;
|
101 | }) => NodePath<any, any> | NodePath[], handlers?: Handler[], options?: Options): DocumentationObject | DocumentationObject[];
|
102 | const utils: {
|
103 | docblock: {
|
104 | getDoclets: (str?: string) => Record<string, any>;
|
105 | };
|
106 | };
|
107 | const resolver: {
|
108 | findAllComponentDefinitions(ast: ASTNode): NodePath[];
|
109 | findAllExportedComponentDefinitions(ast: ASTNode, recast: {
|
110 | visit: (path: NodePath, handlers: {
|
111 | [handlerName: string]: () => boolean | undefined;
|
112 | }) => void;
|
113 | }): NodePath[];
|
114 | findExportedComponentDefinition(ast: ASTNode): NodePath | undefined;
|
115 | };
|
116 | }
|
117 | declare module 'react-docgen-displayname-handler' {
|
118 | import { NodePath as DisplaNameHandlerNodePath } from 'ast-types/lib/node-path';
|
119 | import { Documentation } from 'react-docgen';
|
120 | type Handler = (documentation: Documentation, path: DisplaNameHandlerNodePath) => void;
|
121 | function createDisplayNameHandler(componentPath: string): Handler;
|
122 | }
|
123 | declare module 'react-docgen-annotation-resolver' {
|
124 | import { ASTNode as AnnoASTNode } from 'ast-types';
|
125 | import { NodePath as AnnoNodePath } from 'ast-types/lib/node-path';
|
126 | function annotationResolver(ast: AnnoASTNode, recast: {
|
127 | visit: (node: AnnoNodePath, handlers: {
|
128 | [handlerName: string]: () => boolean | undefined;
|
129 | }) => void;
|
130 | }): AnnoNodePath[];
|
131 | export = annotationResolver;
|
132 | }
|