* Parse method signatures from a class
(source: string, className: string)
| 85 | const classNode = file.statements.find( |
| 86 | (statement): statement is ts.ClassDeclaration => |
| 87 | ts.isClassDeclaration(statement) && statement.name?.text === className |
| 88 | ); |
| 89 | if (!classNode) { |
| 90 | throw new Error(`Class ${className} was not found in ${path}`); |
| 91 | } |
| 92 | |
| 93 | return classNode.members |
| 94 | .filter((member): member is ts.MethodDeclaration => |
| 95 | ts.isMethodDeclaration(member) && isPublic(member) |
| 96 | ) |
| 97 | .map(method => ({ |
| 98 | name: methodName(method, file), |
| 99 | signature: methodSignature(method, file), |
| 100 | description: descriptionFor(method), |
| 101 | })); |
| 102 | } |
| 103 | |
| 104 | function extractResultTypes(path: string, source: string): TypeDoc[] { |
| 105 | const file = sourceFile(path, source); |
| 106 | |
| 107 | return file.statements |
| 108 | .filter((statement): statement is ts.InterfaceDeclaration => |
| 109 | ts.isInterfaceDeclaration(statement) && |
| 110 | hasModifier(statement, ts.SyntaxKind.ExportKeyword) && |
| 111 | (statement.name.text.endsWith('Result') || statement.name.text.endsWith('State') || statement.name.text.startsWith('GE') || statement.name.text.startsWith('Market')) |
| 112 | ) |
| 113 | .map(statement => ({ |
| 114 | name: statement.name.text, |
| 115 | description: descriptionFor(statement), |
| 116 | properties: statement.members |
| 117 | .filter((member): member is ts.PropertySignature => |
| 118 | ts.isPropertySignature(member) && Boolean(member.name) |
| 119 | ) |
| 120 | .map(property => ({ |
| 121 | signature: normalizeCode(property.getText(file)).replace(/;$/, ''), |
| 122 | description: descriptionFor(property), |
| 123 | })), |
| 124 | })); |
| 125 | } |
| 126 | |
| 127 | function markdownCell(text: string): string { |
| 128 | return text |
| 129 | .replace(/\|/g, '\\|') |
| 130 | .replace(/\r?\n/g, ' '); |
no test coverage detected