@xyd-js/sources 0.0.1-xyd.0
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/CHANGELOG.md +9 -0
- package/README.md +3 -0
- package/TODO.md +6 -0
- package/dist/example.cjs +642 -0
- package/dist/example.cjs.map +1 -0
- package/dist/example.d.cts +2 -0
- package/dist/example.d.ts +2 -0
- package/dist/example.js +618 -0
- package/dist/example.js.map +1 -0
- package/dist/index.cjs +647 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +83 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +612 -0
- package/dist/index.js.map +1 -0
- package/docs/README.md +20 -0
- package/docs/classes/ExampleClass.md +35 -0
- package/docs/functions/gqlSchemaToReferences.md +27 -0
- package/docs/functions/helloWorld.md +17 -0
- package/docs/functions/helloWorldV2.md +33 -0
- package/docs/functions/helloWorldV3.md +35 -0
- package/docs.json +551 -0
- package/example/package-a/package.json +4 -0
- package/example/package-a/src/index.ts +56 -0
- package/example/package-a/tsconfig.json +23 -0
- package/example/package-b/package.json +7 -0
- package/example/package-b/src/billing.ts +193 -0
- package/example/package-b/src/index.ts +8 -0
- package/example/package-b/tsconfig.json +20 -0
- package/package.json +22 -0
- package/references_todo.json +220 -0
- package/src/SignatureText.ts +214 -0
- package/src/TypeDocTransformer.ts +572 -0
- package/src/index.ts +45 -0
- package/test-cmd/index.ts +62 -0
- package/tsconfig.json +30 -0
- package/tsup.config.ts +39 -0
package/dist/example.js
ADDED
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
// test-cmd/index.ts
|
|
2
|
+
import * as fs3 from "node:fs";
|
|
3
|
+
import * as path2 from "node:path";
|
|
4
|
+
import * as TypeDoc from "typedoc";
|
|
5
|
+
|
|
6
|
+
// src/TypeDocTransformer.ts
|
|
7
|
+
import * as fs2 from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { ReflectionKind } from "typedoc";
|
|
10
|
+
|
|
11
|
+
// src/SignatureText.ts
|
|
12
|
+
import * as ts from "typescript";
|
|
13
|
+
import * as fs from "node:fs";
|
|
14
|
+
var printer = ts.createPrinter({ removeComments: true });
|
|
15
|
+
var SignatureTextLoader = class {
|
|
16
|
+
constructor(sourcePath) {
|
|
17
|
+
const source = fs.readFileSync(sourcePath, "utf-8");
|
|
18
|
+
this.sourceFile = ts.createSourceFile(
|
|
19
|
+
sourcePath,
|
|
20
|
+
source,
|
|
21
|
+
ts.ScriptTarget.Latest,
|
|
22
|
+
true
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var MultiSignatureLoader = class {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.loaders = /* @__PURE__ */ new Map();
|
|
29
|
+
}
|
|
30
|
+
load(path3) {
|
|
31
|
+
if (this.loaders.has(path3)) {
|
|
32
|
+
return this.loaders.get(path3);
|
|
33
|
+
}
|
|
34
|
+
const loader = new SignatureTextLoader(path3);
|
|
35
|
+
this.loaders.set(path3, loader);
|
|
36
|
+
return loader;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function signatureTextByLine(sign, targetLine) {
|
|
40
|
+
return signatureText.call(sign, targetLine);
|
|
41
|
+
}
|
|
42
|
+
function signatureSourceCodeByLine(sign, targetLine) {
|
|
43
|
+
return signatureSourceCode.call(sign, targetLine);
|
|
44
|
+
}
|
|
45
|
+
function signatureText(targetLine) {
|
|
46
|
+
const sourceFile = this.sourceFile;
|
|
47
|
+
const signatureNode = findSignatureNode.call(
|
|
48
|
+
this,
|
|
49
|
+
sourceFile,
|
|
50
|
+
[targetLine]
|
|
51
|
+
);
|
|
52
|
+
if (!signatureNode) {
|
|
53
|
+
console.error("(signatureText): `signatureNode` is empty, something went wrong");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const printableSignatureNode = nodeToPrintableSignatureNode(signatureNode);
|
|
57
|
+
if (!printableSignatureNode) {
|
|
58
|
+
console.error("(signatureText): cannot convert `signatureNode` to `printableSignatureNode`");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return printer.printNode(ts.EmitHint.Unspecified, printableSignatureNode, sourceFile).trim();
|
|
62
|
+
}
|
|
63
|
+
function findSignatureNode(node, targetLines) {
|
|
64
|
+
let isSourceFile = false;
|
|
65
|
+
if (node === node.getSourceFile()) {
|
|
66
|
+
isSourceFile = true;
|
|
67
|
+
}
|
|
68
|
+
if (!isSourceFile && isNodeAtLine(node, targetLines, this.sourceFile)) {
|
|
69
|
+
return node;
|
|
70
|
+
}
|
|
71
|
+
let signatureNode;
|
|
72
|
+
ts.forEachChild(node, (n) => {
|
|
73
|
+
if (signatureNode) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
signatureNode = findSignatureNode.call(this, n, targetLines);
|
|
77
|
+
});
|
|
78
|
+
return signatureNode;
|
|
79
|
+
}
|
|
80
|
+
function signatureSourceCode(targetLine) {
|
|
81
|
+
const sourceFile = this.sourceFile;
|
|
82
|
+
const signatureNode = findSignatureNode.call(
|
|
83
|
+
this,
|
|
84
|
+
sourceFile,
|
|
85
|
+
[targetLine]
|
|
86
|
+
);
|
|
87
|
+
if (!signatureNode) {
|
|
88
|
+
console.error("(signatureSourceCode): `signatureNode` is empty, something went wrong");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const start = signatureNode.getStart(sourceFile);
|
|
92
|
+
const end = signatureNode.getEnd();
|
|
93
|
+
return sourceFile.text.substring(start, end).trim();
|
|
94
|
+
}
|
|
95
|
+
function nodeToPrintableSignatureNode(node) {
|
|
96
|
+
let resp;
|
|
97
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
98
|
+
resp = ts.factory.updateFunctionDeclaration(
|
|
99
|
+
node,
|
|
100
|
+
node.modifiers,
|
|
101
|
+
node.asteriskToken,
|
|
102
|
+
node.name,
|
|
103
|
+
node.typeParameters,
|
|
104
|
+
node.parameters,
|
|
105
|
+
node.type,
|
|
106
|
+
void 0
|
|
107
|
+
);
|
|
108
|
+
} else if (ts.isClassDeclaration(node)) {
|
|
109
|
+
resp = ts.factory.updateClassDeclaration(
|
|
110
|
+
node,
|
|
111
|
+
node.modifiers,
|
|
112
|
+
node.name,
|
|
113
|
+
node.typeParameters,
|
|
114
|
+
node.heritageClauses,
|
|
115
|
+
[]
|
|
116
|
+
);
|
|
117
|
+
} else if (ts.isInterfaceDeclaration(node)) {
|
|
118
|
+
resp = ts.factory.updateInterfaceDeclaration(
|
|
119
|
+
node,
|
|
120
|
+
node.modifiers,
|
|
121
|
+
node.name,
|
|
122
|
+
node.typeParameters,
|
|
123
|
+
node.heritageClauses,
|
|
124
|
+
[]
|
|
125
|
+
);
|
|
126
|
+
} else if (ts.isEnumDeclaration(node)) {
|
|
127
|
+
resp = ts.factory.updateEnumDeclaration(
|
|
128
|
+
node,
|
|
129
|
+
node.modifiers,
|
|
130
|
+
node.name,
|
|
131
|
+
[]
|
|
132
|
+
);
|
|
133
|
+
} else if (ts.isTypeAliasDeclaration(node)) {
|
|
134
|
+
resp = ts.factory.updateTypeAliasDeclaration(
|
|
135
|
+
node,
|
|
136
|
+
node.modifiers,
|
|
137
|
+
node.name,
|
|
138
|
+
node.typeParameters,
|
|
139
|
+
node.type
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (!resp) {
|
|
143
|
+
console.error("(nodeToPrintableSignatureNode): resp is empty, something went wrong");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
return resp;
|
|
147
|
+
}
|
|
148
|
+
function isNodeAtLine(node, lines, sf) {
|
|
149
|
+
const { line: startLine } = sf.getLineAndCharacterOfPosition(node.getStart());
|
|
150
|
+
return lines.includes(startLine + 1);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/TypeDocTransformer.ts
|
|
154
|
+
var TypeDocSignatureTextLoader = class extends MultiSignatureLoader {
|
|
155
|
+
constructor(project, packagePathMap) {
|
|
156
|
+
super();
|
|
157
|
+
this.project = project;
|
|
158
|
+
this.packagePathMap = packagePathMap;
|
|
159
|
+
}
|
|
160
|
+
signatureText(id, line) {
|
|
161
|
+
const loader = this.getSignatuerLoader(id);
|
|
162
|
+
if (!loader) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const signTxt = signatureTextByLine(loader, line);
|
|
166
|
+
if (!signTxt) {
|
|
167
|
+
console.warn("(TypeDocSignatureTextLoader.signatureText): Signature text is empty", id);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
return signTxt;
|
|
171
|
+
}
|
|
172
|
+
signatureSourceCode(id, line) {
|
|
173
|
+
const loader = this.getSignatuerLoader(id);
|
|
174
|
+
if (!loader) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const sourceCode = signatureSourceCodeByLine(loader, line);
|
|
178
|
+
if (!sourceCode) {
|
|
179
|
+
console.warn("(TypeDocSignatureTextLoader.signatureSourceCode): Source code is empty", id);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
return sourceCode;
|
|
183
|
+
}
|
|
184
|
+
getSignatuerLoader(id) {
|
|
185
|
+
const symbolMap = this.project.symbolIdMap[id];
|
|
186
|
+
if (!symbolMap) {
|
|
187
|
+
console.warn("(TypeDocSignatureTextLoader.getSignatuerLoader): Symbol not found", id);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const fullPath = this.packagePathMap[id];
|
|
191
|
+
if (!fullPath) {
|
|
192
|
+
console.warn("(TypeDocSignatureTextLoader.getSignatuerLoader): Package path not found for symbol", symbolMap.packageName);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const loader = this.load(fullPath);
|
|
196
|
+
if (!loader) {
|
|
197
|
+
console.warn("(TypeDocSignatureTextLoader.getSignatuerLoader): Loader not found", fullPath);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
return loader;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var Transformer = class {
|
|
204
|
+
constructor(rootPath, project, references = []) {
|
|
205
|
+
this.rootPath = rootPath;
|
|
206
|
+
this.project = project;
|
|
207
|
+
this.references = references;
|
|
208
|
+
this.packagePathMap = {};
|
|
209
|
+
const packagePathMap = this.createPackagePathMap();
|
|
210
|
+
if (packagePathMap) {
|
|
211
|
+
this.packagePathMap = packagePathMap;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
createPackagePathMap() {
|
|
215
|
+
const packagePathMap = {};
|
|
216
|
+
const packageJsonPaths = this.findPackageJsonPaths(this.rootPath);
|
|
217
|
+
if (!packageJsonPaths.length) {
|
|
218
|
+
console.warn("(Transformer.createPackagePathMap): No package.json found in rootPath", this.rootPath);
|
|
219
|
+
return { packageMap: null, moduleRootMap: null };
|
|
220
|
+
}
|
|
221
|
+
for (const packageJsonPath of packageJsonPaths) {
|
|
222
|
+
const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
223
|
+
const packageName = packageJson.name;
|
|
224
|
+
const moduleRoot = path.dirname(packageJsonPath);
|
|
225
|
+
if (!packageName) {
|
|
226
|
+
console.warn("(Transformer.createPackagePathMap): Package name not found in package.json", packageJsonPath);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
for (const id in this.project.symbolIdMap) {
|
|
230
|
+
const symbolMap = this.project.symbolIdMap[id];
|
|
231
|
+
if (symbolMap.packageName === packageName) {
|
|
232
|
+
const fullPath = path.join(moduleRoot, symbolMap.packagePath);
|
|
233
|
+
packagePathMap[Number.parseInt(id)] = fullPath;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return packagePathMap;
|
|
238
|
+
}
|
|
239
|
+
findPackageJsonPaths(dir) {
|
|
240
|
+
let results = [];
|
|
241
|
+
const list = fs2.readdirSync(dir);
|
|
242
|
+
for (const file of list) {
|
|
243
|
+
const filePath = path.join(dir, file);
|
|
244
|
+
const stat = fs2.statSync(filePath);
|
|
245
|
+
if (stat && stat.isDirectory()) {
|
|
246
|
+
results = results.concat(this.findPackageJsonPaths(filePath));
|
|
247
|
+
} else if (file === "package.json") {
|
|
248
|
+
results.push(filePath);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return results;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
function typedocToUniform(rootPath, project) {
|
|
255
|
+
const references = [];
|
|
256
|
+
const transformer = new Transformer(
|
|
257
|
+
rootPath,
|
|
258
|
+
project,
|
|
259
|
+
references
|
|
260
|
+
);
|
|
261
|
+
const signatureTextLoader = new TypeDocSignatureTextLoader(
|
|
262
|
+
project,
|
|
263
|
+
transformer.packagePathMap
|
|
264
|
+
);
|
|
265
|
+
transformer.signatureTextLoader = signatureTextLoader;
|
|
266
|
+
if (project.kind !== ReflectionKind.Project) {
|
|
267
|
+
throw new Error("Project reflection expected");
|
|
268
|
+
}
|
|
269
|
+
for (const child of project.children || []) {
|
|
270
|
+
if (!("kind" in child)) {
|
|
271
|
+
throw new Error("(typedocToUniform): Child reflection expected in project childrens");
|
|
272
|
+
}
|
|
273
|
+
if (typeof child.kind != "number") {
|
|
274
|
+
throw new Error("(typedocToUniform): Child reflection kind expected to be a number");
|
|
275
|
+
}
|
|
276
|
+
if (!child.kind) {
|
|
277
|
+
throw new Error("(typedocToUniform): Child reflection kind expected to be a valid ReflectionKind");
|
|
278
|
+
}
|
|
279
|
+
const kind = child.kind;
|
|
280
|
+
switch (kind) {
|
|
281
|
+
case ReflectionKind.Module: {
|
|
282
|
+
const container = child;
|
|
283
|
+
for (const group of container.children || []) {
|
|
284
|
+
const ref = typedocGroupToUniform.call(
|
|
285
|
+
transformer,
|
|
286
|
+
group
|
|
287
|
+
);
|
|
288
|
+
if (!ref) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
ref.context = {
|
|
292
|
+
...ref.context,
|
|
293
|
+
package: container.name
|
|
294
|
+
};
|
|
295
|
+
references.push(ref);
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
case ReflectionKind.Function:
|
|
300
|
+
case ReflectionKind.Class: {
|
|
301
|
+
if (!child) {
|
|
302
|
+
throw new Error("(typedocToUniform): Function reflection expected to be a DeclarationReflection");
|
|
303
|
+
}
|
|
304
|
+
const ref = typedocGroupToUniform.call(
|
|
305
|
+
transformer,
|
|
306
|
+
child
|
|
307
|
+
);
|
|
308
|
+
if (!ref) {
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
ref.context = {
|
|
312
|
+
...ref.context,
|
|
313
|
+
package: project.name
|
|
314
|
+
};
|
|
315
|
+
references.push(ref);
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
default: {
|
|
319
|
+
console.warn("(typedocToUniform): Another children project kind not supported", child.kind);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return references;
|
|
324
|
+
}
|
|
325
|
+
function typedocGroupToUniform(group) {
|
|
326
|
+
let ref;
|
|
327
|
+
switch (group.kind) {
|
|
328
|
+
case ReflectionKind.Class: {
|
|
329
|
+
ref = jsClassToUniformRef.call(this, group);
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case ReflectionKind.Function: {
|
|
333
|
+
ref = jsFunctionToUniformRef.call(this, group);
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
default: {
|
|
337
|
+
console.warn("(typedocGroupToUniform): Unhandled reflection kind", group.kind);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return ref;
|
|
341
|
+
}
|
|
342
|
+
function jsClassToUniformRef(dec) {
|
|
343
|
+
var _a, _b, _c, _d;
|
|
344
|
+
const definitions = [];
|
|
345
|
+
const ref = {
|
|
346
|
+
title: `Class ${dec.name}`,
|
|
347
|
+
canonical: `class-${dec.name}`,
|
|
348
|
+
description: "",
|
|
349
|
+
context: {},
|
|
350
|
+
examples: {
|
|
351
|
+
groups: []
|
|
352
|
+
},
|
|
353
|
+
definitions
|
|
354
|
+
};
|
|
355
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
356
|
+
if (declarationCtx) {
|
|
357
|
+
ref.context = {
|
|
358
|
+
...ref.context,
|
|
359
|
+
...declarationCtx
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (dec.comment) {
|
|
363
|
+
const description = commentToUniform(dec.comment);
|
|
364
|
+
const group = ((declarationCtx == null ? void 0 : declarationCtx.packageName.split("/")) || []).map((name) => `"${name}"`).join(",");
|
|
365
|
+
ref.description = `---
|
|
366
|
+
title: ${dec.name}
|
|
367
|
+
group: [${group}, Classes]
|
|
368
|
+
---
|
|
369
|
+
${description}`;
|
|
370
|
+
}
|
|
371
|
+
{
|
|
372
|
+
const constructor = (_a = dec.children) == null ? void 0 : _a.find((child) => child.name === "constructor");
|
|
373
|
+
if ((_b = constructor == null ? void 0 : constructor.signatures) == null ? void 0 : _b[0]) {
|
|
374
|
+
const constructorDef = {
|
|
375
|
+
title: "Constructor",
|
|
376
|
+
properties: []
|
|
377
|
+
};
|
|
378
|
+
const constructorSign = constructor.signatures[0];
|
|
379
|
+
for (const param of constructorSign.parameters || []) {
|
|
380
|
+
if (!param.type) {
|
|
381
|
+
console.warn("(jsClassToUniformRef): Constructor parameter type not found", param.name);
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
let description = "";
|
|
385
|
+
if (param.comment) {
|
|
386
|
+
description = commentToUniform(param.comment);
|
|
387
|
+
}
|
|
388
|
+
constructorDef.properties.push({
|
|
389
|
+
name: param.name,
|
|
390
|
+
type: someTypeToUniformType(param.type),
|
|
391
|
+
description
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
definitions.push(constructorDef);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
{
|
|
398
|
+
const methods = ((_c = dec.children) == null ? void 0 : _c.filter(
|
|
399
|
+
(child) => child.kind === ReflectionKind.Method && child.name !== "constructor"
|
|
400
|
+
)) || [];
|
|
401
|
+
if (methods.length > 0) {
|
|
402
|
+
const methodsDef = {
|
|
403
|
+
title: "Methods",
|
|
404
|
+
properties: []
|
|
405
|
+
};
|
|
406
|
+
for (const method of methods) {
|
|
407
|
+
if (!((_d = method.signatures) == null ? void 0 : _d[0])) continue;
|
|
408
|
+
const methodSign = method.signatures[0];
|
|
409
|
+
let methodDesc = "";
|
|
410
|
+
if (methodSign.comment) {
|
|
411
|
+
methodDesc = commentToUniform(methodSign.comment);
|
|
412
|
+
}
|
|
413
|
+
methodsDef.properties.push({
|
|
414
|
+
name: method.name,
|
|
415
|
+
type: methodSign.type ? someTypeToUniformType(methodSign.type) : "void",
|
|
416
|
+
description: methodDesc
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
definitions.push(methodsDef);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return ref;
|
|
423
|
+
}
|
|
424
|
+
function jsFunctionToUniformRef(dec) {
|
|
425
|
+
const definitions = [];
|
|
426
|
+
const ref = {
|
|
427
|
+
title: `Function ${dec.name}`,
|
|
428
|
+
canonical: `fn-${dec.name}`,
|
|
429
|
+
description: "",
|
|
430
|
+
context: {},
|
|
431
|
+
examples: {
|
|
432
|
+
groups: []
|
|
433
|
+
},
|
|
434
|
+
definitions
|
|
435
|
+
};
|
|
436
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
437
|
+
if (declarationCtx) {
|
|
438
|
+
ref.context = {
|
|
439
|
+
...ref.context,
|
|
440
|
+
...declarationCtx
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
const signatures = dec.signatures || [];
|
|
444
|
+
if (signatures.length > 1) {
|
|
445
|
+
console.error("(jsFunctionToUniformRef): Multiple signatures not supported for function declaration", dec.name);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
for (const sign of dec.signatures || []) {
|
|
449
|
+
{
|
|
450
|
+
if (sign.comment) {
|
|
451
|
+
const description = commentToUniform(sign.comment);
|
|
452
|
+
const group = ((declarationCtx == null ? void 0 : declarationCtx.packageName.split("/")) || []).map((name) => `"${name}"`).join(",");
|
|
453
|
+
ref.description = `---
|
|
454
|
+
title: ${dec.name}
|
|
455
|
+
group: [${group}, Functions]
|
|
456
|
+
---
|
|
457
|
+
${description}`;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
{
|
|
461
|
+
const returnsUniformDef = {
|
|
462
|
+
title: "Returns",
|
|
463
|
+
properties: []
|
|
464
|
+
};
|
|
465
|
+
if (sign.type) {
|
|
466
|
+
let desc = "";
|
|
467
|
+
if (sign.comment) {
|
|
468
|
+
desc = returnCommentToUniform(sign.comment) || "";
|
|
469
|
+
}
|
|
470
|
+
returnsUniformDef.properties.push({
|
|
471
|
+
name: "",
|
|
472
|
+
type: someTypeToUniformType(sign.type),
|
|
473
|
+
description: desc
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
ref.definitions.push(returnsUniformDef);
|
|
477
|
+
}
|
|
478
|
+
{
|
|
479
|
+
const parametersUniformDef = {
|
|
480
|
+
title: "Parameters",
|
|
481
|
+
properties: []
|
|
482
|
+
};
|
|
483
|
+
for (const param of sign.parameters || []) {
|
|
484
|
+
if (!param.type) {
|
|
485
|
+
console.warn("(jsFunctionToUniformRef): Parameter type not found", param.name);
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
let description = "";
|
|
489
|
+
if (param.comment) {
|
|
490
|
+
description = commentToUniform(param.comment);
|
|
491
|
+
}
|
|
492
|
+
parametersUniformDef.properties.push({
|
|
493
|
+
name: param.name,
|
|
494
|
+
type: someTypeToUniformType(param.type),
|
|
495
|
+
description
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
ref.definitions.push(parametersUniformDef);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return ref;
|
|
502
|
+
}
|
|
503
|
+
function declarationUniformContext(dec) {
|
|
504
|
+
if (!dec.sources || !dec.sources.length) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (dec.sources.length > 1) {
|
|
508
|
+
console.warn("(declarationUniformContext): Multiple sources not supported for function declaration", dec.name);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
const source = dec.sources[0];
|
|
512
|
+
if (!source.fileName) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const signTxt = this.signatureTextLoader.signatureText(
|
|
516
|
+
dec.id,
|
|
517
|
+
source.line
|
|
518
|
+
) || "";
|
|
519
|
+
const sourceCode = this.signatureTextLoader.signatureSourceCode(
|
|
520
|
+
dec.id,
|
|
521
|
+
source.line
|
|
522
|
+
) || "";
|
|
523
|
+
const symbolMap = this.project.symbolIdMap[dec.id];
|
|
524
|
+
if (!symbolMap) {
|
|
525
|
+
console.warn("(declarationUniformContext): Symbol not found", dec.id);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
const fileFullPath = symbolMap.packagePath;
|
|
529
|
+
return {
|
|
530
|
+
packageName: symbolMap.packageName,
|
|
531
|
+
fileName: source.fileName,
|
|
532
|
+
fileFullPath,
|
|
533
|
+
line: source.line,
|
|
534
|
+
col: source.character,
|
|
535
|
+
signatureText: {
|
|
536
|
+
code: signTxt,
|
|
537
|
+
lang: "ts"
|
|
538
|
+
},
|
|
539
|
+
sourcecode: {
|
|
540
|
+
code: sourceCode,
|
|
541
|
+
lang: "ts"
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
function someTypeToUniformType(someType) {
|
|
546
|
+
if (!("name" in someType)) {
|
|
547
|
+
console.warn("SomeType does not have name property", someType);
|
|
548
|
+
return "";
|
|
549
|
+
}
|
|
550
|
+
switch (someType.type) {
|
|
551
|
+
case "reference": {
|
|
552
|
+
return `<${someType.name}>`;
|
|
553
|
+
}
|
|
554
|
+
default: {
|
|
555
|
+
return someType.name;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
function commentToUniform(comment) {
|
|
560
|
+
let desc = "";
|
|
561
|
+
for (const summary of (comment == null ? void 0 : comment.summary) || []) {
|
|
562
|
+
desc += `${summary.text}
|
|
563
|
+
`;
|
|
564
|
+
}
|
|
565
|
+
return desc;
|
|
566
|
+
}
|
|
567
|
+
function returnCommentToUniform(comment) {
|
|
568
|
+
if (!comment.blockTags || !comment.blockTags.length) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
let desc = "";
|
|
572
|
+
for (const tag of comment.blockTags) {
|
|
573
|
+
if (tag.tag === "@returns") {
|
|
574
|
+
for (const content of tag.content || []) {
|
|
575
|
+
desc += `${content.text}
|
|
576
|
+
`;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return desc;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// test-cmd/index.ts
|
|
584
|
+
async function generateDocs() {
|
|
585
|
+
const options = {
|
|
586
|
+
entryPoints: [
|
|
587
|
+
"example/package-a"
|
|
588
|
+
// "example/package-b",
|
|
589
|
+
],
|
|
590
|
+
plugin: [
|
|
591
|
+
"typedoc-plugin-markdown"
|
|
592
|
+
],
|
|
593
|
+
readme: "none",
|
|
594
|
+
disableSources: true,
|
|
595
|
+
entryPointStrategy: TypeDoc.EntryPointStrategy.Packages,
|
|
596
|
+
indexFormat: "table",
|
|
597
|
+
useCodeBlocks: true
|
|
598
|
+
};
|
|
599
|
+
const app = await TypeDoc.Application.bootstrapWithPlugins(options);
|
|
600
|
+
const project = await app.convert();
|
|
601
|
+
if (!project) {
|
|
602
|
+
throw new Error("Failed to generate documentation.");
|
|
603
|
+
}
|
|
604
|
+
const jsonOutput = await app.serializer.projectToObject(project, path2.resolve("./example"));
|
|
605
|
+
fs3.writeFileSync("docs.json", JSON.stringify(jsonOutput, null, 2));
|
|
606
|
+
await app.generateOutputs(project);
|
|
607
|
+
{
|
|
608
|
+
const projectRaw = fs3.readFileSync("docs.json", "utf-8");
|
|
609
|
+
const projectJson = JSON.parse(projectRaw);
|
|
610
|
+
const ref = typedocToUniform(
|
|
611
|
+
path2.resolve("./example"),
|
|
612
|
+
projectJson
|
|
613
|
+
);
|
|
614
|
+
fs3.writeFileSync("references_todo.json", JSON.stringify(ref, null, 2));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
generateDocs().catch(console.error);
|
|
618
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../test-cmd/index.ts","../src/TypeDocTransformer.ts","../src/SignatureText.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport * as TypeDoc from 'typedoc';\nimport type {TypeDocOptions} from \"typedoc\";\n//@ts-ignore\nimport {PluginOptions} from 'typedoc-plugin-markdown'\n\nimport {typedocToUniform} from \"../src/TypeDocTransformer\"\n\nasync function generateDocs() {\n const options = {\n entryPoints: [\n \"example/package-a\",\n // \"example/package-b\",\n ],\n plugin: [\n \"typedoc-plugin-markdown\"\n ],\n readme: \"none\",\n disableSources: true,\n entryPointStrategy: TypeDoc.EntryPointStrategy.Packages,\n\n indexFormat: \"table\",\n useCodeBlocks: true,\n } satisfies Partial<PluginOptions | TypeDocOptions>;\n\n const app = await TypeDoc.Application.bootstrapWithPlugins(options);\n const project = await app.convert()\n\n if (!project) {\n throw new Error('Failed to generate documentation.');\n }\n\n const jsonOutput = await app.serializer.projectToObject(project, path.resolve(\"./example\"));\n fs.writeFileSync('docs.json', JSON.stringify(jsonOutput, null, 2));\n\n await app.generateOutputs(project);\n // await app.generateJson(project, 'docs.json');\n\n {\n const projectRaw = fs.readFileSync('docs.json', 'utf-8');\n const projectJson = JSON.parse(projectRaw);\n const ref = typedocToUniform(\n path.resolve(\"./example\"),\n projectJson\n );\n\n fs.writeFileSync('references_todo.json', JSON.stringify(ref, null, 2));\n }\n\n // {\n // const loader = new SignatureTextLoader(\n // path.resolve('./example/package-a/src/index.ts')\n // );\n //\n // // TODO: some issues if line number higher than file lines\n // const signature = signatureTextByLine(loader, 15);\n // }\n}\n\ngenerateDocs().catch(console.error);","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport type {Reference, Definition} from \"@xyd-js/uniform\";\n\nimport type {\n JSONOutput,\n ContainerReflection,\n DeclarationReflection,\n SomeType,\n ReflectionSymbolId,\n Comment,\n} from 'typedoc';\nimport {ReflectionKind} from \"typedoc\";\n\nimport {\n MultiSignatureLoader,\n signatureTextByLine,\n signatureSourceCodeByLine\n} from \"./SignatureText\";\n\nclass TypeDocSignatureTextLoader extends MultiSignatureLoader {\n constructor(\n private project: JSONOutput.ProjectReflection,\n private packagePathMap: { [id: number]: string }\n ) {\n super();\n }\n\n public signatureText(\n id: number,\n line: number\n ) {\n const loader = this.getSignatuerLoader(id)\n if (!loader) {\n return\n }\n\n const signTxt = signatureTextByLine(loader, line)\n if (!signTxt) {\n console.warn('(TypeDocSignatureTextLoader.signatureText): Signature text is empty', id)\n return\n }\n\n return signTxt\n }\n\n public signatureSourceCode(\n id: number,\n line: number\n ) {\n const loader = this.getSignatuerLoader(id)\n if (!loader) {\n return\n }\n\n const sourceCode = signatureSourceCodeByLine(loader, line)\n if (!sourceCode) {\n console.warn('(TypeDocSignatureTextLoader.signatureSourceCode): Source code is empty', id)\n return\n }\n\n return sourceCode\n }\n\n private getSignatuerLoader(id: number) {\n const symbolMap = this.project.symbolIdMap[id] as ReflectionSymbolId\n if (!symbolMap) {\n console.warn('(TypeDocSignatureTextLoader.getSignatuerLoader): Symbol not found', id)\n return\n }\n\n const fullPath = this.packagePathMap[id]\n if (!fullPath) {\n console.warn('(TypeDocSignatureTextLoader.getSignatuerLoader): Package path not found for symbol', symbolMap.packageName)\n return\n }\n\n const loader = this.load(fullPath)\n if (!loader) {\n console.warn('(TypeDocSignatureTextLoader.getSignatuerLoader): Loader not found', fullPath)\n return\n }\n\n return loader\n }\n}\n\nclass Transformer {\n public packagePathMap: { [id: number]: string } = {};\n public signatureTextLoader!: TypeDocSignatureTextLoader;\n\n constructor(\n private rootPath: string,\n protected project: JSONOutput.ProjectReflection,\n protected references: Reference[] = []\n ) {\n const packagePathMap = this.createPackagePathMap()\n if (packagePathMap) {\n this.packagePathMap = packagePathMap\n }\n }\n\n private createPackagePathMap() {\n const packagePathMap: { [id: number]: string } = {};\n const packageJsonPaths = this.findPackageJsonPaths(this.rootPath);\n\n if (!packageJsonPaths.length) {\n console.warn('(Transformer.createPackagePathMap): No package.json found in rootPath', this.rootPath)\n return {packageMap: null, moduleRootMap: null}\n }\n\n for (const packageJsonPath of packageJsonPaths) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));\n const packageName = packageJson.name;\n const moduleRoot = path.dirname(packageJsonPath);\n\n if (!packageName) {\n console.warn('(Transformer.createPackagePathMap): Package name not found in package.json', packageJsonPath)\n continue\n }\n\n for (const id in this.project.symbolIdMap) {\n const symbolMap = this.project.symbolIdMap[id] as ReflectionSymbolId;\n\n if (symbolMap.packageName === packageName) {\n const fullPath = path.join(moduleRoot, symbolMap.packagePath);\n packagePathMap[Number.parseInt(id)] = fullPath;\n }\n }\n }\n\n return packagePathMap\n }\n\n private findPackageJsonPaths(dir: string): string[] {\n let results: string[] = [];\n const list = fs.readdirSync(dir);\n\n for (const file of list) {\n const filePath = path.join(dir, file);\n const stat = fs.statSync(filePath);\n if (stat && stat.isDirectory()) {\n results = results.concat(this.findPackageJsonPaths(filePath));\n } else if (file === 'package.json') {\n results.push(filePath);\n }\n }\n return results;\n }\n}\n\nexport function typedocToUniform(\n rootPath: string,\n project: JSONOutput.ProjectReflection\n): Reference[] {\n const references: Reference[] = []\n const transformer = new Transformer(\n rootPath,\n project,\n references\n )\n const signatureTextLoader = new TypeDocSignatureTextLoader(\n project,\n transformer.packagePathMap,\n )\n transformer.signatureTextLoader = signatureTextLoader\n\n // TODO: in the future abstraction?\n if (project.kind !== ReflectionKind.Project) {\n throw new Error('Project reflection expected');\n }\n\n for (const child of project.children || []) {\n if (!(\"kind\" in child)) {\n throw new Error('(typedocToUniform): Child reflection expected in project childrens');\n }\n\n if (typeof child.kind != \"number\") {\n throw new Error('(typedocToUniform): Child reflection kind expected to be a number');\n }\n\n if (!(child.kind satisfies ReflectionKind)) {\n throw new Error('(typedocToUniform): Child reflection kind expected to be a valid ReflectionKind');\n }\n\n const kind = child.kind as ReflectionKind\n\n switch (kind) {\n case ReflectionKind.Module: {\n const container = child as ContainerReflection\n\n for (const group of container.children || []) {\n const ref = typedocGroupToUniform.call(\n transformer,\n group\n )\n\n if (!ref) {\n continue\n }\n\n ref.context = {\n ...ref.context,\n package: container.name,\n }\n references.push(ref)\n }\n\n break\n }\n\n case ReflectionKind.Function:\n case ReflectionKind.Class: {\n if (!(child satisfies DeclarationReflection)) {\n throw new Error('(typedocToUniform): Function reflection expected to be a DeclarationReflection');\n }\n\n const ref = typedocGroupToUniform.call(\n transformer,\n child as DeclarationReflection\n )\n\n if (!ref) {\n break\n }\n\n ref.context = {\n ...ref.context,\n package: project.name,\n }\n references.push(ref)\n\n break\n }\n\n default: {\n console.warn(\"(typedocToUniform): Another children project kind not supported\", child.kind)\n }\n }\n }\n\n return references\n}\n\nfunction typedocGroupToUniform(\n this: Transformer,\n group: DeclarationReflection\n) {\n let ref: Reference | undefined\n\n switch (group.kind) {\n case ReflectionKind.Class: {\n ref = jsClassToUniformRef.call(this, group)\n\n break\n }\n case ReflectionKind.Function: {\n ref = jsFunctionToUniformRef.call(this, group)\n\n break\n }\n default: {\n console.warn('(typedocGroupToUniform): Unhandled reflection kind', group.kind)\n }\n }\n\n return ref\n}\n\nfunction jsClassToUniformRef(\n this: Transformer,\n dec: DeclarationReflection\n) {\n const definitions: Definition[] = []\n\n const ref: Reference = {\n title: `Class ${dec.name}`,\n canonical: `class-${dec.name}`,\n description: '',\n context: {},\n examples: {\n groups: []\n },\n definitions\n }\n\n const declarationCtx = declarationUniformContext.call(this, dec)\n if (declarationCtx) {\n ref.context = {\n ...ref.context,\n ...declarationCtx\n }\n }\n\n if (dec.comment) {\n const description = commentToUniform(dec.comment)\n const group = (declarationCtx?.packageName.split('/') || [])\n .map(name => `\"${name}\"`)\n .join(\",\")\n\n ref.description = `---\ntitle: ${dec.name} \ngroup: [${group}, Classes]\n---\n${description}`\n }\n\n // handle constructor\n {\n const constructor = dec.children?.find(child => child.name === 'constructor')\n if (constructor?.signatures?.[0]) {\n const constructorDef: Definition = {\n title: 'Constructor',\n properties: []\n }\n\n const constructorSign = constructor.signatures[0]\n for (const param of constructorSign.parameters || []) {\n if (!param.type) {\n console.warn('(jsClassToUniformRef): Constructor parameter type not found', param.name)\n continue\n }\n\n let description = \"\"\n if (param.comment) {\n description = commentToUniform(param.comment)\n }\n constructorDef.properties.push({\n name: param.name,\n type: someTypeToUniformType(param.type),\n description\n })\n }\n definitions.push(constructorDef)\n }\n }\n\n // handle methods\n {\n const methods = dec.children?.filter(child =>\n child.kind === ReflectionKind.Method && child.name !== 'constructor'\n ) || []\n\n if (methods.length > 0) {\n const methodsDef: Definition = {\n title: 'Methods',\n properties: []\n }\n\n for (const method of methods) {\n if (!method.signatures?.[0]) continue\n\n const methodSign = method.signatures[0]\n let methodDesc = \"\"\n if (methodSign.comment) {\n methodDesc = commentToUniform(methodSign.comment)\n }\n\n methodsDef.properties.push({\n name: method.name,\n type: methodSign.type ? someTypeToUniformType(methodSign.type) : \"void\",\n description: methodDesc\n })\n }\n\n definitions.push(methodsDef)\n }\n }\n\n return ref\n}\n\nfunction jsFunctionToUniformRef(\n this: Transformer,\n dec: DeclarationReflection\n) {\n const definitions: Definition[] = []\n const ref: Reference = {\n title: `Function ${dec.name}`,\n canonical: `fn-${dec.name}`,\n description: '',\n context: {},\n examples: {\n groups: [],\n },\n definitions,\n }\n\n const declarationCtx = declarationUniformContext.call(this, dec)\n if (declarationCtx) {\n ref.context = {\n ...ref.context,\n ...declarationCtx\n }\n }\n\n const signatures = dec.signatures || []\n if (signatures.length > 1) {\n console.error('(jsFunctionToUniformRef): Multiple signatures not supported for function declaration', dec.name)\n return\n }\n\n for (const sign of dec.signatures || []) {\n {\n if (sign.comment) {\n const description = commentToUniform(sign.comment)\n const group = (declarationCtx?.packageName.split('/') || [])\n .map(name => `\"${name}\"`)\n .join(\",\")\n\n ref.description = `---\ntitle: ${dec.name}\ngroup: [${group}, Functions]\n---\n${description}`\n }\n }\n\n // handle returns\n {\n const returnsUniformDef: Definition = {\n title: 'Returns',\n properties: [],\n }\n\n if (sign.type) {\n let desc = \"\"\n\n if (sign.comment) {\n desc = returnCommentToUniform(sign.comment) || \"\"\n }\n returnsUniformDef.properties.push({\n name: \"\",\n type: someTypeToUniformType(sign.type),\n description: desc\n })\n }\n\n ref.definitions.push(returnsUniformDef)\n }\n\n // handle parameters\n {\n const parametersUniformDef: Definition = {\n title: 'Parameters',\n properties: [],\n }\n\n for (const param of sign.parameters || []) {\n if (!param.type) {\n console.warn('(jsFunctionToUniformRef): Parameter type not found', param.name)\n continue\n }\n\n let description = \"\"\n if (param.comment) {\n description = commentToUniform(param.comment)\n }\n parametersUniformDef.properties.push({\n name: param.name,\n type: someTypeToUniformType(param.type),\n description\n })\n }\n\n ref.definitions.push(parametersUniformDef)\n }\n }\n\n return ref\n}\n\n\nfunction declarationUniformContext(\n this: Transformer,\n dec: DeclarationReflection,\n) {\n if (!dec.sources || !dec.sources.length) {\n return\n }\n\n if (dec.sources.length > 1) {\n console.warn('(declarationUniformContext): Multiple sources not supported for function declaration', dec.name)\n return\n }\n\n const source = dec.sources[0]\n if (!source.fileName) {\n return\n }\n\n const signTxt = this.signatureTextLoader.signatureText(\n dec.id,\n source.line\n ) || \"\"\n\n const sourceCode = this.signatureTextLoader.signatureSourceCode(\n dec.id,\n source.line\n ) || \"\"\n\n // Get the symbol map to find the package path\n const symbolMap = this.project.symbolIdMap[dec.id] as ReflectionSymbolId\n if (!symbolMap) {\n console.warn('(declarationUniformContext): Symbol not found', dec.id)\n return\n }\n\n // Use the packagePath directly as it's already relative to the module root\n const fileFullPath = symbolMap.packagePath\n\n return {\n packageName: symbolMap.packageName,\n fileName: source.fileName,\n fileFullPath,\n line: source.line,\n col: source.character,\n signatureText: {\n code: signTxt,\n lang: \"ts\",\n },\n sourcecode: {\n code: sourceCode,\n lang: \"ts\"\n }\n }\n}\n\nfunction someTypeToUniformType(someType: SomeType) {\n if (!(\"name\" in someType)) {\n console.warn('SomeType does not have name property', someType)\n return \"\"\n }\n\n switch (someType.type) {\n case \"reference\": {\n // TODO: abstract definition properties like GenericDefinitionProperty extends DefinitionProperty?\n return `<${someType.name}>`\n }\n default: {\n return someType.name\n }\n }\n}\n\nfunction commentToUniform(comment: Comment) {\n let desc = \"\"\n\n for (const summary of comment?.summary || []) {\n desc += `${summary.text}\\n`\n }\n\n return desc\n}\n\nfunction returnCommentToUniform(comment: Comment) {\n if (!comment.blockTags || !comment.blockTags.length) {\n return\n }\n\n let desc = \"\"\n for (const tag of comment.blockTags) {\n if (tag.tag === \"@returns\") {\n for (const content of tag.content || []) {\n desc += `${content.text}\\n`\n }\n }\n }\n\n return desc\n}","import * as ts from 'typescript';\nimport * as fs from \"node:fs\";\n\n// TODO: in the future more lightweight solution ??? - currently it's fine cuz it uses battle-tested TypeScript API\n\nconst printer = ts.createPrinter({removeComments: true});\n\nexport class SignatureTextLoader {\n protected sourceFile: ts.SourceFile;\n\n constructor(sourcePath: string) {\n const source = fs.readFileSync(sourcePath, 'utf-8');\n\n this.sourceFile = ts.createSourceFile(\n sourcePath,\n source,\n ts.ScriptTarget.Latest,\n true\n );\n }\n}\n\nexport class MultiSignatureLoader {\n private loaders: Map<string, SignatureTextLoader>\n\n constructor() {\n this.loaders = new Map<string, SignatureTextLoader>()\n }\n\n protected load(path: string) {\n if (this.loaders.has(path)) {\n return this.loaders.get(path)\n }\n\n const loader = new SignatureTextLoader(path)\n this.loaders.set(path, loader)\n\n return loader\n }\n}\n\n/**\n * Get the signature text of a function, class, interface, enum, or type alias at a specific line.\n *\n * @param sign - instance of SignatureText\n * @param targetLine - the line number of the signature in source code\n *\n * @returns code friendly signature text\n */\nexport function signatureTextByLine(\n sign: SignatureTextLoader,\n targetLine: number\n) {\n return signatureText.call(sign, targetLine)\n}\n\n/**\n * Get the source code of a function, class, interface, enum, or type alias at a specific line.\n *\n * @param sign - instance of SignatureText\n * @param targetLine - the line number of the signature in source code\n *\n * @returns source code of the signature\n*/\nexport function signatureSourceCodeByLine(\n sign: SignatureTextLoader,\n targetLine: number\n) {\n return signatureSourceCode.call(sign, targetLine)\n}\n\nfunction signatureText(\n this: SignatureTextLoader,\n targetLine: number\n) {\n const sourceFile = this.sourceFile;\n const signatureNode = findSignatureNode.call(\n this,\n sourceFile,\n [targetLine]\n );\n\n if (!signatureNode) {\n console.error(\"(signatureText): `signatureNode` is empty, something went wrong\");\n return\n }\n\n const printableSignatureNode = nodeToPrintableSignatureNode(signatureNode);\n if (!printableSignatureNode) {\n console.error(\"(signatureText): cannot convert `signatureNode` to `printableSignatureNode`\");\n return\n }\n\n return printer.printNode(ts.EmitHint.Unspecified, printableSignatureNode, sourceFile).trim()\n\n}\n\n// TODO: this function is probably not optimized well (recursion when not needed)\nfunction findSignatureNode(\n this: SignatureTextLoader,\n node: ts.Node,\n targetLines: number[]\n) {\n let isSourceFile = false\n if (node === node.getSourceFile()) {\n isSourceFile = true\n }\n\n if (!isSourceFile && isNodeAtLine(node, targetLines, this.sourceFile)) {\n return node\n }\n\n let signatureNode: ts.Node | undefined;\n\n ts.forEachChild(node, (n) => {\n if (signatureNode) {\n return\n }\n signatureNode = findSignatureNode.call(this, n, targetLines)\n });\n\n return signatureNode\n}\n\n\nfunction signatureSourceCode(\n this: SignatureTextLoader,\n targetLine: number\n) {\n const sourceFile = this.sourceFile;\n const signatureNode = findSignatureNode.call(\n this,\n sourceFile,\n [targetLine]\n );\n\n if (!signatureNode) {\n console.error(\"(signatureSourceCode): `signatureNode` is empty, something went wrong\");\n return\n }\n\n // Get the start and end positions of the node\n const start = signatureNode.getStart(sourceFile);\n const end = signatureNode.getEnd();\n\n // Get the source text between start and end\n return sourceFile.text.substring(start, end).trim();\n}\n\nfunction nodeToPrintableSignatureNode(node: ts.Node) {\n let resp: ts.Node | undefined;\n\n if (ts.isFunctionDeclaration(node)) {\n resp = ts.factory.updateFunctionDeclaration(\n node,\n node.modifiers,\n node.asteriskToken,\n node.name,\n node.typeParameters,\n node.parameters,\n node.type,\n undefined\n );\n } else if (ts.isClassDeclaration(node)) {\n resp = ts.factory.updateClassDeclaration(\n node,\n node.modifiers,\n node.name,\n node.typeParameters,\n node.heritageClauses,\n []\n );\n } else if (ts.isInterfaceDeclaration(node)) {\n resp = ts.factory.updateInterfaceDeclaration(\n node,\n node.modifiers,\n node.name,\n node.typeParameters,\n node.heritageClauses,\n []\n );\n } else if (ts.isEnumDeclaration(node)) {\n resp = ts.factory.updateEnumDeclaration(\n node,\n node.modifiers,\n node.name,\n []\n );\n } else if (ts.isTypeAliasDeclaration(node)) {\n resp = ts.factory.updateTypeAliasDeclaration(\n node,\n node.modifiers,\n node.name,\n node.typeParameters,\n node.type\n );\n }\n\n if (!resp) {\n console.error(\"(nodeToPrintableSignatureNode): resp is empty, something went wrong\");\n return;\n }\n\n return resp\n}\n\nfunction isNodeAtLine(node: ts.Node, lines: number[], sf: ts.SourceFile): boolean {\n const {line: startLine} = sf.getLineAndCharacterOfPosition(node.getStart());\n\n return lines.includes(startLine + 1); // lines are 0-based internally\n}\n\n\n\n"],"mappings":";AAAA,YAAYA,SAAQ;AACpB,YAAYC,WAAU;AAEtB,YAAY,aAAa;;;ACHzB,YAAYC,SAAQ;AACpB,YAAY,UAAU;AAYtB,SAAQ,sBAAqB;;;ACb7B,YAAY,QAAQ;AACpB,YAAY,QAAQ;AAIpB,IAAM,UAAa,iBAAc,EAAC,gBAAgB,KAAI,CAAC;AAEhD,IAAM,sBAAN,MAA0B;AAAA,EAG7B,YAAY,YAAoB;AAC5B,UAAM,SAAY,gBAAa,YAAY,OAAO;AAElD,SAAK,aAAgB;AAAA,MACjB;AAAA,MACA;AAAA,MACG,gBAAa;AAAA,MAChB;AAAA,IACJ;AAAA,EACJ;AACJ;AAEO,IAAM,uBAA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