@ankhorage/paradox 0.0.5 → 0.0.7
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 +16 -0
- package/README.md +141 -0
- package/dist/analyze/analyze.js +10 -0
- package/dist/analyze/badges.d.ts +6 -0
- package/dist/analyze/badges.js +256 -0
- package/dist/analyze/components.js +3 -0
- package/dist/analyze/exports.js +39 -9
- package/dist/analyze/modules.d.ts +9 -0
- package/dist/analyze/modules.js +44 -0
- package/dist/analyze/types.d.ts +48 -0
- package/dist/analyze/usage.d.ts +6 -0
- package/dist/analyze/utils/getExportMetadata.d.ts +12 -0
- package/dist/analyze/utils/getExportMetadata.js +162 -0
- package/dist/analyze/utils/getPropsFromType.js +3 -1
- package/dist/analyze/utils/parseParadoxComment.d.ts +2 -0
- package/dist/analyze/utils/parseParadoxComment.js +19 -1
- package/dist/cli.js +2 -2
- package/dist/model/buildModel.d.ts +46 -0
- package/dist/model/buildModel.js +55 -4
- package/dist/model/types.d.ts +48 -0
- package/dist/render/render.d.ts +3 -1
- package/dist/render/render.js +25 -87
- package/dist/render/renderers/badges.d.ts +6 -0
- package/dist/render/renderers/badges.js +35 -0
- package/dist/render/renderers/diagrams.d.ts +6 -0
- package/dist/render/renderers/diagrams.js +106 -0
- package/dist/render/renderers/html.d.ts +5 -0
- package/dist/render/renderers/html.js +317 -0
- package/dist/render/renderers/markdown.d.ts +5 -0
- package/dist/render/renderers/markdown.js +155 -0
- package/dist/render/types.d.ts +20 -0
- package/dist/write/write.js +12 -1
- package/package.json +1 -1
package/dist/analyze/types.d.ts
CHANGED
|
@@ -2,11 +2,41 @@ import type { Node } from 'ts-morph';
|
|
|
2
2
|
/***
|
|
3
3
|
* Describes one exported declaration discovered in a package.
|
|
4
4
|
*/
|
|
5
|
+
export interface AnalysisSourceLocation {
|
|
6
|
+
filePath: string;
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AnalysisParameter {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
required: boolean;
|
|
14
|
+
description: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface AnalysisSignature {
|
|
17
|
+
label: string;
|
|
18
|
+
parameters: AnalysisParameter[];
|
|
19
|
+
returnType: string | null;
|
|
20
|
+
returnDescription: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface AnalysisMember {
|
|
23
|
+
name: string;
|
|
24
|
+
kind: 'property' | 'method';
|
|
25
|
+
type: string;
|
|
26
|
+
required: boolean;
|
|
27
|
+
description: string | null;
|
|
28
|
+
}
|
|
5
29
|
export interface AnalysisExport {
|
|
6
30
|
name: string;
|
|
7
31
|
node: Node;
|
|
8
32
|
description: string | null;
|
|
9
33
|
kind: 'function' | 'type' | 'unknown';
|
|
34
|
+
modulePath: string;
|
|
35
|
+
sourceLocation: AnalysisSourceLocation;
|
|
36
|
+
exportPaths: string[];
|
|
37
|
+
relatedSymbols: string[];
|
|
38
|
+
signatures: AnalysisSignature[];
|
|
39
|
+
members: AnalysisMember[];
|
|
10
40
|
}
|
|
11
41
|
/***
|
|
12
42
|
* Describes one React component and its extracted props.
|
|
@@ -14,6 +44,9 @@ export interface AnalysisExport {
|
|
|
14
44
|
export interface AnalysisComponent {
|
|
15
45
|
name: string;
|
|
16
46
|
description: string | null;
|
|
47
|
+
modulePath: string;
|
|
48
|
+
sourceLocation: AnalysisSourceLocation;
|
|
49
|
+
exportPaths: string[];
|
|
17
50
|
props: {
|
|
18
51
|
name: string;
|
|
19
52
|
type: string;
|
|
@@ -29,6 +62,18 @@ export interface AnalysisUsageCommand {
|
|
|
29
62
|
name: string;
|
|
30
63
|
command: string;
|
|
31
64
|
}
|
|
65
|
+
export interface AnalysisBadge {
|
|
66
|
+
id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
value: string;
|
|
69
|
+
color: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AnalysisModule {
|
|
72
|
+
path: string;
|
|
73
|
+
isEntrypoint: boolean;
|
|
74
|
+
dependencies: string[];
|
|
75
|
+
exports: string[];
|
|
76
|
+
}
|
|
32
77
|
/***
|
|
33
78
|
* Complete analysis output used to build the documentation model.
|
|
34
79
|
*/
|
|
@@ -38,6 +83,9 @@ export interface AnalysisResult {
|
|
|
38
83
|
description: string | null;
|
|
39
84
|
exports: AnalysisExport[];
|
|
40
85
|
components: AnalysisComponent[];
|
|
86
|
+
entrypoints: string[];
|
|
87
|
+
modules: AnalysisModule[];
|
|
88
|
+
badges: AnalysisBadge[];
|
|
41
89
|
usage: AnalysisUsage | null;
|
|
42
90
|
config: {
|
|
43
91
|
exportName: string;
|
package/dist/analyze/usage.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import type { AnalysisUsage } from './types.js';
|
|
|
2
2
|
export interface PackageJsonModel {
|
|
3
3
|
name: string;
|
|
4
4
|
description?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
license?: string;
|
|
7
|
+
packageManager?: string;
|
|
5
8
|
bin?: string | Record<string, string>;
|
|
9
|
+
scripts?: Record<string, string>;
|
|
10
|
+
eslintConfig?: unknown;
|
|
11
|
+
prettier?: unknown;
|
|
6
12
|
}
|
|
7
13
|
export declare function createUsageFromPackageJson(pkg: PackageJsonModel): AnalysisUsage | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node, type Symbol as MorphSymbol } from 'ts-morph';
|
|
2
|
+
import type { AnalysisExport } from '../types.js';
|
|
3
|
+
/***
|
|
4
|
+
* Extracts computed metadata for an exported declaration.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getExportMetadata(options: {
|
|
7
|
+
name: string;
|
|
8
|
+
node: Node;
|
|
9
|
+
root: string;
|
|
10
|
+
entrypointPath: string;
|
|
11
|
+
symbol: MorphSymbol;
|
|
12
|
+
}): Pick<AnalysisExport, 'exportPaths' | 'members' | 'modulePath' | 'relatedSymbols' | 'signatures' | 'sourceLocation'>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import { Node, } from 'ts-morph';
|
|
3
|
+
import { getParadoxComment } from './getParadoxComment.js';
|
|
4
|
+
import { parseParadoxComment } from './parseParadoxComment.js';
|
|
5
|
+
/***
|
|
6
|
+
* Extracts computed metadata for an exported declaration.
|
|
7
|
+
*/
|
|
8
|
+
export function getExportMetadata(options) {
|
|
9
|
+
const modulePath = toPosixPath(relative(options.root, options.node.getSourceFile().getFilePath()));
|
|
10
|
+
const sourceLocation = getSourceLocation(options.node, options.root);
|
|
11
|
+
const signatures = getSignatures(options.symbol, options.node);
|
|
12
|
+
const members = getMembers(options.node);
|
|
13
|
+
const relatedSymbols = collectRelatedSymbols(options.name, signatures.flatMap((signature) => [
|
|
14
|
+
...signature.parameters.map((parameter) => parameter.type),
|
|
15
|
+
signature.returnType,
|
|
16
|
+
]), members.map((member) => member.type));
|
|
17
|
+
return {
|
|
18
|
+
modulePath,
|
|
19
|
+
sourceLocation,
|
|
20
|
+
exportPaths: [options.entrypointPath],
|
|
21
|
+
relatedSymbols,
|
|
22
|
+
signatures,
|
|
23
|
+
members,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getSourceLocation(node, root) {
|
|
27
|
+
const sourceFile = node.getSourceFile();
|
|
28
|
+
const { column, line } = sourceFile.getLineAndColumnAtPos(node.getStart(false));
|
|
29
|
+
return {
|
|
30
|
+
filePath: toPosixPath(relative(root, sourceFile.getFilePath())),
|
|
31
|
+
line,
|
|
32
|
+
column,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function getSignatures(symbol, node) {
|
|
36
|
+
const parsed = readParadoxMetadata(node);
|
|
37
|
+
const signatures = getCallableDeclarations(symbol, node).map((declaration) => getSignature(declaration, parsed.params, parsed.returns));
|
|
38
|
+
return uniqueBy(signatures.filter((signature) => signature.parameters.length > 0 ||
|
|
39
|
+
signature.returnType !== null ||
|
|
40
|
+
signature.returnDescription !== null), (signature) => signature.label);
|
|
41
|
+
}
|
|
42
|
+
function getSignature(declaration, params, returns) {
|
|
43
|
+
const normalizedParameters = declaration.getParameters().map((parameter) => {
|
|
44
|
+
const parameterDescription = params[parameter.getName()];
|
|
45
|
+
return {
|
|
46
|
+
name: parameter.getName(),
|
|
47
|
+
type: parameter.getType().getText(parameter),
|
|
48
|
+
required: !parameter.isOptional(),
|
|
49
|
+
description: parameterDescription ? parameterDescription.trim() : null,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const returnType = declaration.getReturnType().getText(declaration);
|
|
53
|
+
const parameterLabel = normalizedParameters
|
|
54
|
+
.map((parameter) => `${parameter.name}${parameter.required ? '' : '?'}: ${parameter.type}`)
|
|
55
|
+
.join(', ');
|
|
56
|
+
return {
|
|
57
|
+
label: `(${parameterLabel})${returnType === 'void' ? '' : ` => ${returnType}`}`,
|
|
58
|
+
parameters: normalizedParameters,
|
|
59
|
+
returnType,
|
|
60
|
+
returnDescription: returns,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function getMembers(node) {
|
|
64
|
+
if (getCallableNode(node) !== null)
|
|
65
|
+
return [];
|
|
66
|
+
return node
|
|
67
|
+
.getType()
|
|
68
|
+
.getProperties()
|
|
69
|
+
.map((property) => {
|
|
70
|
+
const [declaration] = property.getDeclarations();
|
|
71
|
+
const rawComment = getParadoxComment(declaration);
|
|
72
|
+
const parsed = rawComment
|
|
73
|
+
? parseParadoxComment(rawComment)
|
|
74
|
+
: { description: null, isConfig: false, params: {}, returns: null };
|
|
75
|
+
return {
|
|
76
|
+
name: property.getName(),
|
|
77
|
+
kind: isMemberMethodDeclaration(declaration) ? 'method' : 'property',
|
|
78
|
+
type: property.getTypeAtLocation(declaration).getText(declaration),
|
|
79
|
+
required: !property.isOptional(),
|
|
80
|
+
description: parsed.description,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function getCallableDeclarations(symbol, node) {
|
|
85
|
+
const declarations = symbol
|
|
86
|
+
.getDeclarations()
|
|
87
|
+
.map((declaration) => getCallableNode(declaration))
|
|
88
|
+
.filter((declaration) => declaration !== null);
|
|
89
|
+
if (declarations.length > 0) {
|
|
90
|
+
return declarations;
|
|
91
|
+
}
|
|
92
|
+
const callableNode = getCallableNode(node);
|
|
93
|
+
return callableNode !== null ? [callableNode] : [];
|
|
94
|
+
}
|
|
95
|
+
function getCallableNode(node) {
|
|
96
|
+
if (Node.isFunctionDeclaration(node))
|
|
97
|
+
return node;
|
|
98
|
+
if (Node.isMethodDeclaration(node))
|
|
99
|
+
return node;
|
|
100
|
+
if (Node.isMethodSignature(node))
|
|
101
|
+
return node;
|
|
102
|
+
if (Node.isArrowFunction(node))
|
|
103
|
+
return node;
|
|
104
|
+
if (Node.isFunctionExpression(node))
|
|
105
|
+
return node;
|
|
106
|
+
if (Node.isVariableDeclaration(node)) {
|
|
107
|
+
const initializer = node.getInitializer();
|
|
108
|
+
if (initializer &&
|
|
109
|
+
(Node.isArrowFunction(initializer) || Node.isFunctionExpression(initializer))) {
|
|
110
|
+
return initializer;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
function isMemberMethodDeclaration(node) {
|
|
116
|
+
return Node.isMethodDeclaration(node) || Node.isMethodSignature(node);
|
|
117
|
+
}
|
|
118
|
+
function readParadoxMetadata(node) {
|
|
119
|
+
const rawComment = getParadoxComment(node);
|
|
120
|
+
return rawComment
|
|
121
|
+
? parseParadoxComment(rawComment)
|
|
122
|
+
: { description: null, isConfig: false, params: {}, returns: null };
|
|
123
|
+
}
|
|
124
|
+
function collectRelatedSymbols(exportName, ...values) {
|
|
125
|
+
const candidates = values.flatMap((entries) => entries).filter((entry) => entry !== null);
|
|
126
|
+
const related = new Set();
|
|
127
|
+
for (const value of candidates) {
|
|
128
|
+
for (const symbol of value.matchAll(/\b[A-Z][A-Za-z0-9_]*\b/g)) {
|
|
129
|
+
const [candidate] = symbol;
|
|
130
|
+
if (!IGNORED_RELATED_SYMBOLS.has(candidate) && candidate !== exportName) {
|
|
131
|
+
related.add(candidate);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [...related].sort((left, right) => left.localeCompare(right));
|
|
136
|
+
}
|
|
137
|
+
function toPosixPath(path) {
|
|
138
|
+
return path.replaceAll('\\', '/');
|
|
139
|
+
}
|
|
140
|
+
function uniqueBy(items, key) {
|
|
141
|
+
const seen = new Set();
|
|
142
|
+
return items.filter((item) => {
|
|
143
|
+
const itemKey = key(item);
|
|
144
|
+
if (seen.has(itemKey))
|
|
145
|
+
return false;
|
|
146
|
+
seen.add(itemKey);
|
|
147
|
+
return true;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const IGNORED_RELATED_SYMBOLS = new Set([
|
|
151
|
+
'Array',
|
|
152
|
+
'Boolean',
|
|
153
|
+
'Date',
|
|
154
|
+
'Element',
|
|
155
|
+
'JSX',
|
|
156
|
+
'Map',
|
|
157
|
+
'Promise',
|
|
158
|
+
'ReadonlyArray',
|
|
159
|
+
'Record',
|
|
160
|
+
'Set',
|
|
161
|
+
'String',
|
|
162
|
+
]);
|
|
@@ -8,7 +8,9 @@ export function getPropsFromType(type) {
|
|
|
8
8
|
const [declaration] = property.getDeclarations();
|
|
9
9
|
const propertyType = property.getTypeAtLocation(declaration);
|
|
10
10
|
const rawComment = getParadoxComment(declaration);
|
|
11
|
-
const parsed = rawComment
|
|
11
|
+
const parsed = rawComment
|
|
12
|
+
? parseParadoxComment(rawComment)
|
|
13
|
+
: { description: null, isConfig: false, params: {}, returns: null };
|
|
12
14
|
return {
|
|
13
15
|
name: property.getName(),
|
|
14
16
|
type: propertyType.getText(declaration),
|
|
@@ -8,12 +8,28 @@ export function parseParadoxComment(rawComment) {
|
|
|
8
8
|
.split('\n')
|
|
9
9
|
.map((line) => line.replace(/^\s*\*\s?/, '').trimEnd());
|
|
10
10
|
let isConfig = false;
|
|
11
|
+
const params = {};
|
|
12
|
+
let returns = null;
|
|
11
13
|
const description = lines
|
|
12
14
|
.filter((line) => {
|
|
13
|
-
|
|
15
|
+
const trimmed = line.trimStart();
|
|
16
|
+
if (trimmed.startsWith('@config')) {
|
|
14
17
|
isConfig = true;
|
|
15
18
|
return false;
|
|
16
19
|
}
|
|
20
|
+
if (trimmed.startsWith('@param ')) {
|
|
21
|
+
const paramBody = trimmed.slice('@param '.length).trim();
|
|
22
|
+
const [name, ...descriptionParts] = paramBody.split(/\s+/);
|
|
23
|
+
if (name) {
|
|
24
|
+
params[name] = descriptionParts.join(' ').trim();
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (trimmed.startsWith('@returns') || trimmed.startsWith('@return')) {
|
|
29
|
+
const returnBody = trimmed.replace(/^@returns?/, '').trim();
|
|
30
|
+
returns = returnBody.length > 0 ? returnBody : null;
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
17
33
|
return true;
|
|
18
34
|
})
|
|
19
35
|
.join('\n')
|
|
@@ -21,5 +37,7 @@ export function parseParadoxComment(rawComment) {
|
|
|
21
37
|
return {
|
|
22
38
|
description: description.length > 0 ? description : null,
|
|
23
39
|
isConfig,
|
|
40
|
+
params,
|
|
41
|
+
returns,
|
|
24
42
|
};
|
|
25
43
|
}
|
package/dist/cli.js
CHANGED
|
@@ -14,10 +14,10 @@ async function main() {
|
|
|
14
14
|
const configDir = dirname(configFilePath);
|
|
15
15
|
const config = await loadParadoxConfig(configFilePath);
|
|
16
16
|
const packageRoot = await resolvePackageRoot(config, configDir);
|
|
17
|
-
const { outputRoot } = resolveOutputRoot(config, packageRoot);
|
|
17
|
+
const { outputDir, outputRoot } = resolveOutputRoot(config, packageRoot);
|
|
18
18
|
const analysis = await analyze(config, { packageRoot });
|
|
19
19
|
const model = buildModel(analysis);
|
|
20
|
-
const result = render(model);
|
|
20
|
+
const result = render(model, { outputDir });
|
|
21
21
|
await write(result, config, { packageRoot, outputRoot });
|
|
22
22
|
}
|
|
23
23
|
main().catch((error) => {
|
|
@@ -3,14 +3,53 @@ interface BuildModelInput {
|
|
|
3
3
|
packageName: string;
|
|
4
4
|
packageId: string;
|
|
5
5
|
description: string | null;
|
|
6
|
+
badges: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
color: string;
|
|
11
|
+
}[];
|
|
6
12
|
exports: {
|
|
7
13
|
name: string;
|
|
8
14
|
description: string | null;
|
|
9
15
|
kind: ExportKind;
|
|
16
|
+
modulePath: string;
|
|
17
|
+
sourceLocation: {
|
|
18
|
+
filePath: string;
|
|
19
|
+
line: number;
|
|
20
|
+
column: number;
|
|
21
|
+
};
|
|
22
|
+
exportPaths: string[];
|
|
23
|
+
relatedSymbols: string[];
|
|
24
|
+
signatures: {
|
|
25
|
+
label: string;
|
|
26
|
+
parameters: {
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
required: boolean;
|
|
30
|
+
description: string | null;
|
|
31
|
+
}[];
|
|
32
|
+
returnType: string | null;
|
|
33
|
+
returnDescription: string | null;
|
|
34
|
+
}[];
|
|
35
|
+
members: {
|
|
36
|
+
name: string;
|
|
37
|
+
kind: 'property' | 'method';
|
|
38
|
+
type: string;
|
|
39
|
+
required: boolean;
|
|
40
|
+
description: string | null;
|
|
41
|
+
}[];
|
|
10
42
|
}[];
|
|
11
43
|
components: {
|
|
12
44
|
name: string;
|
|
13
45
|
description: string | null;
|
|
46
|
+
modulePath: string;
|
|
47
|
+
sourceLocation: {
|
|
48
|
+
filePath: string;
|
|
49
|
+
line: number;
|
|
50
|
+
column: number;
|
|
51
|
+
};
|
|
52
|
+
exportPaths: string[];
|
|
14
53
|
props: {
|
|
15
54
|
name: string;
|
|
16
55
|
type: string;
|
|
@@ -28,6 +67,13 @@ interface BuildModelInput {
|
|
|
28
67
|
config: {
|
|
29
68
|
exportName: string;
|
|
30
69
|
} | null;
|
|
70
|
+
entrypoints: string[];
|
|
71
|
+
modules: {
|
|
72
|
+
path: string;
|
|
73
|
+
isEntrypoint: boolean;
|
|
74
|
+
dependencies: string[];
|
|
75
|
+
exports: string[];
|
|
76
|
+
}[];
|
|
31
77
|
}
|
|
32
78
|
/***
|
|
33
79
|
* Converts analysis output into a serializable documentation model.
|
package/dist/model/buildModel.js
CHANGED
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
* Converts analysis output into a serializable documentation model.
|
|
3
3
|
*/
|
|
4
4
|
export function buildModel(analysis) {
|
|
5
|
-
const
|
|
5
|
+
const exportNames = new Set(analysis.exports.map((item) => item.name));
|
|
6
|
+
const exportsByName = new Map(analysis.exports.map((item) => [item.name, mapExport(item, exportNames)]));
|
|
6
7
|
const exports = sortByName([...exportsByName.values()]);
|
|
7
8
|
return {
|
|
8
9
|
packageName: analysis.packageName,
|
|
9
10
|
packageId: analysis.packageId,
|
|
10
11
|
description: analysis.description,
|
|
12
|
+
badges: analysis.badges.map((badge) => ({
|
|
13
|
+
id: badge.id,
|
|
14
|
+
label: badge.label,
|
|
15
|
+
value: badge.value,
|
|
16
|
+
color: badge.color,
|
|
17
|
+
})),
|
|
11
18
|
usage: analysis.usage !== null
|
|
12
19
|
? {
|
|
13
20
|
packageName: analysis.usage.packageName,
|
|
@@ -26,21 +33,65 @@ export function buildModel(analysis) {
|
|
|
26
33
|
]),
|
|
27
34
|
}
|
|
28
35
|
: null,
|
|
36
|
+
entrypoints: [...analysis.entrypoints].sort((a, b) => a.localeCompare(b)),
|
|
37
|
+
modules: [...analysis.modules]
|
|
38
|
+
.map((module) => ({
|
|
39
|
+
path: module.path,
|
|
40
|
+
isEntrypoint: module.isEntrypoint,
|
|
41
|
+
dependencies: [...module.dependencies].sort((a, b) => a.localeCompare(b)),
|
|
42
|
+
exports: [...module.exports].sort((a, b) => a.localeCompare(b)),
|
|
43
|
+
}))
|
|
44
|
+
.sort((left, right) => left.path.localeCompare(right.path)),
|
|
29
45
|
exports,
|
|
30
|
-
components: sortByName(analysis.components.map(mapComponent)),
|
|
46
|
+
components: sortByName(analysis.components.map((component) => mapComponent(component, exportsByName.get(component.name)))),
|
|
31
47
|
};
|
|
32
48
|
}
|
|
33
|
-
function mapExport(item) {
|
|
49
|
+
function mapExport(item, exportNames) {
|
|
34
50
|
return {
|
|
35
51
|
name: item.name,
|
|
36
52
|
description: item.description,
|
|
37
53
|
kind: item.kind,
|
|
54
|
+
modulePath: item.modulePath,
|
|
55
|
+
sourceLocation: {
|
|
56
|
+
filePath: item.sourceLocation.filePath,
|
|
57
|
+
line: item.sourceLocation.line,
|
|
58
|
+
column: item.sourceLocation.column,
|
|
59
|
+
},
|
|
60
|
+
exportPaths: [...item.exportPaths].sort((a, b) => a.localeCompare(b)),
|
|
61
|
+
relatedSymbols: item.relatedSymbols
|
|
62
|
+
.filter((symbol) => exportNames.has(symbol))
|
|
63
|
+
.sort((a, b) => a.localeCompare(b)),
|
|
64
|
+
signatures: item.signatures.map((signature) => ({
|
|
65
|
+
label: signature.label,
|
|
66
|
+
parameters: sortByName(signature.parameters.map((parameter) => ({
|
|
67
|
+
name: parameter.name,
|
|
68
|
+
type: parameter.type,
|
|
69
|
+
required: parameter.required,
|
|
70
|
+
description: parameter.description,
|
|
71
|
+
}))),
|
|
72
|
+
returnType: signature.returnType,
|
|
73
|
+
returnDescription: signature.returnDescription,
|
|
74
|
+
})),
|
|
75
|
+
members: sortByName(item.members.map((member) => ({
|
|
76
|
+
name: member.name,
|
|
77
|
+
kind: member.kind,
|
|
78
|
+
type: member.type,
|
|
79
|
+
required: member.required,
|
|
80
|
+
description: member.description,
|
|
81
|
+
}))),
|
|
38
82
|
};
|
|
39
83
|
}
|
|
40
|
-
function mapComponent(component) {
|
|
84
|
+
function mapComponent(component, exportModel) {
|
|
41
85
|
return {
|
|
42
86
|
name: component.name,
|
|
43
87
|
description: component.description,
|
|
88
|
+
modulePath: component.modulePath,
|
|
89
|
+
sourceLocation: {
|
|
90
|
+
filePath: component.sourceLocation.filePath,
|
|
91
|
+
line: component.sourceLocation.line,
|
|
92
|
+
column: component.sourceLocation.column,
|
|
93
|
+
},
|
|
94
|
+
exportPaths: exportModel?.exportPaths ?? [...component.exportPaths].sort((a, b) => a.localeCompare(b)),
|
|
44
95
|
props: sortByName(component.props.map((prop) => ({
|
|
45
96
|
name: prop.name,
|
|
46
97
|
type: prop.type,
|
package/dist/model/types.d.ts
CHANGED
|
@@ -5,11 +5,20 @@ export interface DocumentationModel {
|
|
|
5
5
|
packageName: string;
|
|
6
6
|
packageId: string;
|
|
7
7
|
description: string | null;
|
|
8
|
+
badges: GeneratedBadge[];
|
|
8
9
|
usage: UsageModel | null;
|
|
9
10
|
config: ConfigModel | null;
|
|
11
|
+
entrypoints: string[];
|
|
12
|
+
modules: ModuleModel[];
|
|
10
13
|
exports: ExportModel[];
|
|
11
14
|
components: ComponentModel[];
|
|
12
15
|
}
|
|
16
|
+
export interface GeneratedBadge {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
color: string;
|
|
21
|
+
}
|
|
13
22
|
export interface UsageModel {
|
|
14
23
|
packageName: string;
|
|
15
24
|
commands: UsageCommandModel[];
|
|
@@ -27,13 +36,52 @@ export interface ExportModel {
|
|
|
27
36
|
name: string;
|
|
28
37
|
description: string | null;
|
|
29
38
|
kind: ExportKind;
|
|
39
|
+
modulePath: string;
|
|
40
|
+
sourceLocation: SourceLocationModel;
|
|
41
|
+
exportPaths: string[];
|
|
42
|
+
relatedSymbols: string[];
|
|
43
|
+
signatures: SignatureModel[];
|
|
44
|
+
members: MemberModel[];
|
|
30
45
|
}
|
|
31
46
|
export type ExportKind = 'function' | 'type' | 'unknown';
|
|
32
47
|
export interface ComponentModel {
|
|
33
48
|
name: string;
|
|
34
49
|
description: string | null;
|
|
50
|
+
modulePath: string;
|
|
51
|
+
sourceLocation: SourceLocationModel;
|
|
52
|
+
exportPaths: string[];
|
|
35
53
|
props: PropModel[];
|
|
36
54
|
}
|
|
55
|
+
export interface SourceLocationModel {
|
|
56
|
+
filePath: string;
|
|
57
|
+
line: number;
|
|
58
|
+
column: number;
|
|
59
|
+
}
|
|
60
|
+
export interface SignatureModel {
|
|
61
|
+
label: string;
|
|
62
|
+
parameters: ParameterModel[];
|
|
63
|
+
returnType: string | null;
|
|
64
|
+
returnDescription: string | null;
|
|
65
|
+
}
|
|
66
|
+
export interface ParameterModel {
|
|
67
|
+
name: string;
|
|
68
|
+
type: string;
|
|
69
|
+
required: boolean;
|
|
70
|
+
description: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface MemberModel {
|
|
73
|
+
name: string;
|
|
74
|
+
kind: 'property' | 'method';
|
|
75
|
+
type: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
description: string | null;
|
|
78
|
+
}
|
|
79
|
+
export interface ModuleModel {
|
|
80
|
+
path: string;
|
|
81
|
+
isEntrypoint: boolean;
|
|
82
|
+
dependencies: string[];
|
|
83
|
+
exports: string[];
|
|
84
|
+
}
|
|
37
85
|
export interface PropModel {
|
|
38
86
|
name: string;
|
|
39
87
|
type: string;
|
package/dist/render/render.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ import type { RenderResult } from './types.js';
|
|
|
3
3
|
/***
|
|
4
4
|
* Renders the documentation model into README and artifact files.
|
|
5
5
|
*/
|
|
6
|
-
export declare function render(model: DocumentationModel
|
|
6
|
+
export declare function render(model: DocumentationModel, options?: {
|
|
7
|
+
outputDir?: string;
|
|
8
|
+
}): RenderResult;
|