|
1 | 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 | import ts from 'typescript'; |
4 | | -import { ValueDescription } from './interfaces'; |
5 | 4 |
|
6 | 5 | export function isOptional(type: ts.Type) { |
7 | 6 | if (!type.isUnionOrIntersection()) { |
@@ -62,48 +61,6 @@ export function getDescription(docComment: Array<ts.SymbolDisplayPart>, declarat |
62 | 61 | }; |
63 | 62 | } |
64 | 63 |
|
65 | | -export function extractValueDescriptions(type: ts.UnionOrIntersectionType, typeNode: ts.TypeNode | undefined) { |
66 | | - if (type.aliasSymbol) { |
67 | | - // Traverse from "variant: ButtonProps.Variant" to "type Variant = ..." |
68 | | - const aliasDeclaration = extractDeclaration(type.aliasSymbol); |
69 | | - if (ts.isTypeAliasDeclaration(aliasDeclaration)) { |
70 | | - typeNode = aliasDeclaration.type; |
71 | | - } |
72 | | - } |
73 | | - |
74 | | - if (!typeNode) { |
75 | | - return []; |
76 | | - } |
77 | | - |
78 | | - const maybeList = typeNode.getChildren()[0]; |
79 | | - // based on similar code in typedoc |
80 | | - // https://github.com/TypeStrong/typedoc/blob/6090b3e31471cea3728db1b03888bca5703b437e/src/lib/converter/symbols.ts#L406-L438 |
81 | | - if (maybeList.kind !== ts.SyntaxKind.SyntaxList) { |
82 | | - return []; |
83 | | - } |
84 | | - const rawComments: Array<string | undefined> = []; |
85 | | - let memberIndex = 0; |
86 | | - for (const child of maybeList.getChildren()) { |
87 | | - const text = child.getFullText(); |
88 | | - if (text.includes('/**')) { |
89 | | - rawComments[memberIndex] = (rawComments[memberIndex] ?? '') + child.getFullText(); |
90 | | - } |
91 | | - |
92 | | - if (child.kind !== ts.SyntaxKind.BarToken) { |
93 | | - memberIndex++; |
94 | | - } |
95 | | - } |
96 | | - // Array.from to fix sparse array |
97 | | - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#array_methods_and_empty_slots |
98 | | - return Array.from(rawComments).map((comment): ValueDescription | undefined => { |
99 | | - if (!comment) { |
100 | | - return undefined; |
101 | | - } |
102 | | - const systemTags = Array.from(comment.matchAll(/@awsuiSystem\s+(\w+)/g), ([_, system]) => system); |
103 | | - return systemTags.length > 0 ? { systemTags } : undefined; |
104 | | - }); |
105 | | -} |
106 | | - |
107 | 64 | export function extractDeclaration(symbol: ts.Symbol) { |
108 | 65 | const declarations = symbol.getDeclarations(); |
109 | 66 | if (!declarations || declarations.length === 0) { |
|
0 commit comments