@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.
Files changed (85) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/analyze/analyze.d.ts +6 -0
  3. package/dist/analyze/analyze.js +34 -0
  4. package/dist/analyze/components.d.ts +5 -0
  5. package/dist/analyze/components.js +21 -0
  6. package/dist/analyze/exports.d.ts +16 -0
  7. package/dist/analyze/exports.js +52 -0
  8. package/dist/analyze/project.d.ts +5 -0
  9. package/dist/analyze/project.js +10 -0
  10. package/dist/analyze/types.d.ts +45 -0
  11. package/dist/analyze/types.js +1 -0
  12. package/dist/analyze/usage.d.ts +7 -0
  13. package/dist/analyze/usage.js +40 -0
  14. package/dist/analyze/utils/getComponentPropsType.d.ts +5 -0
  15. package/dist/analyze/utils/getComponentPropsType.js +21 -0
  16. package/dist/analyze/utils/getParadoxComment.d.ts +5 -0
  17. package/dist/analyze/utils/getParadoxComment.js +19 -0
  18. package/dist/analyze/utils/getPropsFromType.d.ts +6 -0
  19. package/dist/analyze/utils/getPropsFromType.js +19 -0
  20. package/dist/analyze/utils/isReactComponent.d.ts +5 -0
  21. package/dist/analyze/utils/isReactComponent.js +30 -0
  22. package/dist/analyze/utils/parseParadoxComment.d.ts +12 -0
  23. package/dist/analyze/utils/parseParadoxComment.js +25 -0
  24. package/{src/analyze/utils/resolveExportSymbol.ts → dist/analyze/utils/resolveExportSymbol.d.ts} +1 -4
  25. package/dist/analyze/utils/resolveExportSymbol.js +6 -0
  26. package/dist/cli.d.ts +2 -0
  27. package/dist/cli.js +23 -0
  28. package/{src/config/defineParadoxConfig.ts → dist/config/defineParadoxConfig.d.ts} +1 -4
  29. package/dist/config/defineParadoxConfig.js +6 -0
  30. package/dist/config/types.d.ts +19 -0
  31. package/dist/config/types.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/model/buildModel.d.ts +36 -0
  34. package/dist/model/buildModel.js +65 -0
  35. package/dist/model/types.d.ts +42 -0
  36. package/dist/model/types.js +1 -0
  37. package/dist/render/render.d.ts +6 -0
  38. package/dist/render/render.js +88 -0
  39. package/dist/render/types.d.ts +10 -0
  40. package/dist/render/types.js +1 -0
  41. package/dist/write/write.d.ts +6 -0
  42. package/dist/write/write.js +18 -0
  43. package/package.json +27 -3
  44. package/.changeset/README.md +0 -5
  45. package/.changeset/config.json +0 -11
  46. package/.github/workflows/docs.yml +0 -45
  47. package/.prettierignore +0 -1
  48. package/.prettierrc.js +0 -5
  49. package/bun.lock +0 -663
  50. package/eslint.config.mjs +0 -12
  51. package/paradox/components.md +0 -1
  52. package/paradox/exports.json +0 -12
  53. package/paradox/exports.md +0 -13
  54. package/paradox/paradox.json +0 -26
  55. package/paradox.config.ts +0 -18
  56. package/src/analyze/analyze.ts +0 -56
  57. package/src/analyze/components.ts +0 -27
  58. package/src/analyze/exports.ts +0 -87
  59. package/src/analyze/project.ts +0 -11
  60. package/src/analyze/types.ts +0 -45
  61. package/src/analyze/utils/getComponentPropsType.ts +0 -26
  62. package/src/analyze/utils/getParadoxComment.ts +0 -24
  63. package/src/analyze/utils/getPropsFromType.ts +0 -24
  64. package/src/analyze/utils/isReactComponent.ts +0 -35
  65. package/src/analyze/utils/parseParadoxComment.ts +0 -37
  66. package/src/cli.ts +0 -30
  67. package/src/config/types.ts +0 -22
  68. package/src/model/buildModel.ts +0 -46
  69. package/src/model/types.ts +0 -28
  70. package/src/render/render.ts +0 -113
  71. package/src/render/types.ts +0 -10
  72. package/src/write/write.ts +0 -25
  73. package/tests/__snapshots__/basic.components.md +0 -10
  74. package/tests/__snapshots__/basic.exports.md +0 -19
  75. package/tests/__snapshots__/basic.readme.md +0 -37
  76. package/tests/analyze.test.ts +0 -72
  77. package/tests/fixtures/basic/package.json +0 -8
  78. package/tests/fixtures/basic/src/config.ts +0 -8
  79. package/tests/fixtures/basic/src/index.ts +0 -3
  80. package/tests/fixtures/basic/src/internal.ts +0 -6
  81. package/tests/fixtures/basic/src/ui.ts +0 -29
  82. package/tests/fixtures/basic/tsconfig.json +0 -11
  83. package/tsconfig.eslint.json +0 -16
  84. package/tsconfig.json +0 -14
  85. /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,6 @@
1
+ import type { DocumentationModel } from '../model/types.js';
2
+ import type { RenderResult } from './types.js';
3
+ /***
4
+ * Renders the documentation model into README and artifact files.
5
+ */
6
+ export declare function render(model: DocumentationModel): RenderResult;
@@ -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,10 @@
1
+ /***
2
+ * Rendered documentation files ready to be written to disk.
3
+ */
4
+ export interface RenderResult {
5
+ readme: string;
6
+ exportsMarkdown: string;
7
+ components: string;
8
+ exportsJson: string;
9
+ paradoxJson: string;
10
+ }
@@ -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.1",
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": "./src/cli.ts"
34
+ "paradox": "./dist/cli.js"
12
35
  },
13
36
  "scripts": {
14
- "build": "tsc --noEmit",
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"
@@ -1,5 +0,0 @@
1
- # Changesets
2
-
3
- This directory stores release notes consumed by Changesets.
4
-
5
- Run `bun run changeset` to create a new changeset before publishing a package change.
@@ -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
package/.prettierrc.js DELETED
@@ -1,5 +0,0 @@
1
- import { createRequire } from 'node:module';
2
-
3
- const require = createRequire(import.meta.url);
4
-
5
- export default require('@ankhorage/devtools/prettier');