@ankhorage/paradox 0.0.1 → 0.0.3
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/dist/analyze/analyze.d.ts +6 -0
- package/dist/analyze/analyze.js +34 -0
- package/dist/analyze/components.d.ts +5 -0
- package/dist/analyze/components.js +21 -0
- package/dist/analyze/exports.d.ts +16 -0
- package/dist/analyze/exports.js +52 -0
- package/dist/analyze/project.d.ts +5 -0
- package/dist/analyze/project.js +10 -0
- package/dist/analyze/types.d.ts +45 -0
- package/dist/analyze/types.js +1 -0
- package/dist/analyze/usage.d.ts +7 -0
- package/dist/analyze/usage.js +40 -0
- package/dist/analyze/utils/getComponentPropsType.d.ts +5 -0
- package/dist/analyze/utils/getComponentPropsType.js +21 -0
- package/dist/analyze/utils/getParadoxComment.d.ts +5 -0
- package/dist/analyze/utils/getParadoxComment.js +19 -0
- package/dist/analyze/utils/getPropsFromType.d.ts +6 -0
- package/dist/analyze/utils/getPropsFromType.js +19 -0
- package/dist/analyze/utils/isReactComponent.d.ts +5 -0
- package/dist/analyze/utils/isReactComponent.js +30 -0
- package/dist/analyze/utils/parseParadoxComment.d.ts +12 -0
- package/dist/analyze/utils/parseParadoxComment.js +25 -0
- package/{src/analyze/utils/resolveExportSymbol.ts → dist/analyze/utils/resolveExportSymbol.d.ts} +1 -4
- package/dist/analyze/utils/resolveExportSymbol.js +6 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +23 -0
- package/{src/config/defineParadoxConfig.ts → dist/config/defineParadoxConfig.d.ts} +1 -4
- package/dist/config/defineParadoxConfig.js +6 -0
- package/dist/config/types.d.ts +19 -0
- package/dist/config/types.js +1 -0
- package/dist/index.js +1 -0
- package/dist/model/buildModel.d.ts +36 -0
- package/dist/model/buildModel.js +65 -0
- package/dist/model/types.d.ts +42 -0
- package/dist/model/types.js +1 -0
- package/dist/render/render.d.ts +6 -0
- package/dist/render/render.js +88 -0
- package/dist/render/types.d.ts +10 -0
- package/dist/render/types.js +1 -0
- package/dist/write/write.d.ts +6 -0
- package/dist/write/write.js +18 -0
- package/package.json +27 -3
- package/.changeset/README.md +0 -5
- package/.changeset/config.json +0 -11
- package/.github/workflows/docs.yml +0 -45
- package/.prettierignore +0 -1
- package/.prettierrc.js +0 -5
- package/bun.lock +0 -663
- package/eslint.config.mjs +0 -12
- package/paradox/components.md +0 -1
- package/paradox/exports.json +0 -12
- package/paradox/exports.md +0 -13
- package/paradox/paradox.json +0 -26
- package/paradox.config.ts +0 -18
- package/src/analyze/analyze.ts +0 -56
- package/src/analyze/components.ts +0 -27
- package/src/analyze/exports.ts +0 -87
- package/src/analyze/project.ts +0 -11
- package/src/analyze/types.ts +0 -45
- package/src/analyze/utils/getComponentPropsType.ts +0 -26
- package/src/analyze/utils/getParadoxComment.ts +0 -24
- package/src/analyze/utils/getPropsFromType.ts +0 -24
- package/src/analyze/utils/isReactComponent.ts +0 -35
- package/src/analyze/utils/parseParadoxComment.ts +0 -37
- package/src/cli.ts +0 -30
- package/src/config/types.ts +0 -22
- package/src/model/buildModel.ts +0 -46
- package/src/model/types.ts +0 -28
- package/src/render/render.ts +0 -113
- package/src/render/types.ts +0 -10
- package/src/write/write.ts +0 -25
- package/tests/__snapshots__/basic.components.md +0 -10
- package/tests/__snapshots__/basic.exports.md +0 -19
- package/tests/__snapshots__/basic.readme.md +0 -37
- package/tests/analyze.test.ts +0 -72
- package/tests/fixtures/basic/package.json +0 -8
- package/tests/fixtures/basic/src/config.ts +0 -8
- package/tests/fixtures/basic/src/index.ts +0 -3
- package/tests/fixtures/basic/src/internal.ts +0 -6
- package/tests/fixtures/basic/src/ui.ts +0 -29
- package/tests/fixtures/basic/tsconfig.json +0 -11
- package/tsconfig.eslint.json +0 -16
- package/tsconfig.json +0 -14
- /package/{src/index.ts → dist/index.d.ts} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Serializable model consumed by renderers and writers.
|
|
3
|
+
*/
|
|
4
|
+
export interface DocumentationModel {
|
|
5
|
+
packageName: string;
|
|
6
|
+
packageId: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
usage: UsageModel | null;
|
|
9
|
+
config: ConfigModel | null;
|
|
10
|
+
exports: ExportModel[];
|
|
11
|
+
components: ComponentModel[];
|
|
12
|
+
}
|
|
13
|
+
export interface UsageModel {
|
|
14
|
+
packageName: string;
|
|
15
|
+
commands: UsageCommandModel[];
|
|
16
|
+
}
|
|
17
|
+
export interface UsageCommandModel {
|
|
18
|
+
name: string;
|
|
19
|
+
command: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ConfigModel {
|
|
22
|
+
exportName: string;
|
|
23
|
+
configFile: string;
|
|
24
|
+
factoryName: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ExportModel {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string | null;
|
|
29
|
+
kind: ExportKind;
|
|
30
|
+
}
|
|
31
|
+
export type ExportKind = 'function' | 'type' | 'unknown';
|
|
32
|
+
export interface ComponentModel {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string | null;
|
|
35
|
+
props: PropModel[];
|
|
36
|
+
}
|
|
37
|
+
export interface PropModel {
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
required: boolean;
|
|
41
|
+
description: string | null;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Renders the documentation model into README and artifact files.
|
|
3
|
+
*/
|
|
4
|
+
export function render(model) {
|
|
5
|
+
return {
|
|
6
|
+
readme: renderReadme(model),
|
|
7
|
+
exportsMarkdown: renderExports(model),
|
|
8
|
+
components: renderComponents(model),
|
|
9
|
+
exportsJson: `${JSON.stringify(model.exports, null, 2)}\n`,
|
|
10
|
+
paradoxJson: `${JSON.stringify(model, null, 2)}\n`,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function renderReadme(model) {
|
|
14
|
+
const lines = [`# ${model.packageName}`, ''];
|
|
15
|
+
if (model.description) {
|
|
16
|
+
lines.push(model.description, '');
|
|
17
|
+
}
|
|
18
|
+
if (model.usage !== null) {
|
|
19
|
+
lines.push('## Usage', '');
|
|
20
|
+
lines.push('```bash');
|
|
21
|
+
for (const command of model.usage.commands) {
|
|
22
|
+
lines.push(command.command);
|
|
23
|
+
}
|
|
24
|
+
lines.push('```', '');
|
|
25
|
+
}
|
|
26
|
+
if (model.config !== null) {
|
|
27
|
+
lines.push('## Configuration', '');
|
|
28
|
+
lines.push(`Create a \`${model.config.configFile}\` file:`, '');
|
|
29
|
+
lines.push('```ts');
|
|
30
|
+
if (model.config.factoryName !== null) {
|
|
31
|
+
lines.push(`import { ${model.config.factoryName} } from '${model.packageId}';`);
|
|
32
|
+
lines.push('');
|
|
33
|
+
lines.push(`export default ${model.config.factoryName}({`);
|
|
34
|
+
lines.push(' // ...');
|
|
35
|
+
lines.push('});');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
lines.push(`import type { ${model.config.exportName} } from '${model.packageId}';`);
|
|
39
|
+
lines.push('');
|
|
40
|
+
lines.push('const config = {');
|
|
41
|
+
lines.push(' // ...');
|
|
42
|
+
lines.push(`} satisfies ${model.config.exportName};`);
|
|
43
|
+
lines.push('');
|
|
44
|
+
lines.push('export default config;');
|
|
45
|
+
}
|
|
46
|
+
lines.push('```', '');
|
|
47
|
+
}
|
|
48
|
+
if (model.exports.length > 0) {
|
|
49
|
+
lines.push('## Public API', '');
|
|
50
|
+
for (const item of model.exports) {
|
|
51
|
+
lines.push(`### ${item.name}`, '');
|
|
52
|
+
lines.push(item.description ?? `\`${item.kind}\` export.`, '');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return `${lines.join('\n').trimEnd()}\n`;
|
|
56
|
+
}
|
|
57
|
+
function renderExports(model) {
|
|
58
|
+
const lines = ['# Public API', ''];
|
|
59
|
+
for (const item of model.exports) {
|
|
60
|
+
lines.push(`## ${item.name}`, '');
|
|
61
|
+
lines.push(`Kind: \`${item.kind}\``, '');
|
|
62
|
+
if (item.description) {
|
|
63
|
+
lines.push(item.description, '');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return `${lines.join('\n').trimEnd()}\n`;
|
|
67
|
+
}
|
|
68
|
+
function renderComponents(model) {
|
|
69
|
+
const lines = ['# Components', ''];
|
|
70
|
+
for (const component of model.components) {
|
|
71
|
+
lines.push(`## ${component.name}`, '');
|
|
72
|
+
if (component.description) {
|
|
73
|
+
lines.push(component.description, '');
|
|
74
|
+
}
|
|
75
|
+
if (component.props.length > 0) {
|
|
76
|
+
lines.push('| Prop | Type | Required | Description |');
|
|
77
|
+
lines.push('| --- | --- | --- | --- |');
|
|
78
|
+
for (const prop of component.props) {
|
|
79
|
+
lines.push(`| ${escapeTableCell(prop.name)} | \`${escapeTableCell(prop.type)}\` | ${prop.required ? 'yes' : 'no'} | ${escapeTableCell(prop.description ?? '')} |`);
|
|
80
|
+
}
|
|
81
|
+
lines.push('');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return `${lines.join('\n').trimEnd()}\n`;
|
|
85
|
+
}
|
|
86
|
+
function escapeTableCell(value) {
|
|
87
|
+
return value.replaceAll('|', '\\|');
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ParadoxConfig } from '../config/types.js';
|
|
2
|
+
import type { RenderResult } from '../render/types.js';
|
|
3
|
+
/***
|
|
4
|
+
* Writes generated documentation artifacts to the configured output paths.
|
|
5
|
+
*/
|
|
6
|
+
export declare function write(result: RenderResult, config: ParadoxConfig): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/***
|
|
4
|
+
* Writes generated documentation artifacts to the configured output paths.
|
|
5
|
+
*/
|
|
6
|
+
export async function write(result, config) {
|
|
7
|
+
const root = config.package?.root ?? process.cwd();
|
|
8
|
+
const outputDir = config.output?.dir ?? 'paradox';
|
|
9
|
+
const mode = config.mode ?? 'safe';
|
|
10
|
+
await mkdir(join(root, outputDir), { recursive: true });
|
|
11
|
+
await writeFile(join(root, outputDir, 'exports.md'), result.exportsMarkdown);
|
|
12
|
+
await writeFile(join(root, outputDir, 'components.md'), result.components);
|
|
13
|
+
await writeFile(join(root, outputDir, 'exports.json'), result.exportsJson);
|
|
14
|
+
await writeFile(join(root, outputDir, 'paradox.json'), result.paradoxJson);
|
|
15
|
+
if (mode === 'write') {
|
|
16
|
+
await writeFile(join(root, 'README.md'), result.readme);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/paradox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Deterministic documentation generator for TypeScript packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
+
"homepage": "https://github.com/ankhorage/paradox#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/ankhorage/paradox/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/ankhorage/paradox.git"
|
|
16
|
+
},
|
|
9
17
|
"type": "module",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"CHANGELOG.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
10
33
|
"bin": {
|
|
11
|
-
"paradox": "./
|
|
34
|
+
"paradox": "./dist/cli.js"
|
|
12
35
|
},
|
|
13
36
|
"scripts": {
|
|
14
|
-
"build": "tsc
|
|
37
|
+
"build": "tsc -p tsconfig.build.json",
|
|
15
38
|
"changeset": "changeset",
|
|
16
39
|
"changeset:status": "changeset status --since=origin/main",
|
|
17
40
|
"docs": "bun src/cli.ts",
|
|
@@ -20,6 +43,7 @@
|
|
|
20
43
|
"format:check": "prettier --check .",
|
|
21
44
|
"lint": "eslint . --max-warnings=0",
|
|
22
45
|
"lint:fix": "eslint . --fix --max-warnings=0",
|
|
46
|
+
"prepack": "bun run build",
|
|
23
47
|
"test": "bun test",
|
|
24
48
|
"typecheck": "bun x tsc --noEmit -p tsconfig.json",
|
|
25
49
|
"version-packages": "changeset version"
|
package/.changeset/README.md
DELETED
package/.changeset/config.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json",
|
|
3
|
-
"changelog": "@changesets/cli/changelog",
|
|
4
|
-
"commit": false,
|
|
5
|
-
"fixed": [],
|
|
6
|
-
"linked": [],
|
|
7
|
-
"access": "public",
|
|
8
|
-
"baseBranch": "main",
|
|
9
|
-
"updateInternalDependencies": "patch",
|
|
10
|
-
"ignore": []
|
|
11
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
push:
|
|
6
|
-
branches:
|
|
7
|
-
- main
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
validate:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- name: Checkout repository
|
|
15
|
-
uses: actions/checkout@v4
|
|
16
|
-
|
|
17
|
-
- name: Setup Bun
|
|
18
|
-
uses: oven-sh/setup-bun@v2
|
|
19
|
-
with:
|
|
20
|
-
bun-version: '1.3.11'
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: bun install --frozen-lockfile
|
|
24
|
-
|
|
25
|
-
- name: Run lint
|
|
26
|
-
run: bun run lint
|
|
27
|
-
|
|
28
|
-
- name: Check formatting
|
|
29
|
-
run: bun run format:check
|
|
30
|
-
|
|
31
|
-
- name: Run typecheck
|
|
32
|
-
run: bun run typecheck
|
|
33
|
-
|
|
34
|
-
- name: Run tests
|
|
35
|
-
run: bun run test
|
|
36
|
-
|
|
37
|
-
- name: Check changesets
|
|
38
|
-
if: github.event_name == 'pull_request'
|
|
39
|
-
run: bun run changeset:status
|
|
40
|
-
|
|
41
|
-
- name: Generate docs
|
|
42
|
-
run: bun run docs
|
|
43
|
-
|
|
44
|
-
- name: Check generated docs
|
|
45
|
-
run: git diff --exit-code
|
package/.prettierignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
tests/__snapshots__/*.md
|