MCPcopy Create free account
hub / github.com/MaxBittker/rs-sdk / parseClassMethods

Function parseClassMethods

sdk/generate-api-docs.ts:87–127  ·  view source on GitHub ↗

* Parse method signatures from a class

(source: string, className: string)

Source from the content-addressed store, hash-verified

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
104function 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
127function markdownCell(text: string): string {
128 return text
129 .replace(/\|/g, '\\|')
130 .replace(/\r?\n/g, ' ');

Callers 1

mainFunction · 0.85

Calls 7

extractJSDocFunction · 0.85
parseParamsFunction · 0.85
testMethod · 0.65
hasMethod · 0.45
addMethod · 0.45
trimMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected