@ankhorage/paradox 0.0.0 → 0.0.1
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 +6 -0
- package/README.md +14 -32
- package/package.json +1 -1
- package/paradox/exports.json +1 -46
- package/paradox/exports.md +2 -56
- package/paradox/paradox.json +11 -47
- package/src/analyze/analyze.ts +11 -1
- package/src/analyze/exports.ts +22 -3
- package/src/analyze/types.ts +9 -0
- package/src/analyze/utils/parseParadoxComment.ts +17 -3
- package/src/config/types.ts +3 -1
- package/src/index.ts +0 -7
- package/src/model/buildModel.ts +21 -0
- package/src/model/types.ts +9 -0
- package/src/render/render.ts +33 -2
- package/tests/__snapshots__/basic.exports.md +7 -1
- package/tests/__snapshots__/basic.readme.md +25 -1
- package/tests/analyze.test.ts +14 -2
- package/tests/fixtures/basic/package.json +4 -1
- package/tests/fixtures/basic/src/config.ts +8 -0
- package/tests/fixtures/basic/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Deterministic documentation generator for TypeScript packages.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
bunx @ankhorage/paradox
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Configuration
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Create a `paradox.config.ts` file:
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
```ts
|
|
16
|
+
import { defineParadoxConfig } from '@ankhorage/paradox';
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
export default defineParadoxConfig({
|
|
19
|
+
// ...
|
|
20
|
+
});
|
|
21
|
+
```
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### AnalysisResult
|
|
20
|
-
|
|
21
|
-
Complete analysis output used to build the documentation model.
|
|
23
|
+
## Public API
|
|
22
24
|
|
|
23
25
|
### defineParadoxConfig
|
|
24
26
|
|
|
@@ -26,24 +28,4 @@ Defines a Paradox configuration object without changing its shape.
|
|
|
26
28
|
|
|
27
29
|
### ParadoxConfig
|
|
28
30
|
|
|
29
|
-
Configuration for running Paradox
|
|
30
|
-
|
|
31
|
-
### buildModel
|
|
32
|
-
|
|
33
|
-
Converts analysis output into a serializable documentation model.
|
|
34
|
-
|
|
35
|
-
### DocumentationModel
|
|
36
|
-
|
|
37
|
-
Serializable model consumed by renderers and writers.
|
|
38
|
-
|
|
39
|
-
### render
|
|
40
|
-
|
|
41
|
-
Renders the documentation model into README and artifact files.
|
|
42
|
-
|
|
43
|
-
### RenderResult
|
|
44
|
-
|
|
45
|
-
Rendered documentation files ready to be written to disk.
|
|
46
|
-
|
|
47
|
-
### write
|
|
48
|
-
|
|
49
|
-
Writes generated documentation artifacts to the configured output paths.
|
|
31
|
+
Configuration for running Paradox.
|
package/package.json
CHANGED
package/paradox/exports.json
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
[
|
|
2
|
-
{
|
|
3
|
-
"name": "analyze",
|
|
4
|
-
"description": "Runs the source analysis pipeline for a configured package.",
|
|
5
|
-
"kind": "function"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"name": "AnalysisComponent",
|
|
9
|
-
"description": "Describes one React component and its extracted props.",
|
|
10
|
-
"kind": "type"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "AnalysisExport",
|
|
14
|
-
"description": "Describes one exported declaration discovered in a package.",
|
|
15
|
-
"kind": "type"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"name": "AnalysisResult",
|
|
19
|
-
"description": "Complete analysis output used to build the documentation model.",
|
|
20
|
-
"kind": "type"
|
|
21
|
-
},
|
|
22
2
|
{
|
|
23
3
|
"name": "defineParadoxConfig",
|
|
24
4
|
"description": "Defines a Paradox configuration object without changing its shape.",
|
|
@@ -26,32 +6,7 @@
|
|
|
26
6
|
},
|
|
27
7
|
{
|
|
28
8
|
"name": "ParadoxConfig",
|
|
29
|
-
"description": "Configuration for running Paradox
|
|
9
|
+
"description": "Configuration for running Paradox.",
|
|
30
10
|
"kind": "type"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "buildModel",
|
|
34
|
-
"description": "Converts analysis output into a serializable documentation model.",
|
|
35
|
-
"kind": "function"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "DocumentationModel",
|
|
39
|
-
"description": "Serializable model consumed by renderers and writers.",
|
|
40
|
-
"kind": "type"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"name": "render",
|
|
44
|
-
"description": "Renders the documentation model into README and artifact files.",
|
|
45
|
-
"kind": "function"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "RenderResult",
|
|
49
|
-
"description": "Rendered documentation files ready to be written to disk.",
|
|
50
|
-
"kind": "type"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"name": "write",
|
|
54
|
-
"description": "Writes generated documentation artifacts to the configured output paths.",
|
|
55
|
-
"kind": "function"
|
|
56
11
|
}
|
|
57
12
|
]
|
package/paradox/exports.md
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## analyze
|
|
4
|
-
|
|
5
|
-
Kind: `function`
|
|
6
|
-
|
|
7
|
-
Runs the source analysis pipeline for a configured package.
|
|
8
|
-
|
|
9
|
-
## AnalysisComponent
|
|
10
|
-
|
|
11
|
-
Kind: `type`
|
|
12
|
-
|
|
13
|
-
Describes one React component and its extracted props.
|
|
14
|
-
|
|
15
|
-
## AnalysisExport
|
|
16
|
-
|
|
17
|
-
Kind: `type`
|
|
18
|
-
|
|
19
|
-
Describes one exported declaration discovered in a package.
|
|
20
|
-
|
|
21
|
-
## AnalysisResult
|
|
22
|
-
|
|
23
|
-
Kind: `type`
|
|
24
|
-
|
|
25
|
-
Complete analysis output used to build the documentation model.
|
|
1
|
+
# Public API
|
|
26
2
|
|
|
27
3
|
## defineParadoxConfig
|
|
28
4
|
|
|
@@ -34,34 +10,4 @@ Defines a Paradox configuration object without changing its shape.
|
|
|
34
10
|
|
|
35
11
|
Kind: `type`
|
|
36
12
|
|
|
37
|
-
Configuration for running Paradox
|
|
38
|
-
|
|
39
|
-
## buildModel
|
|
40
|
-
|
|
41
|
-
Kind: `function`
|
|
42
|
-
|
|
43
|
-
Converts analysis output into a serializable documentation model.
|
|
44
|
-
|
|
45
|
-
## DocumentationModel
|
|
46
|
-
|
|
47
|
-
Kind: `type`
|
|
48
|
-
|
|
49
|
-
Serializable model consumed by renderers and writers.
|
|
50
|
-
|
|
51
|
-
## render
|
|
52
|
-
|
|
53
|
-
Kind: `function`
|
|
54
|
-
|
|
55
|
-
Renders the documentation model into README and artifact files.
|
|
56
|
-
|
|
57
|
-
## RenderResult
|
|
58
|
-
|
|
59
|
-
Kind: `type`
|
|
60
|
-
|
|
61
|
-
Rendered documentation files ready to be written to disk.
|
|
62
|
-
|
|
63
|
-
## write
|
|
64
|
-
|
|
65
|
-
Kind: `function`
|
|
66
|
-
|
|
67
|
-
Writes generated documentation artifacts to the configured output paths.
|
|
13
|
+
Configuration for running Paradox.
|
package/paradox/paradox.json
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@ankhorage/paradox",
|
|
3
|
+
"packageId": "@ankhorage/paradox",
|
|
3
4
|
"description": "Deterministic documentation generator for TypeScript packages.",
|
|
4
5
|
"exports": [
|
|
5
|
-
{
|
|
6
|
-
"name": "analyze",
|
|
7
|
-
"description": "Runs the source analysis pipeline for a configured package.",
|
|
8
|
-
"kind": "function"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "AnalysisComponent",
|
|
12
|
-
"description": "Describes one React component and its extracted props.",
|
|
13
|
-
"kind": "type"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"name": "AnalysisExport",
|
|
17
|
-
"description": "Describes one exported declaration discovered in a package.",
|
|
18
|
-
"kind": "type"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "AnalysisResult",
|
|
22
|
-
"description": "Complete analysis output used to build the documentation model.",
|
|
23
|
-
"kind": "type"
|
|
24
|
-
},
|
|
25
6
|
{
|
|
26
7
|
"name": "defineParadoxConfig",
|
|
27
8
|
"description": "Defines a Paradox configuration object without changing its shape.",
|
|
@@ -29,34 +10,17 @@
|
|
|
29
10
|
},
|
|
30
11
|
{
|
|
31
12
|
"name": "ParadoxConfig",
|
|
32
|
-
"description": "Configuration for running Paradox
|
|
13
|
+
"description": "Configuration for running Paradox.",
|
|
33
14
|
"kind": "type"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"name": "buildModel",
|
|
37
|
-
"description": "Converts analysis output into a serializable documentation model.",
|
|
38
|
-
"kind": "function"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"name": "DocumentationModel",
|
|
42
|
-
"description": "Serializable model consumed by renderers and writers.",
|
|
43
|
-
"kind": "type"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"name": "render",
|
|
47
|
-
"description": "Renders the documentation model into README and artifact files.",
|
|
48
|
-
"kind": "function"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"name": "RenderResult",
|
|
52
|
-
"description": "Rendered documentation files ready to be written to disk.",
|
|
53
|
-
"kind": "type"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"name": "write",
|
|
57
|
-
"description": "Writes generated documentation artifacts to the configured output paths.",
|
|
58
|
-
"kind": "function"
|
|
59
15
|
}
|
|
60
16
|
],
|
|
61
|
-
"components": []
|
|
17
|
+
"components": [],
|
|
18
|
+
"usage": {
|
|
19
|
+
"command": "bunx @ankhorage/paradox"
|
|
20
|
+
},
|
|
21
|
+
"config": {
|
|
22
|
+
"exportName": "ParadoxConfig",
|
|
23
|
+
"configFile": "paradox.config.ts",
|
|
24
|
+
"factoryName": "defineParadoxConfig"
|
|
25
|
+
}
|
|
62
26
|
}
|
package/src/analyze/analyze.ts
CHANGED
|
@@ -14,11 +14,16 @@ export async function analyze(config: ParadoxConfig): Promise<AnalysisResult> {
|
|
|
14
14
|
const root = config.package?.root ?? process.cwd();
|
|
15
15
|
|
|
16
16
|
const pkg = await readPackageJson(root);
|
|
17
|
+
const usage = pkg.bin
|
|
18
|
+
? {
|
|
19
|
+
command: `bunx ${pkg.name}`,
|
|
20
|
+
}
|
|
21
|
+
: null;
|
|
17
22
|
|
|
18
23
|
const project = createProject(root);
|
|
19
24
|
const entrypoints = config.package?.entrypoints ?? ['src/index.ts'];
|
|
20
25
|
|
|
21
|
-
const exports = analyzeExports(project, {
|
|
26
|
+
const { config: configMetadata, exports } = analyzeExports(project, {
|
|
22
27
|
root,
|
|
23
28
|
entrypoints,
|
|
24
29
|
});
|
|
@@ -26,21 +31,26 @@ export async function analyze(config: ParadoxConfig): Promise<AnalysisResult> {
|
|
|
26
31
|
|
|
27
32
|
return {
|
|
28
33
|
packageName: config.docs?.title ?? pkg.name,
|
|
34
|
+
packageId: pkg.name,
|
|
29
35
|
description: config.docs?.description ?? pkg.description ?? null,
|
|
30
36
|
|
|
31
37
|
exports,
|
|
32
38
|
components,
|
|
39
|
+
usage,
|
|
40
|
+
config: configMetadata,
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
async function readPackageJson(root: string): Promise<{
|
|
37
45
|
name: string;
|
|
38
46
|
description?: string;
|
|
47
|
+
bin?: string | Record<string, string>;
|
|
39
48
|
}> {
|
|
40
49
|
const raw = await readFile(join(root, 'package.json'), 'utf-8');
|
|
41
50
|
|
|
42
51
|
return JSON.parse(raw) as {
|
|
43
52
|
name: string;
|
|
44
53
|
description?: string;
|
|
54
|
+
bin?: string | Record<string, string>;
|
|
45
55
|
};
|
|
46
56
|
}
|
package/src/analyze/exports.ts
CHANGED
|
@@ -7,6 +7,13 @@ import { getParadoxComment } from './utils/getParadoxComment.js';
|
|
|
7
7
|
import { parseParadoxComment } from './utils/parseParadoxComment.js';
|
|
8
8
|
import { resolveExportSymbol } from './utils/resolveExportSymbol.js';
|
|
9
9
|
|
|
10
|
+
export interface AnalyzeExportsResult {
|
|
11
|
+
exports: AnalysisExport[];
|
|
12
|
+
config: {
|
|
13
|
+
exportName: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
/***
|
|
11
18
|
* Collects exported declarations from configured package entrypoints.
|
|
12
19
|
*/
|
|
@@ -16,8 +23,9 @@ export function analyzeExports(
|
|
|
16
23
|
root: string;
|
|
17
24
|
entrypoints: readonly string[];
|
|
18
25
|
},
|
|
19
|
-
):
|
|
26
|
+
): AnalyzeExportsResult {
|
|
20
27
|
const exports: AnalysisExport[] = [];
|
|
28
|
+
let config: AnalyzeExportsResult['config'] = null;
|
|
21
29
|
|
|
22
30
|
for (const sourceFile of getEntryPointSourceFiles(project, options)) {
|
|
23
31
|
const exported = sourceFile.getExportSymbols();
|
|
@@ -27,7 +35,15 @@ export function analyzeExports(
|
|
|
27
35
|
const [decl] = resolved.getDeclarations();
|
|
28
36
|
|
|
29
37
|
const rawComment = getParadoxComment(decl);
|
|
30
|
-
const parsed = rawComment
|
|
38
|
+
const parsed = rawComment
|
|
39
|
+
? parseParadoxComment(rawComment)
|
|
40
|
+
: { description: null, isConfig: false };
|
|
41
|
+
|
|
42
|
+
if (parsed.isConfig) {
|
|
43
|
+
config = {
|
|
44
|
+
exportName: resolved.getName(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
31
47
|
|
|
32
48
|
exports.push({
|
|
33
49
|
name: resolved.getName(),
|
|
@@ -38,7 +54,10 @@ export function analyzeExports(
|
|
|
38
54
|
}
|
|
39
55
|
}
|
|
40
56
|
|
|
41
|
-
return
|
|
57
|
+
return {
|
|
58
|
+
exports,
|
|
59
|
+
config,
|
|
60
|
+
};
|
|
42
61
|
}
|
|
43
62
|
|
|
44
63
|
function getEntryPointSourceFiles(
|
package/src/analyze/types.ts
CHANGED
|
@@ -29,8 +29,17 @@ export interface AnalysisComponent {
|
|
|
29
29
|
*/
|
|
30
30
|
export interface AnalysisResult {
|
|
31
31
|
packageName: string;
|
|
32
|
+
packageId: string;
|
|
32
33
|
description: string | null;
|
|
33
34
|
|
|
34
35
|
exports: AnalysisExport[];
|
|
35
36
|
components: AnalysisComponent[];
|
|
37
|
+
|
|
38
|
+
usage: {
|
|
39
|
+
command: string;
|
|
40
|
+
} | null;
|
|
41
|
+
|
|
42
|
+
config: {
|
|
43
|
+
exportName: string;
|
|
44
|
+
} | null;
|
|
36
45
|
}
|
|
@@ -3,21 +3,35 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface ParsedParadoxComment {
|
|
5
5
|
description: string | null;
|
|
6
|
+
isConfig: boolean;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
/***
|
|
9
10
|
* Parses a Paradox doc comment into structured metadata.
|
|
10
11
|
*/
|
|
11
12
|
export function parseParadoxComment(rawComment: string): ParsedParadoxComment {
|
|
12
|
-
const
|
|
13
|
+
const lines = rawComment
|
|
13
14
|
.replace(/^\/\*\*\*/, '')
|
|
14
15
|
.replace(/\*\/$/, '')
|
|
15
16
|
.split('\n')
|
|
16
|
-
.map((line) => line.replace(/^\s*\*\s?/, '').trimEnd())
|
|
17
|
+
.map((line) => line.replace(/^\s*\*\s?/, '').trimEnd());
|
|
18
|
+
|
|
19
|
+
let isConfig = false;
|
|
20
|
+
|
|
21
|
+
const description = lines
|
|
22
|
+
.filter((line) => {
|
|
23
|
+
if (line.trimStart().startsWith('@config')) {
|
|
24
|
+
isConfig = true;
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return true;
|
|
29
|
+
})
|
|
17
30
|
.join('\n')
|
|
18
31
|
.trim();
|
|
19
32
|
|
|
20
33
|
return {
|
|
21
|
-
description:
|
|
34
|
+
description: description.length > 0 ? description : null,
|
|
35
|
+
isConfig,
|
|
22
36
|
};
|
|
23
37
|
}
|
package/src/config/types.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export { analyze } from './analyze/analyze.js';
|
|
2
|
-
export type { AnalysisComponent, AnalysisExport, AnalysisResult } from './analyze/types.js';
|
|
3
1
|
export { defineParadoxConfig } from './config/defineParadoxConfig.js';
|
|
4
2
|
export type { ParadoxConfig } from './config/types.js';
|
|
5
|
-
export { buildModel } from './model/buildModel.js';
|
|
6
|
-
export type { DocumentationModel } from './model/types.js';
|
|
7
|
-
export { render } from './render/render.js';
|
|
8
|
-
export type { RenderResult } from './render/types.js';
|
|
9
|
-
export { write } from './write/write.js';
|
package/src/model/buildModel.ts
CHANGED
|
@@ -18,8 +18,29 @@ export function buildModel(analysis: AnalysisResult): DocumentationModel {
|
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
20
|
packageName: analysis.packageName,
|
|
21
|
+
packageId: analysis.packageId,
|
|
21
22
|
description: analysis.description,
|
|
22
23
|
exports: [...exportsByName.values()],
|
|
23
24
|
components: analysis.components,
|
|
25
|
+
usage: analysis.usage,
|
|
26
|
+
config:
|
|
27
|
+
analysis.config !== null
|
|
28
|
+
? {
|
|
29
|
+
exportName: analysis.config.exportName,
|
|
30
|
+
configFile: `${analysis.packageId.split('/').pop()}.config.ts`,
|
|
31
|
+
factoryName: findConfigFactoryName(analysis.config.exportName, [
|
|
32
|
+
...exportsByName.keys(),
|
|
33
|
+
]),
|
|
34
|
+
}
|
|
35
|
+
: null,
|
|
24
36
|
};
|
|
25
37
|
}
|
|
38
|
+
|
|
39
|
+
function findConfigFactoryName(configExportName: string, exportNames: string[]): string | null {
|
|
40
|
+
const prefix = configExportName.endsWith('Config')
|
|
41
|
+
? configExportName.slice(0, -'Config'.length)
|
|
42
|
+
: configExportName;
|
|
43
|
+
const expectedFactoryName = `define${prefix}Config`;
|
|
44
|
+
|
|
45
|
+
return exportNames.includes(expectedFactoryName) ? expectedFactoryName : null;
|
|
46
|
+
}
|
package/src/model/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { AnalysisComponent, AnalysisResult } from '../analyze/types.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export interface DocumentationModel {
|
|
7
7
|
packageName: string;
|
|
8
|
+
packageId: string;
|
|
8
9
|
description: string | null;
|
|
9
10
|
exports: {
|
|
10
11
|
name: string;
|
|
@@ -12,6 +13,14 @@ export interface DocumentationModel {
|
|
|
12
13
|
kind: string;
|
|
13
14
|
}[];
|
|
14
15
|
components: AnalysisComponent[];
|
|
16
|
+
usage: {
|
|
17
|
+
command: string;
|
|
18
|
+
} | null;
|
|
19
|
+
config: {
|
|
20
|
+
exportName: string;
|
|
21
|
+
configFile: string;
|
|
22
|
+
factoryName: string | null;
|
|
23
|
+
} | null;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
export type SerializableAnalysisResult = Omit<AnalysisResult, 'exports'> & {
|
package/src/render/render.ts
CHANGED
|
@@ -21,8 +21,39 @@ function renderReadme(model: DocumentationModel): string {
|
|
|
21
21
|
lines.push(model.description, '');
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
if (model.usage !== null) {
|
|
25
|
+
lines.push('## Usage', '');
|
|
26
|
+
lines.push('```bash');
|
|
27
|
+
lines.push(model.usage.command);
|
|
28
|
+
lines.push('```', '');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (model.config !== null) {
|
|
32
|
+
lines.push('## Configuration', '');
|
|
33
|
+
lines.push(`Create a \`${model.config.configFile}\` file:`, '');
|
|
34
|
+
lines.push('```ts');
|
|
35
|
+
|
|
36
|
+
if (model.config.factoryName !== null) {
|
|
37
|
+
lines.push(`import { ${model.config.factoryName} } from '${model.packageId}';`);
|
|
38
|
+
lines.push('');
|
|
39
|
+
lines.push(`export default ${model.config.factoryName}({`);
|
|
40
|
+
lines.push(' // ...');
|
|
41
|
+
lines.push('});');
|
|
42
|
+
} else {
|
|
43
|
+
lines.push(`import type { ${model.config.exportName} } from '${model.packageId}';`);
|
|
44
|
+
lines.push('');
|
|
45
|
+
lines.push('const config = {');
|
|
46
|
+
lines.push(' // ...');
|
|
47
|
+
lines.push(`} satisfies ${model.config.exportName};`);
|
|
48
|
+
lines.push('');
|
|
49
|
+
lines.push('export default config;');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
lines.push('```', '');
|
|
53
|
+
}
|
|
54
|
+
|
|
24
55
|
if (model.exports.length > 0) {
|
|
25
|
-
lines.push('##
|
|
56
|
+
lines.push('## Public API', '');
|
|
26
57
|
|
|
27
58
|
for (const item of model.exports) {
|
|
28
59
|
lines.push(`### ${item.name}`, '');
|
|
@@ -34,7 +65,7 @@ function renderReadme(model: DocumentationModel): string {
|
|
|
34
65
|
}
|
|
35
66
|
|
|
36
67
|
function renderExports(model: DocumentationModel): string {
|
|
37
|
-
const lines = ['#
|
|
68
|
+
const lines = ['# Public API', ''];
|
|
38
69
|
|
|
39
70
|
for (const item of model.exports) {
|
|
40
71
|
lines.push(`## ${item.name}`, '');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Public API
|
|
2
2
|
|
|
3
3
|
## Button
|
|
4
4
|
|
|
@@ -6,6 +6,12 @@ Kind: `function`
|
|
|
6
6
|
|
|
7
7
|
Renders the fixture button component.
|
|
8
8
|
|
|
9
|
+
## ToolConfig
|
|
10
|
+
|
|
11
|
+
Kind: `type`
|
|
12
|
+
|
|
13
|
+
Configuration for the fixture package.
|
|
14
|
+
|
|
9
15
|
## ButtonProps
|
|
10
16
|
|
|
11
17
|
Kind: `type`
|
|
@@ -2,12 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Generated fixture docs.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx @fixture/basic
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
Create a `basic.config.ts` file:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import type { ToolConfig } from '@fixture/basic';
|
|
17
|
+
|
|
18
|
+
const config = {
|
|
19
|
+
// ...
|
|
20
|
+
} satisfies ToolConfig;
|
|
21
|
+
|
|
22
|
+
export default config;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Public API
|
|
6
26
|
|
|
7
27
|
### Button
|
|
8
28
|
|
|
9
29
|
Renders the fixture button component.
|
|
10
30
|
|
|
31
|
+
### ToolConfig
|
|
32
|
+
|
|
33
|
+
Configuration for the fixture package.
|
|
34
|
+
|
|
11
35
|
### ButtonProps
|
|
12
36
|
|
|
13
37
|
Props accepted by the fixture button.
|
package/tests/analyze.test.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { join } from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
import { describe, expect, test } from 'bun:test';
|
|
5
5
|
|
|
6
|
-
import { analyze
|
|
6
|
+
import { analyze } from '../src/analyze/analyze.js';
|
|
7
|
+
import { buildModel } from '../src/model/buildModel.js';
|
|
8
|
+
import { render } from '../src/render/render.js';
|
|
7
9
|
|
|
8
10
|
const fixtureRoot = join(import.meta.dir, 'fixtures/basic');
|
|
9
11
|
const snapshotRoot = join(import.meta.dir, '__snapshots__');
|
|
@@ -21,8 +23,18 @@ describe('analyze', () => {
|
|
|
21
23
|
},
|
|
22
24
|
});
|
|
23
25
|
|
|
24
|
-
expect(analysis.exports.map((item) => item.name)).toEqual([
|
|
26
|
+
expect(analysis.exports.map((item) => item.name)).toEqual([
|
|
27
|
+
'Button',
|
|
28
|
+
'ToolConfig',
|
|
29
|
+
'ButtonProps',
|
|
30
|
+
]);
|
|
25
31
|
expect(analysis.exports.map((item) => item.name)).not.toContain('internalHelper');
|
|
32
|
+
expect(analysis.usage).toEqual({
|
|
33
|
+
command: 'bunx @fixture/basic',
|
|
34
|
+
});
|
|
35
|
+
expect(analysis.config).toEqual({
|
|
36
|
+
exportName: 'ToolConfig',
|
|
37
|
+
});
|
|
26
38
|
|
|
27
39
|
expect(analysis.components).toEqual([
|
|
28
40
|
{
|