@workday/canvas-kit-docs 9.1.20 → 9.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es6/docgen/docParser.d.ts +3 -2
- package/dist/es6/docgen/docParser.d.ts.map +1 -1
- package/dist/es6/docgen/docParser.js +73 -62
- package/dist/es6/docgen/plugins/componentParser.d.ts.map +1 -1
- package/dist/es6/docgen/plugins/componentParser.js +4 -2
- package/dist/es6/docgen/plugins/enhancedComponentParser.js +5 -5
- package/dist/es6/docgen/plugins/modelParser.js +3 -3
- package/dist/es6/lib/docs.js +519 -2716
- package/dist/es6/lib/widgetUtils.js +1 -1
- package/dist/mdx/MAINTAINING.mdx +83 -4
- package/lib/widgetUtils.tsx +1 -1
- package/package.json +5 -5
|
@@ -7,6 +7,7 @@ export declare class DocParser<T extends {
|
|
|
7
7
|
plugins: ParserPlugin<T>[];
|
|
8
8
|
/** A shared reference to the Typescript type checker */
|
|
9
9
|
checker: ts.TypeChecker;
|
|
10
|
+
visitedTypeScriptSymbols: Record<string, ts.SyntaxKind>;
|
|
10
11
|
/**
|
|
11
12
|
* This is the shared mutable instance of all exported symbols already processed. You can push new
|
|
12
13
|
* symbols or search for existing symbols. If your plugin doesn't need to access existing symbols,
|
|
@@ -31,7 +32,7 @@ export declare function getNodeName(node: ts.Expression | ts.Declaration): strin
|
|
|
31
32
|
export declare function filterObjectProperties(value: any): value is ObjectProperty;
|
|
32
33
|
export declare function filterObjectTypeParameters(value: any): value is TypeParameter;
|
|
33
34
|
export declare function filterFunctionParameters(value: any): value is FunctionParameter;
|
|
34
|
-
export declare function getSymbolFromNode(
|
|
35
|
+
export declare function getSymbolFromNode(parser: DocParser, node: ts.Node): ts.Symbol | undefined;
|
|
35
36
|
export declare function isObject(type: ts.Type): type is ts.ObjectType;
|
|
36
37
|
/**
|
|
37
38
|
* Given a node, extract a default value and only return a `Value` if we consider it to be
|
|
@@ -64,7 +65,7 @@ export declare function getDefaultsFromObjectBindingParameter(parser: DocParser,
|
|
|
64
65
|
*/
|
|
65
66
|
export declare function getValueFromType(parser: DocParser, type: ts.Type, node?: ts.Node): Value | undefined;
|
|
66
67
|
export declare function unknownValue(nodeText: string): UnknownValue;
|
|
67
|
-
export declare function isExportedSymbol(
|
|
68
|
+
export declare function isExportedSymbol(parser: DocParser, node: ts.Node): boolean;
|
|
68
69
|
export declare function getValueDeclaration(symbol?: ts.Symbol): ts.Declaration | undefined;
|
|
69
70
|
export declare function getValueFromSignatureNode(parser: DocParser, declaration: ts.SignatureDeclaration): Value;
|
|
70
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docParser.d.ts","sourceRoot":"","sources":["../../../docgen/docParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,KAAK,EACL,cAAc,EACd,KAAK,EACL,aAAa,EACb,YAAY,EACZ,cAAc,EAGd,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAIpB,qBAAa,SAAS,CAAC,CAAC,SAAS;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,GAAG;
|
|
1
|
+
{"version":3,"file":"docParser.d.ts","sourceRoot":"","sources":["../../../docgen/docParser.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,6 +5,8 @@ export class DocParser {
|
|
|
5
5
|
constructor(program, plugins = []) {
|
|
6
6
|
this.program = program;
|
|
7
7
|
this.plugins = plugins;
|
|
8
|
+
// track symbols to ensure we don't get stuck in an infinite loop
|
|
9
|
+
this.visitedTypeScriptSymbols = {};
|
|
8
10
|
/**
|
|
9
11
|
* This is the shared mutable instance of all exported symbols already processed. You can push new
|
|
10
12
|
* symbols or search for existing symbols. If your plugin doesn't need to access existing symbols,
|
|
@@ -34,7 +36,9 @@ export class DocParser {
|
|
|
34
36
|
.map(k => ts.SyntaxKind[k])
|
|
35
37
|
.includes(kind) && isNodeExported(this.checker, node));
|
|
36
38
|
}).forEach(node => {
|
|
37
|
-
|
|
39
|
+
// reset visited symbols for every exported symbol to prevent accidental short-circuiting of non-exported symbols of the same name across files or scopes.
|
|
40
|
+
this.visitedTypeScriptSymbols = {};
|
|
41
|
+
const symbol = getSymbolFromNode(this, node);
|
|
38
42
|
const previousSymbolsLength = this.symbols.length;
|
|
39
43
|
if (symbol) {
|
|
40
44
|
const exportedSymbol = {
|
|
@@ -93,7 +97,7 @@ function _getValueFromNode(parser, node) {
|
|
|
93
97
|
// Uncomment for debugging
|
|
94
98
|
// console.log(
|
|
95
99
|
// t.getKindNameFromNode(node) || node.kind,
|
|
96
|
-
// safeGetText(
|
|
100
|
+
// safeGetText(parser, node),
|
|
97
101
|
// checker.typeToString(checker.getTypeAtLocation(node))
|
|
98
102
|
// );
|
|
99
103
|
/**
|
|
@@ -180,10 +184,10 @@ function _getValueFromNode(parser, node) {
|
|
|
180
184
|
// ```
|
|
181
185
|
// If `ValueOf` was exported, the type would be documented as `ValueOf<{a: 'first', b:
|
|
182
186
|
// 'second'}>`, but if it isn't exported, the value is `'first' | 'second'`
|
|
183
|
-
const isLocalTypeReference = t.isTypeReference(node.type) && !isExportedSymbol(
|
|
187
|
+
const isLocalTypeReference = t.isTypeReference(node.type) && !isExportedSymbol(parser, node.type.typeName);
|
|
184
188
|
const value = isLocalTypeReference
|
|
185
189
|
? getValueFromType(parser, checker.getTypeAtLocation(node), node) ||
|
|
186
|
-
unknownValue(safeGetText(
|
|
190
|
+
unknownValue(safeGetText(parser, node))
|
|
187
191
|
: getValueFromNode(parser, node.type);
|
|
188
192
|
return {
|
|
189
193
|
kind: 'type',
|
|
@@ -286,7 +290,7 @@ function _getValueFromNode(parser, node) {
|
|
|
286
290
|
*/
|
|
287
291
|
if (t.isMethodDeclaration(node)) {
|
|
288
292
|
const signature = getValueFromSignatureNode(parser, node);
|
|
289
|
-
const symbol = getSymbolFromNode(
|
|
293
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
290
294
|
const type = checker.getTypeAtLocation(node);
|
|
291
295
|
const jsDoc = findDocComment(checker, symbol);
|
|
292
296
|
if (jsDoc.tags.default) {
|
|
@@ -318,7 +322,7 @@ function _getValueFromNode(parser, node) {
|
|
|
318
322
|
*/
|
|
319
323
|
if (t.isMethodSignature(node)) {
|
|
320
324
|
const signature = getValueFromSignatureNode(parser, node);
|
|
321
|
-
const symbol = getSymbolFromNode(
|
|
325
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
322
326
|
const jsDoc = findDocComment(checker, symbol);
|
|
323
327
|
return {
|
|
324
328
|
kind: 'property',
|
|
@@ -368,8 +372,8 @@ function _getValueFromNode(parser, node) {
|
|
|
368
372
|
}
|
|
369
373
|
if (node.initializer &&
|
|
370
374
|
t.isIdentifier(node.initializer) &&
|
|
371
|
-
isExportedSymbol(
|
|
372
|
-
const symbol = getSymbolFromNode(
|
|
375
|
+
isExportedSymbol(parser, node.initializer)) {
|
|
376
|
+
const symbol = getSymbolFromNode(parser, node.initializer);
|
|
373
377
|
return {
|
|
374
378
|
kind: 'symbol',
|
|
375
379
|
name: node.initializer.text,
|
|
@@ -385,7 +389,7 @@ function _getValueFromNode(parser, node) {
|
|
|
385
389
|
// Both functions and objects are considered objects to Typescript
|
|
386
390
|
if (isObject(type)) {
|
|
387
391
|
if (type.objectFlags & ts.ObjectFlags.ArrayLiteral) {
|
|
388
|
-
return getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
392
|
+
return getValueFromType(parser, type) || unknownValue(safeGetText(parser, node));
|
|
389
393
|
}
|
|
390
394
|
return getObjectValueFromType(parser, type);
|
|
391
395
|
}
|
|
@@ -402,7 +406,7 @@ function _getValueFromNode(parser, node) {
|
|
|
402
406
|
* }
|
|
403
407
|
*/
|
|
404
408
|
if (t.isPropertySignature(node)) {
|
|
405
|
-
const symbol = getSymbolFromNode(
|
|
409
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
406
410
|
const jsDoc = findDocComment(checker, symbol);
|
|
407
411
|
// Get the name of the property - it could be a symbol or have a `name` that is an identifier or string literal
|
|
408
412
|
const name = (symbol === null || symbol === void 0 ? void 0 : symbol.name) ||
|
|
@@ -417,7 +421,7 @@ function _getValueFromNode(parser, node) {
|
|
|
417
421
|
required: node.questionToken ? false : true,
|
|
418
422
|
type: node.type
|
|
419
423
|
? getValueFromNode(parser, node.type)
|
|
420
|
-
: unknownValue(safeGetText(
|
|
424
|
+
: unknownValue(safeGetText(parser, node)),
|
|
421
425
|
...jsDoc,
|
|
422
426
|
};
|
|
423
427
|
}
|
|
@@ -434,13 +438,13 @@ function _getValueFromNode(parser, node) {
|
|
|
434
438
|
*/
|
|
435
439
|
if (t.isPropertyDeclaration(node)) {
|
|
436
440
|
const name = getNodeName(node);
|
|
437
|
-
const symbol = getSymbolFromNode(
|
|
441
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
438
442
|
const jsDoc = findDocComment(checker, symbol);
|
|
439
443
|
const type = checker.getTypeAtLocation(node);
|
|
440
444
|
return {
|
|
441
445
|
kind: 'property',
|
|
442
446
|
name: name || (symbol === null || symbol === void 0 ? void 0 : symbol.name) || 'unknown',
|
|
443
|
-
type: getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
447
|
+
type: getValueFromType(parser, type) || unknownValue(safeGetText(parser, node)),
|
|
444
448
|
...jsDoc,
|
|
445
449
|
};
|
|
446
450
|
}
|
|
@@ -477,7 +481,7 @@ function _getValueFromNode(parser, node) {
|
|
|
477
481
|
};
|
|
478
482
|
}
|
|
479
483
|
if (t.isSpreadAssignment(node)) {
|
|
480
|
-
const symbol = getSymbolFromNode(
|
|
484
|
+
const symbol = getSymbolFromNode(parser, node.expression);
|
|
481
485
|
const declaration = getValueDeclaration(symbol);
|
|
482
486
|
if (declaration) {
|
|
483
487
|
return getValueFromNode(parser, declaration);
|
|
@@ -504,7 +508,7 @@ function _getValueFromNode(parser, node) {
|
|
|
504
508
|
};
|
|
505
509
|
}
|
|
506
510
|
if (t.isSpreadElement(node)) {
|
|
507
|
-
const symbol = getSymbolFromNode(
|
|
511
|
+
const symbol = getSymbolFromNode(parser, node.expression);
|
|
508
512
|
const declaration = getValueDeclaration(symbol);
|
|
509
513
|
if (declaration) {
|
|
510
514
|
return getValueFromNode(parser, declaration);
|
|
@@ -523,7 +527,7 @@ function _getValueFromNode(parser, node) {
|
|
|
523
527
|
* */
|
|
524
528
|
if (t.isPropertyAssignment(node)) {
|
|
525
529
|
const type = checker.getTypeAtLocation(node);
|
|
526
|
-
const symbol = getSymbolFromNode(
|
|
530
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
527
531
|
const jsDoc = findDocComment(checker, symbol);
|
|
528
532
|
// For default values, we want the value and not the type. An `AsExpression` redirects to types,
|
|
529
533
|
// so we want to bypass it to get the value node
|
|
@@ -534,16 +538,16 @@ function _getValueFromNode(parser, node) {
|
|
|
534
538
|
kind: 'property',
|
|
535
539
|
name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
|
|
536
540
|
defaultValue: getValueFromNode(parser, defaultValueNode),
|
|
537
|
-
type: getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
541
|
+
type: getValueFromType(parser, type) || unknownValue(safeGetText(parser, node)),
|
|
538
542
|
required: symbol ? !isOptional(symbol) && !includesUndefined(type) : false,
|
|
539
543
|
...jsDoc,
|
|
540
544
|
};
|
|
541
545
|
}
|
|
542
546
|
// as A
|
|
543
547
|
if (t.isAsExpression(node)) {
|
|
544
|
-
if (safeGetText(
|
|
548
|
+
if (safeGetText(parser, node) === 'const') {
|
|
545
549
|
const type = checker.getTypeAtLocation(node.parent);
|
|
546
|
-
return getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
550
|
+
return getValueFromType(parser, type) || unknownValue(safeGetText(parser, node));
|
|
547
551
|
}
|
|
548
552
|
return getValueFromNode(parser, node.type);
|
|
549
553
|
}
|
|
@@ -552,9 +556,9 @@ function _getValueFromNode(parser, node) {
|
|
|
552
556
|
// something like `keyof A`. In this case, we'll get the symbol and ask for the properties of
|
|
553
557
|
// the symbol's declaration.
|
|
554
558
|
if (t.isTypeReference(node.type)) {
|
|
555
|
-
const symbol = getSymbolFromNode(
|
|
559
|
+
const symbol = getSymbolFromNode(parser, node.type.typeName);
|
|
556
560
|
const declaration = getValueDeclaration(symbol);
|
|
557
|
-
if (symbol && declaration && isExportedSymbol(
|
|
561
|
+
if (symbol && declaration && isExportedSymbol(parser, declaration)) {
|
|
558
562
|
return {
|
|
559
563
|
kind: 'keyof',
|
|
560
564
|
name: {
|
|
@@ -576,7 +580,7 @@ function _getValueFromNode(parser, node) {
|
|
|
576
580
|
throw Error('Cannot process a synthetic TypeNode with a `keyof`');
|
|
577
581
|
}
|
|
578
582
|
return (getValueFromType(parser, checker.getTypeFromTypeNode(node), node) ||
|
|
579
|
-
unknownValue(safeGetText(
|
|
583
|
+
unknownValue(safeGetText(parser, node)));
|
|
580
584
|
}
|
|
581
585
|
// A literal type contains literals like `string` or `number` or `'foo'`
|
|
582
586
|
if (t.isLiteralType(node)) {
|
|
@@ -663,7 +667,7 @@ function _getValueFromNode(parser, node) {
|
|
|
663
667
|
// type A = B['C']
|
|
664
668
|
if (t.isIndexedAccessType(node)) {
|
|
665
669
|
const type = checker.getTypeAtLocation(node);
|
|
666
|
-
return getValueFromType(parser, type, node) || unknownValue(safeGetText(
|
|
670
|
+
return getValueFromType(parser, type, node) || unknownValue(safeGetText(parser, node));
|
|
667
671
|
}
|
|
668
672
|
/**
|
|
669
673
|
* A ConditionalType is a type-based ternary. For example:
|
|
@@ -702,12 +706,12 @@ function _getValueFromNode(parser, node) {
|
|
|
702
706
|
* latter is only allowed for everything else. For example, accessing a property of an interface.
|
|
703
707
|
*/
|
|
704
708
|
if (t.isQualifiedName(node)) {
|
|
705
|
-
if (isExportedSymbol(
|
|
709
|
+
if (isExportedSymbol(parser, node.left)) {
|
|
706
710
|
const value = checker.typeToString(checker.getTypeAtLocation(node.left));
|
|
707
711
|
return {
|
|
708
712
|
kind: 'qualifiedName',
|
|
709
|
-
left: { kind: 'symbol', name: safeGetText(
|
|
710
|
-
right: { kind: 'string', value: safeGetText(
|
|
713
|
+
left: { kind: 'symbol', name: safeGetText(parser, node.left), value },
|
|
714
|
+
right: { kind: 'string', value: safeGetText(parser, node.right) },
|
|
711
715
|
};
|
|
712
716
|
}
|
|
713
717
|
// if the node.left is not exported, we'll reduce to a type
|
|
@@ -725,11 +729,11 @@ function _getValueFromNode(parser, node) {
|
|
|
725
729
|
* In this example, the TypeQuery is `typeof a`
|
|
726
730
|
*/
|
|
727
731
|
if (t.isTypeQuery(node)) {
|
|
728
|
-
if (isExportedSymbol(
|
|
732
|
+
if (isExportedSymbol(parser, node.exprName)) {
|
|
729
733
|
const value = checker.typeToString(checker.getTypeAtLocation(node.exprName));
|
|
730
734
|
return { kind: 'symbol', name: node.exprName.getText(), value };
|
|
731
735
|
}
|
|
732
|
-
const symbol = getSymbolFromNode(
|
|
736
|
+
const symbol = getSymbolFromNode(parser, node.exprName);
|
|
733
737
|
if (symbol) {
|
|
734
738
|
const declaration = getValueDeclaration(symbol);
|
|
735
739
|
return getValueFromNode(parser, declaration);
|
|
@@ -771,15 +775,15 @@ function _getValueFromNode(parser, node) {
|
|
|
771
775
|
*/
|
|
772
776
|
if (t.isTypeReference(node)) {
|
|
773
777
|
// handle `as const` specially. If we don't do this, we'll get into an infinite loop
|
|
774
|
-
if (safeGetText(
|
|
778
|
+
if (safeGetText(parser, node) === 'const') {
|
|
775
779
|
const type = checker.getTypeAtLocation(node.parent.parent);
|
|
776
780
|
return getValueFromType(parser, type) || unknownValue(node.parent.parent.getText());
|
|
777
781
|
}
|
|
778
782
|
const typeParameters = (_e = node.typeArguments) === null || _e === void 0 ? void 0 : _e.map(p => getValueFromNode(parser, p));
|
|
779
783
|
const symbolNode = t.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName;
|
|
780
|
-
const symbol = getSymbolFromNode(
|
|
784
|
+
const symbol = getSymbolFromNode(parser, symbolNode);
|
|
781
785
|
const fileName = (_f = getValueDeclaration(symbol)) === null || _f === void 0 ? void 0 : _f.getSourceFile().fileName;
|
|
782
|
-
const externalSymbol = getExternalSymbol((symbol === null || symbol === void 0 ? void 0 : symbol.name) || safeGetText(
|
|
786
|
+
const externalSymbol = getExternalSymbol((symbol === null || symbol === void 0 ? void 0 : symbol.name) || safeGetText(parser, node), fileName);
|
|
783
787
|
if (externalSymbol) {
|
|
784
788
|
return {
|
|
785
789
|
kind: 'external',
|
|
@@ -788,9 +792,9 @@ function _getValueFromNode(parser, node) {
|
|
|
788
792
|
typeParameters,
|
|
789
793
|
};
|
|
790
794
|
}
|
|
791
|
-
if (isExportedSymbol(
|
|
795
|
+
if (isExportedSymbol(parser, symbolNode)) {
|
|
792
796
|
const value = checker.typeToString(checker.getTypeAtLocation(node.typeName));
|
|
793
|
-
return { kind: 'symbol', name: safeGetText(
|
|
797
|
+
return { kind: 'symbol', name: safeGetText(parser, node.typeName), typeParameters, value };
|
|
794
798
|
}
|
|
795
799
|
// If it is a qualified name, handle that specially. The `left` might be a symbol
|
|
796
800
|
if (t.isQualifiedName(node.typeName)) {
|
|
@@ -801,6 +805,7 @@ function _getValueFromNode(parser, node) {
|
|
|
801
805
|
const type = checker.getTypeAtLocation(node);
|
|
802
806
|
if (symbol) {
|
|
803
807
|
if (type.getFlags() & ts.TypeFlags.Instantiable) {
|
|
808
|
+
symbol.name; //?
|
|
804
809
|
// It is a generic type
|
|
805
810
|
return { kind: 'generic', name: symbol === null || symbol === void 0 ? void 0 : symbol.name };
|
|
806
811
|
}
|
|
@@ -815,7 +820,7 @@ function _getValueFromNode(parser, node) {
|
|
|
815
820
|
}
|
|
816
821
|
// The type reference is not external, not an exported symbol, and not generic.
|
|
817
822
|
// Fall back to returning the value from it's type property
|
|
818
|
-
return getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
823
|
+
return getValueFromType(parser, type) || unknownValue(safeGetText(parser, node));
|
|
819
824
|
}
|
|
820
825
|
/**
|
|
821
826
|
* A ShorthandPropertyAssignment is a PropertyAssignment that is shorthanded where the `name` and
|
|
@@ -838,13 +843,13 @@ function _getValueFromNode(parser, node) {
|
|
|
838
843
|
*/
|
|
839
844
|
if (t.isShorthandPropertyAssignment(node)) {
|
|
840
845
|
const type = checker.getTypeAtLocation(node);
|
|
841
|
-
const symbol = getSymbolFromNode(
|
|
846
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
842
847
|
const jsDoc = findDocComment(checker, symbol);
|
|
843
848
|
// see if the declaration is assigned to something exported
|
|
844
849
|
return {
|
|
845
850
|
kind: 'property',
|
|
846
851
|
name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
|
|
847
|
-
type: getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
852
|
+
type: getValueFromType(parser, type) || unknownValue(safeGetText(parser, node)),
|
|
848
853
|
...jsDoc,
|
|
849
854
|
};
|
|
850
855
|
}
|
|
@@ -866,7 +871,7 @@ function _getValueFromNode(parser, node) {
|
|
|
866
871
|
properties: node.members.map((m, index) => {
|
|
867
872
|
return {
|
|
868
873
|
kind: 'property',
|
|
869
|
-
name: safeGetText(
|
|
874
|
+
name: safeGetText(parser, m.name),
|
|
870
875
|
type: m.initializer
|
|
871
876
|
? getValueFromNode(parser, m.initializer)
|
|
872
877
|
: { kind: 'number', value: index },
|
|
@@ -888,8 +893,8 @@ function _getValueFromNode(parser, node) {
|
|
|
888
893
|
* In this example, `b` is the identifier because it is a value reference to something else.
|
|
889
894
|
*/
|
|
890
895
|
if (t.isIdentifier(node)) {
|
|
891
|
-
if (isExportedSymbol(
|
|
892
|
-
const symbol = getSymbolFromNode(
|
|
896
|
+
if (isExportedSymbol(parser, node)) {
|
|
897
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
893
898
|
const declaration = getValueDeclaration(symbol);
|
|
894
899
|
return {
|
|
895
900
|
kind: 'symbol',
|
|
@@ -907,7 +912,7 @@ function _getValueFromNode(parser, node) {
|
|
|
907
912
|
*/
|
|
908
913
|
if (t.isParameter(node)) {
|
|
909
914
|
const type = checker.getTypeAtLocation(node);
|
|
910
|
-
const symbol = getSymbolFromNode(
|
|
915
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
911
916
|
const jsDoc = findDocComment(checker, symbol);
|
|
912
917
|
const isRequired = node.questionToken
|
|
913
918
|
? false
|
|
@@ -918,7 +923,7 @@ function _getValueFromNode(parser, node) {
|
|
|
918
923
|
: false;
|
|
919
924
|
const typeInfo = node.type
|
|
920
925
|
? getValueFromNode(parser, node.type)
|
|
921
|
-
: getValueFromType(parser, type) || unknownValue(safeGetText(
|
|
926
|
+
: getValueFromType(parser, type) || unknownValue(safeGetText(parser, node));
|
|
922
927
|
const defaultValue = node.initializer ? getValueFromNode(parser, node.initializer) : undefined;
|
|
923
928
|
/**
|
|
924
929
|
* Set default values if an object binding pattern is found. We do this at the Parameter level,
|
|
@@ -962,11 +967,11 @@ function _getValueFromNode(parser, node) {
|
|
|
962
967
|
return value;
|
|
963
968
|
}
|
|
964
969
|
}
|
|
965
|
-
const symbol = getSymbolFromNode(
|
|
970
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
966
971
|
if (!symbol) {
|
|
967
|
-
return unknownValue(safeGetText(
|
|
972
|
+
return unknownValue(safeGetText(parser, node));
|
|
968
973
|
}
|
|
969
|
-
return unknownValue(safeGetText(
|
|
974
|
+
return unknownValue(safeGetText(parser, node));
|
|
970
975
|
}
|
|
971
976
|
/** True if this is visible outside this file, false otherwise */
|
|
972
977
|
function isNodeExported(checker, node) {
|
|
@@ -1039,8 +1044,8 @@ export function filterFunctionParameters(value) {
|
|
|
1039
1044
|
return value.kind === 'parameter';
|
|
1040
1045
|
}
|
|
1041
1046
|
// https://github.com/dsherret/ts-ast-viewer/blob/c71e238123d972bae889b3829e23b44f39d8d5c2/site/src/components/PropertiesViewer.tsx#L172
|
|
1042
|
-
export function getSymbolFromNode(
|
|
1043
|
-
return node.symbol || checker.getSymbolAtLocation(node);
|
|
1047
|
+
export function getSymbolFromNode(parser, node) {
|
|
1048
|
+
return node.symbol || parser.checker.getSymbolAtLocation(node);
|
|
1044
1049
|
}
|
|
1045
1050
|
export function isObject(type) {
|
|
1046
1051
|
return !!(type.flags & ts.TypeFlags.Object);
|
|
@@ -1120,7 +1125,7 @@ function getIndexSignatureFromType(parser, type) {
|
|
|
1120
1125
|
const parameter = (_a = indexSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[0];
|
|
1121
1126
|
return {
|
|
1122
1127
|
kind: 'indexSignature',
|
|
1123
|
-
name: (parameter === null || parameter === void 0 ? void 0 : parameter.name) ? safeGetText(
|
|
1128
|
+
name: (parameter === null || parameter === void 0 ? void 0 : parameter.name) ? safeGetText(parser, parameter === null || parameter === void 0 ? void 0 : parameter.name) : '',
|
|
1124
1129
|
type: (parameter && getValueFromType(parser, checker.getTypeAtLocation(parameter), parameter)) ||
|
|
1125
1130
|
unknownValue(''),
|
|
1126
1131
|
value: indexSignature.declaration
|
|
@@ -1189,7 +1194,7 @@ export function getValueFromType(parser, type, node) {
|
|
|
1189
1194
|
if (typeNode && originalNodeKind !== typeNode.kind) {
|
|
1190
1195
|
// find the symbol
|
|
1191
1196
|
if (t.isTypeReference(typeNode)) {
|
|
1192
|
-
const symbol = getSymbolFromNode(
|
|
1197
|
+
const symbol = getSymbolFromNode(parser, typeNode.typeName);
|
|
1193
1198
|
const declaration = getValueDeclaration(symbol);
|
|
1194
1199
|
const fileName = declaration === null || declaration === void 0 ? void 0 : declaration.getSourceFile().fileName;
|
|
1195
1200
|
if (symbol) {
|
|
@@ -1198,7 +1203,7 @@ export function getValueFromType(parser, type, node) {
|
|
|
1198
1203
|
return { kind: 'external', name: symbol.name, url: externalSymbol };
|
|
1199
1204
|
}
|
|
1200
1205
|
if (declaration && declaration !== node) {
|
|
1201
|
-
if (isExportedSymbol(
|
|
1206
|
+
if (isExportedSymbol(parser, declaration)) {
|
|
1202
1207
|
return { kind: 'symbol', name: symbol.name, value: typeToString };
|
|
1203
1208
|
}
|
|
1204
1209
|
return getValueFromNode(parser, declaration);
|
|
@@ -1310,16 +1315,23 @@ export function getValueFromType(parser, type, node) {
|
|
|
1310
1315
|
export function unknownValue(nodeText) {
|
|
1311
1316
|
return { kind: 'unknown', value: 'unknown', text: nodeText };
|
|
1312
1317
|
}
|
|
1313
|
-
export function isExportedSymbol(
|
|
1318
|
+
export function isExportedSymbol(parser, node) {
|
|
1314
1319
|
var _a;
|
|
1315
1320
|
const sourceFile = (_a = node.getSourceFile) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
1316
1321
|
if (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.isDeclarationFile) {
|
|
1317
1322
|
return true;
|
|
1318
1323
|
}
|
|
1319
|
-
const symbol = getSymbolFromNode(
|
|
1324
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
1320
1325
|
const declarationNode = getValueDeclaration(symbol);
|
|
1321
|
-
|
|
1322
|
-
|
|
1326
|
+
// Prevent circular types that aren't exported
|
|
1327
|
+
if (symbol && declarationNode) {
|
|
1328
|
+
if (parser.visitedTypeScriptSymbols[symbol.name]) {
|
|
1329
|
+
return true;
|
|
1330
|
+
}
|
|
1331
|
+
// We don't consider type parameter declarations to be visited. These are generics like `T`
|
|
1332
|
+
if (!t.isTypeParameter(declarationNode)) {
|
|
1333
|
+
parser.visitedTypeScriptSymbols[symbol.name] = declarationNode.kind;
|
|
1334
|
+
}
|
|
1323
1335
|
// Check if the declaration's sourcefile is a declaration file
|
|
1324
1336
|
if (declarationNode.getSourceFile().isDeclarationFile) {
|
|
1325
1337
|
return true;
|
|
@@ -1330,7 +1342,7 @@ export function isExportedSymbol(checker, node) {
|
|
|
1330
1342
|
t.isImportSpecifier(declarationNode)) {
|
|
1331
1343
|
return true;
|
|
1332
1344
|
}
|
|
1333
|
-
return isNodeExported(checker, declarationNode);
|
|
1345
|
+
return isNodeExported(parser.checker, declarationNode);
|
|
1334
1346
|
}
|
|
1335
1347
|
return false;
|
|
1336
1348
|
}
|
|
@@ -1341,7 +1353,7 @@ export function getValueDeclaration(symbol) {
|
|
|
1341
1353
|
function isOptional(symbol) {
|
|
1342
1354
|
return (symbol.getFlags() & ts.SymbolFlags.Optional) !== 0;
|
|
1343
1355
|
}
|
|
1344
|
-
function safeGetText(
|
|
1356
|
+
function safeGetText(parser, node) {
|
|
1345
1357
|
var _a;
|
|
1346
1358
|
if ((_a = node.getSourceFile) === null || _a === void 0 ? void 0 : _a.call(node)) {
|
|
1347
1359
|
return node.getText();
|
|
@@ -1352,7 +1364,7 @@ function safeGetText(checker, node) {
|
|
|
1352
1364
|
return node.text;
|
|
1353
1365
|
}
|
|
1354
1366
|
// Try a symbol
|
|
1355
|
-
const symbol = getSymbolFromNode(
|
|
1367
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
1356
1368
|
return (symbol === null || symbol === void 0 ? void 0 : symbol.name) || `SyntheticNode - ${t.getKindNameFromNode(node)}`;
|
|
1357
1369
|
}
|
|
1358
1370
|
/**
|
|
@@ -1367,8 +1379,7 @@ function safeGetText(checker, node) {
|
|
|
1367
1379
|
*/
|
|
1368
1380
|
function getExportMembers(parser, node) {
|
|
1369
1381
|
var _a;
|
|
1370
|
-
const
|
|
1371
|
-
const exports = ((_a = getSymbolFromNode(checker, node)) === null || _a === void 0 ? void 0 : _a.exports) || new Map();
|
|
1382
|
+
const exports = ((_a = getSymbolFromNode(parser, node)) === null || _a === void 0 ? void 0 : _a.exports) || new Map();
|
|
1372
1383
|
const members = Array.from(exports.values())
|
|
1373
1384
|
.map(symbol => {
|
|
1374
1385
|
const declaration = getValueDeclaration(symbol);
|
|
@@ -1401,7 +1412,7 @@ function getValueFromSignature(parser, declaration, signature) {
|
|
|
1401
1412
|
function generateSignatureFromTypeNode(parser, node) {
|
|
1402
1413
|
var _a;
|
|
1403
1414
|
if (t.isFunctionType(node) || t.isMethodSignature(node)) {
|
|
1404
|
-
const parameters = node.parameters.map(p => (getSymbolFromNode(parser
|
|
1415
|
+
const parameters = node.parameters.map(p => (getSymbolFromNode(parser, p) || getSymbolFromNode(parser, p.name)));
|
|
1405
1416
|
const typeParameters = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.map(t => parser.checker.getTypeAtLocation(t));
|
|
1406
1417
|
return {
|
|
1407
1418
|
parameters,
|
|
@@ -1420,11 +1431,11 @@ function generateSignatureFromTypeNode(parser, node) {
|
|
|
1420
1431
|
return parser.checker.getTypeAtLocation(node.type || node);
|
|
1421
1432
|
},
|
|
1422
1433
|
getDocumentationComment() {
|
|
1423
|
-
const symbol = getSymbolFromNode(parser
|
|
1434
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
1424
1435
|
return symbol.getDocumentationComment(parser.checker);
|
|
1425
1436
|
},
|
|
1426
1437
|
getJsDocTags() {
|
|
1427
|
-
const symbol = getSymbolFromNode(parser
|
|
1438
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
1428
1439
|
return symbol.getJsDocTags();
|
|
1429
1440
|
},
|
|
1430
1441
|
};
|
|
@@ -1438,7 +1449,7 @@ export function getValueFromSignatureNode(parser, declaration) {
|
|
|
1438
1449
|
if (signature) {
|
|
1439
1450
|
return getValueFromSignature(parser, declaration, signature);
|
|
1440
1451
|
}
|
|
1441
|
-
return unknownValue(safeGetText(
|
|
1452
|
+
return unknownValue(safeGetText(parser, declaration));
|
|
1442
1453
|
}
|
|
1443
1454
|
function getObjectValueFromType(parser, type) {
|
|
1444
1455
|
const properties = type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentParser.d.ts","sourceRoot":"","sources":["../../../../docgen/plugins/componentParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,EAEL,SAAS,EAOV,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAC,cAAc,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"componentParser.d.ts","sourceRoot":"","sources":["../../../../docgen/plugins/componentParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,EAEL,SAAS,EAOV,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAC,cAAc,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,eAAe,qDA+I1B,CAAC;AAEH;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,WAS9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,EACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GACvC,cAAc,EAAE,CAgBlB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,EACjB,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,GACb,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUvB;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAevB"}
|
|
@@ -34,7 +34,9 @@ export const componentParser = createParserPlugin((node, parser) => {
|
|
|
34
34
|
clause.typeArguments[0] &&
|
|
35
35
|
t.isTypeReference(clause.typeArguments[0])) {
|
|
36
36
|
const type = parser.checker.getTypeAtLocation(clause.typeArguments[0]);
|
|
37
|
-
const defaultPropNode = (_a = node.members.find(m => t.isPropertyDeclaration(m) &&
|
|
37
|
+
const defaultPropNode = (_a = node.members.find(m => t.isPropertyDeclaration(m) &&
|
|
38
|
+
t.isIdentifier(m.name) &&
|
|
39
|
+
m.name.text === 'defaultProps')) === null || _a === void 0 ? void 0 : _a.initializer;
|
|
38
40
|
const defaultProps = getDefaultsFromDefaultProps(parser, defaultPropNode);
|
|
39
41
|
const props = getComponentProps(parser, type, defaultProps);
|
|
40
42
|
/**
|
|
@@ -60,7 +62,7 @@ export const componentParser = createParserPlugin((node, parser) => {
|
|
|
60
62
|
* export function A(props: Props) { return <div /> }
|
|
61
63
|
* ```
|
|
62
64
|
*/
|
|
63
|
-
if (ts.isFunctionLike(node) && isExportedSymbol(parser
|
|
65
|
+
if (ts.isFunctionLike(node) && isExportedSymbol(parser, node)) {
|
|
64
66
|
return getComponentFromFunction(parser, node);
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
@@ -98,7 +98,7 @@ export const enhancedComponentParser = createParserPlugin((node, parser) => {
|
|
|
98
98
|
* Filter out props from `@types/react`
|
|
99
99
|
*/
|
|
100
100
|
if (t.isPropertySignature(node)) {
|
|
101
|
-
const symbol = getSymbolFromNode(parser
|
|
101
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
102
102
|
const declaration = getValueDeclaration(symbol);
|
|
103
103
|
if (declaration && declaration.getSourceFile().fileName.includes('@types/react')) {
|
|
104
104
|
return { kind: 'unknown', value: 'unknown', text: 'empty' };
|
|
@@ -498,7 +498,7 @@ function getElemPropsHook(parser, node) {
|
|
|
498
498
|
t.isIdentifier(subComponentProperty.initializer)) {
|
|
499
499
|
// Check if the elemProps is aliased to another hook
|
|
500
500
|
// for example, `const useMyComponent = useMyOtherComponent`
|
|
501
|
-
const symbol = getSymbolFromNode(parser
|
|
501
|
+
const symbol = getSymbolFromNode(parser, subComponentProperty.initializer);
|
|
502
502
|
const declaration = getValueDeclaration(symbol);
|
|
503
503
|
if (declaration &&
|
|
504
504
|
t.isVariableDeclaration(declaration) &&
|
|
@@ -522,9 +522,9 @@ function getSubcomponents(parser, node) {
|
|
|
522
522
|
if (t.isPropertyAssignment(p) &&
|
|
523
523
|
t.isIdentifier(p.name) &&
|
|
524
524
|
t.isIdentifier(p.initializer)) {
|
|
525
|
-
const symbol = getSymbolFromNode(parser
|
|
525
|
+
const symbol = getSymbolFromNode(parser, p.name);
|
|
526
526
|
const jsDoc = findDocComment(parser.checker, symbol);
|
|
527
|
-
const initializerSymbol = getSymbolFromNode(parser
|
|
527
|
+
const initializerSymbol = getSymbolFromNode(parser, p.initializer);
|
|
528
528
|
// Make sure the symbol exists AND the symbol has an alias
|
|
529
529
|
if (initializerSymbol && initializerSymbol.flags & ts.SymbolFlags.Alias) {
|
|
530
530
|
const initializerJsDoc = findDocComment(parser.checker, parser.checker.getAliasedSymbol(initializerSymbol));
|
|
@@ -537,7 +537,7 @@ function getSubcomponents(parser, node) {
|
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
539
|
if (t.isShorthandPropertyAssignment(p) && t.isIdentifier(p.name)) {
|
|
540
|
-
const symbol = getSymbolFromNode(parser
|
|
540
|
+
const symbol = getSymbolFromNode(parser, p.name);
|
|
541
541
|
const jsDoc = findDocComment(parser.checker, symbol);
|
|
542
542
|
return {
|
|
543
543
|
name: p.name.text,
|
|
@@ -42,7 +42,7 @@ export const modelParser = createParserPlugin((node, parser) => {
|
|
|
42
42
|
*/
|
|
43
43
|
if (t.isShorthandPropertyAssignment(node)) {
|
|
44
44
|
const { checker } = parser;
|
|
45
|
-
const symbol = getSymbolFromNode(
|
|
45
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
46
46
|
const declaration = getValueDeclaration(symbol);
|
|
47
47
|
const name = (symbol === null || symbol === void 0 ? void 0 : symbol.name) || t.isIdentifier(node.name) ? node.name.text : '';
|
|
48
48
|
if (declaration && declaration.getSourceFile()) {
|
|
@@ -120,7 +120,7 @@ export const modelParser = createParserPlugin((node, parser) => {
|
|
|
120
120
|
t.isIdentifier(node.initializer.type.exprName.right) &&
|
|
121
121
|
// TConfig is special from models
|
|
122
122
|
node.initializer.type.exprName.right.text === 'TConfig') {
|
|
123
|
-
const symbol = getSymbolFromNode(parser
|
|
123
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
124
124
|
const jsDoc = (symbol && getFullJsDocComment(parser.checker, symbol)) || defaultJSDoc;
|
|
125
125
|
return {
|
|
126
126
|
kind: 'property',
|
|
@@ -178,7 +178,7 @@ export const modelParser = createParserPlugin((node, parser) => {
|
|
|
178
178
|
// we have a model
|
|
179
179
|
const modelName = node.name.text.replace('use', '');
|
|
180
180
|
// get the symbol for the model hook
|
|
181
|
-
const symbol = getSymbolFromNode(parser
|
|
181
|
+
const symbol = getSymbolFromNode(parser, node);
|
|
182
182
|
const jsDoc = symbol ? getFullJsDocComment(parser.checker, symbol) : defaultJSDoc;
|
|
183
183
|
const options = node.initializer.expression.arguments[0];
|
|
184
184
|
const optionsType = parser.checker.getTypeAtLocation(options);
|