@ankhorage/paradox 0.0.8 → 0.0.9
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
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ankhorage/paradox
|
|
2
2
|
|
|
3
|
-
         
|
|
4
4
|
|
|
5
5
|
Deterministic documentation generator for TypeScript packages.
|
|
6
6
|
|
package/dist/analyze/exports.js
CHANGED
|
@@ -14,7 +14,10 @@ export function analyzeExports(project, options) {
|
|
|
14
14
|
const exported = sourceFile.getExportSymbols();
|
|
15
15
|
for (const symbol of exported) {
|
|
16
16
|
const resolved = resolveExportSymbol(symbol);
|
|
17
|
-
const
|
|
17
|
+
const decl = getFirstDeclaration(resolved.getDeclarations());
|
|
18
|
+
if (decl === null) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
18
21
|
const rawComment = getParadoxComment(decl);
|
|
19
22
|
const parsed = rawComment
|
|
20
23
|
? parseParadoxComment(rawComment)
|
|
@@ -67,6 +70,10 @@ function getEntryPointSourceFiles(project, options) {
|
|
|
67
70
|
})
|
|
68
71
|
.filter((sourceFile) => sourceFile != null);
|
|
69
72
|
}
|
|
73
|
+
function getFirstDeclaration(declarations) {
|
|
74
|
+
const [declaration = null] = declarations;
|
|
75
|
+
return declaration;
|
|
76
|
+
}
|
|
70
77
|
function inferKind(node) {
|
|
71
78
|
if ('getParameters' in node)
|
|
72
79
|
return 'function';
|
|
@@ -63,24 +63,42 @@ function getSignature(declaration, params, returns) {
|
|
|
63
63
|
function getMembers(node) {
|
|
64
64
|
if (getCallableNode(node) !== null)
|
|
65
65
|
return [];
|
|
66
|
-
|
|
67
|
-
.getType()
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
66
|
+
if (Node.isInterfaceDeclaration(node)) {
|
|
67
|
+
return getMembersFromProperties(node.getType().getProperties());
|
|
68
|
+
}
|
|
69
|
+
if (Node.isTypeAliasDeclaration(node)) {
|
|
70
|
+
const typeNode = node.getTypeNode();
|
|
71
|
+
if (!typeNode || !Node.isTypeLiteral(typeNode))
|
|
72
|
+
return [];
|
|
73
|
+
return getMembersFromProperties(node.getType().getProperties());
|
|
74
|
+
}
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
function getMembersFromProperties(properties) {
|
|
78
|
+
return properties.flatMap((property) => {
|
|
79
|
+
const declaration = getFirstDeclaration(property.getDeclarations());
|
|
80
|
+
if (declaration === null) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
71
83
|
const rawComment = getParadoxComment(declaration);
|
|
72
84
|
const parsed = rawComment
|
|
73
85
|
? parseParadoxComment(rawComment)
|
|
74
86
|
: { description: null, isConfig: false, params: {}, returns: null };
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
name: property.getName(),
|
|
90
|
+
kind: isMemberMethodDeclaration(declaration) ? 'method' : 'property',
|
|
91
|
+
type: property.getTypeAtLocation(declaration).getText(declaration),
|
|
92
|
+
required: !property.isOptional(),
|
|
93
|
+
description: parsed.description,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
82
96
|
});
|
|
83
97
|
}
|
|
98
|
+
function getFirstDeclaration(declarations) {
|
|
99
|
+
const [declaration = null] = declarations;
|
|
100
|
+
return declaration;
|
|
101
|
+
}
|
|
84
102
|
function getCallableDeclarations(symbol, node) {
|
|
85
103
|
const declarations = symbol
|
|
86
104
|
.getDeclarations()
|
|
@@ -2,4 +2,4 @@ import type { Node } from 'ts-morph';
|
|
|
2
2
|
/***
|
|
3
3
|
* Reads the nearest Paradox doc comment attached to a declaration.
|
|
4
4
|
*/
|
|
5
|
-
export declare function getParadoxComment(node: Node): string | null;
|
|
5
|
+
export declare function getParadoxComment(node: Node | undefined): string | null;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Reads the nearest Paradox doc comment attached to a declaration.
|
|
3
3
|
*/
|
|
4
4
|
export function getParadoxComment(node) {
|
|
5
|
+
if (!node)
|
|
6
|
+
return null;
|
|
5
7
|
const sourceFile = node.getSourceFile();
|
|
6
8
|
const text = sourceFile.getFullText();
|
|
7
9
|
const nodeStart = node.getStart(false);
|