@ankhorage/paradox 0.0.9 → 0.1.0

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 (46) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +117 -13
  3. package/dist/analyze/analyze.d.ts +0 -3
  4. package/dist/analyze/analyze.js +47 -13
  5. package/dist/analyze/components.d.ts +4 -1
  6. package/dist/analyze/components.js +16 -2
  7. package/dist/analyze/exports.d.ts +1 -0
  8. package/dist/analyze/exports.js +16 -3
  9. package/dist/analyze/semantic/analyzeProject.d.ts +10 -0
  10. package/dist/analyze/semantic/analyzeProject.js +62 -0
  11. package/dist/analyze/semantic/associateDocBlocksWithSymbols.d.ts +5 -0
  12. package/dist/analyze/semantic/associateDocBlocksWithSymbols.js +51 -0
  13. package/dist/analyze/semantic/collectSourceFiles.d.ts +5 -0
  14. package/dist/analyze/semantic/collectSourceFiles.js +22 -0
  15. package/dist/analyze/semantic/createTypeScriptProgram.d.ts +13 -0
  16. package/dist/analyze/semantic/createTypeScriptProgram.js +23 -0
  17. package/dist/analyze/semantic/docBlocks.d.ts +10 -0
  18. package/dist/analyze/semantic/docBlocks.js +102 -0
  19. package/dist/analyze/semantic/exports.d.ts +29 -0
  20. package/dist/analyze/semantic/exports.js +399 -0
  21. package/dist/analyze/semantic/graphs.d.ts +13 -0
  22. package/dist/analyze/semantic/graphs.js +151 -0
  23. package/dist/analyze/semantic/isReactComponent.d.ts +5 -0
  24. package/dist/analyze/semantic/isReactComponent.js +30 -0
  25. package/dist/analyze/semantic/model.d.ts +109 -0
  26. package/dist/analyze/semantic/model.js +1 -0
  27. package/dist/analyze/semantic/paradoxComment.d.ts +16 -0
  28. package/dist/analyze/semantic/paradoxComment.js +64 -0
  29. package/dist/analyze/semantic/tagRegistry.d.ts +2 -0
  30. package/dist/analyze/semantic/tagRegistry.js +1 -0
  31. package/dist/analyze/semantic/utils.d.ts +4 -0
  32. package/dist/analyze/semantic/utils.js +13 -0
  33. package/dist/analyze/types.d.ts +55 -1
  34. package/dist/analyze/utils/parseParadoxComment.d.ts +7 -0
  35. package/dist/analyze/utils/parseParadoxComment.js +61 -14
  36. package/dist/config/defineParadoxConfig.d.ts +2 -0
  37. package/dist/config/defineParadoxConfig.js +2 -0
  38. package/dist/config/types.d.ts +1 -0
  39. package/dist/model/buildModel.d.ts +56 -7
  40. package/dist/model/buildModel.js +16 -0
  41. package/dist/model/types.d.ts +62 -8
  42. package/dist/paths/policy.d.ts +0 -15
  43. package/dist/paths/policy.js +0 -9
  44. package/dist/render/renderers/diagrams.js +11 -0
  45. package/dist/render/renderers/markdown.js +235 -39
  46. package/package.json +15 -6
@@ -0,0 +1,5 @@
1
+ import { Node } from 'ts-morph';
2
+ /***
3
+ * Detects simple React component declarations by name and return type.
4
+ */
5
+ export declare function isReactComponent(node: Node): boolean;
@@ -0,0 +1,30 @@
1
+ import { Node } from 'ts-morph';
2
+ /***
3
+ * Detects simple React component declarations by name and return type.
4
+ */
5
+ export function isReactComponent(node) {
6
+ const name = getDeclarationName(node);
7
+ if (!name || !/^[A-Z]/.test(name))
8
+ return false;
9
+ const callSignature = getCallSignature(node);
10
+ const returnType = callSignature?.getReturnType().getText() ?? null;
11
+ if (returnType === null)
12
+ return false;
13
+ return /JSX\.Element|ReactElement|ReactNode|Element/.test(returnType);
14
+ }
15
+ function getDeclarationName(node) {
16
+ if (Node.isFunctionDeclaration(node))
17
+ return node.getName() ?? null;
18
+ if (Node.isVariableDeclaration(node))
19
+ return node.getName();
20
+ return null;
21
+ }
22
+ function getCallSignature(node) {
23
+ if (Node.isFunctionDeclaration(node)) {
24
+ return node.getType().getCallSignatures()[0] ?? null;
25
+ }
26
+ if (Node.isVariableDeclaration(node)) {
27
+ return node.getType().getCallSignatures()[0] ?? null;
28
+ }
29
+ return null;
30
+ }
@@ -0,0 +1,109 @@
1
+ import type { Node, Project, SourceFile, Symbol, Type, TypeChecker } from 'ts-morph';
2
+ export interface AnalyzedProgram {
3
+ project: Project;
4
+ typeChecker: TypeChecker;
5
+ root: string;
6
+ entrypoints: string[];
7
+ entrypointFilePaths: string[];
8
+ }
9
+ export interface AnalyzedFile {
10
+ path: string;
11
+ sourceFile: SourceFile;
12
+ isEntrypoint: boolean;
13
+ }
14
+ export interface AnalyzedDocBlock {
15
+ id: string;
16
+ sourcePath: string;
17
+ start: number;
18
+ end: number;
19
+ line: number;
20
+ column: number;
21
+ raw: string;
22
+ description: string | null;
23
+ params: Record<string, string>;
24
+ returns: string | null;
25
+ tags: AnalyzedTag[];
26
+ }
27
+ export interface AnalyzedTag {
28
+ name: string;
29
+ value: string | null;
30
+ }
31
+ export type AnalyzedExportKind = 'function' | 'component' | 'class' | 'interface' | 'type' | 'const' | 'hook' | 'unknown';
32
+ export interface AnalyzedExport {
33
+ name: string;
34
+ sourcePath: string;
35
+ exportPaths: string[];
36
+ kind: AnalyzedExportKind;
37
+ signature?: string;
38
+ docBlock?: AnalyzedDocBlock;
39
+ tags: AnalyzedTag[];
40
+ props?: AnalyzedProps;
41
+ typeMembers?: AnalyzedTypeMember[];
42
+ relatedTypes: string[];
43
+ node: Node;
44
+ symbol: Symbol;
45
+ }
46
+ export interface ResolvedTypeReference {
47
+ type: Type;
48
+ name: string | null;
49
+ sourcePath: string | null;
50
+ symbol: Symbol | null;
51
+ }
52
+ export interface AnalyzedProps {
53
+ typeName: string;
54
+ sourcePath: string | null;
55
+ members: AnalyzedProp[];
56
+ }
57
+ export interface AnalyzedProp {
58
+ name: string;
59
+ type: string;
60
+ required: boolean;
61
+ defaultValue?: string;
62
+ description?: string;
63
+ inheritedFrom?: string;
64
+ }
65
+ export interface AnalyzedTypeMember {
66
+ name: string;
67
+ type: string;
68
+ required: boolean;
69
+ description?: string;
70
+ defaultValue?: string;
71
+ inheritedFrom?: string;
72
+ children?: AnalyzedTypeMember[];
73
+ }
74
+ export interface ImportEdge {
75
+ fromPath: string;
76
+ toPath: string;
77
+ sourcePath: string;
78
+ }
79
+ export interface CallEdge {
80
+ fromSymbol: string;
81
+ toSymbol: string;
82
+ callExpression: string;
83
+ sourcePath: string;
84
+ }
85
+ interface TypeReferenceEdge {
86
+ fromSymbol: string;
87
+ toType: string;
88
+ sourcePath: string;
89
+ }
90
+ export interface ComponentCompositionEdge {
91
+ fromComponent: string;
92
+ toComponent: string;
93
+ jsxElement: string;
94
+ sourcePath: string;
95
+ }
96
+ interface AnalyzedGraphs {
97
+ imports: ImportEdge[];
98
+ calls: CallEdge[];
99
+ typeReferences: TypeReferenceEdge[];
100
+ componentComposition: ComponentCompositionEdge[];
101
+ }
102
+ export interface AnalyzedProject {
103
+ files: AnalyzedFile[];
104
+ exports: AnalyzedExport[];
105
+ docBlocks: AnalyzedDocBlock[];
106
+ tags: AnalyzedTag[];
107
+ graphs: AnalyzedGraphs;
108
+ }
109
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { Node } from 'ts-morph';
2
+ /***
3
+ * Reads the nearest Paradox doc comment attached to a declaration.
4
+ */
5
+ export declare function getParadoxComment(node: Node | undefined): string | null;
6
+ interface ParsedParadoxComment {
7
+ description: string | null;
8
+ isConfig: boolean;
9
+ params: Record<string, string>;
10
+ returns: string | null;
11
+ }
12
+ /***
13
+ * Parses a Paradox doc comment into structured metadata.
14
+ */
15
+ export declare function parseParadoxComment(rawComment: string): ParsedParadoxComment;
16
+ export {};
@@ -0,0 +1,64 @@
1
+ /***
2
+ * Reads the nearest Paradox doc comment attached to a declaration.
3
+ */
4
+ export function getParadoxComment(node) {
5
+ if (!node)
6
+ return null;
7
+ const sourceFile = node.getSourceFile();
8
+ const text = sourceFile.getFullText();
9
+ const nodeStart = node.getStart(false);
10
+ const beforeNode = text.slice(0, nodeStart);
11
+ const commentStart = beforeNode.lastIndexOf('/***');
12
+ if (commentStart === -1)
13
+ return null;
14
+ const commentEnd = text.indexOf('*/', commentStart);
15
+ if (commentEnd === -1 || commentEnd > nodeStart)
16
+ return null;
17
+ const between = text.slice(commentEnd + 2, nodeStart);
18
+ if (!/^[\s;]*(export\s+)?(default\s+)?$/.test(between))
19
+ return null;
20
+ return text.slice(commentStart, commentEnd + 2);
21
+ }
22
+ /***
23
+ * Parses a Paradox doc comment into structured metadata.
24
+ */
25
+ export function parseParadoxComment(rawComment) {
26
+ const lines = rawComment
27
+ .replace(/^\/\*\*\*/, '')
28
+ .replace(/\*\/$/, '')
29
+ .split('\n')
30
+ .map((line) => line.replace(/^\s*\*\s?/, '').trimEnd());
31
+ let isConfig = false;
32
+ const params = {};
33
+ let returns = null;
34
+ const description = lines
35
+ .filter((line) => {
36
+ const trimmed = line.trimStart();
37
+ if (trimmed.startsWith('@config')) {
38
+ isConfig = true;
39
+ return false;
40
+ }
41
+ if (trimmed.startsWith('@param ')) {
42
+ const paramBody = trimmed.slice('@param '.length).trim();
43
+ const [name, ...descriptionParts] = paramBody.split(/\s+/);
44
+ if (name) {
45
+ params[name] = descriptionParts.join(' ').trim();
46
+ }
47
+ return false;
48
+ }
49
+ if (trimmed.startsWith('@returns') || trimmed.startsWith('@return')) {
50
+ const returnBody = trimmed.replace(/^@returns?/, '').trim();
51
+ returns = returnBody.length > 0 ? returnBody : null;
52
+ return false;
53
+ }
54
+ return true;
55
+ })
56
+ .join('\n')
57
+ .trim();
58
+ return {
59
+ description: description.length > 0 ? description : null,
60
+ isConfig,
61
+ params,
62
+ returns,
63
+ };
64
+ }
@@ -0,0 +1,2 @@
1
+ export type TagRegistry = ReadonlySet<string>;
2
+ export declare const defaultTagRegistry: TagRegistry;
@@ -0,0 +1 @@
1
+ export const defaultTagRegistry = new Set(['readme', 'config']);
@@ -0,0 +1,4 @@
1
+ export declare function toPosixPath(path: string): string;
2
+ export declare function relativeToRoot(root: string, filePath: string): string;
3
+ export declare function isPathInsideRoot(root: string, filePath: string): boolean;
4
+ export declare function isNodeModulePath(filePath: string): boolean;
@@ -0,0 +1,13 @@
1
+ import { normalize, relative } from 'node:path';
2
+ export function toPosixPath(path) {
3
+ return path.replaceAll('\\', '/');
4
+ }
5
+ export function relativeToRoot(root, filePath) {
6
+ return toPosixPath(relative(root, filePath));
7
+ }
8
+ export function isPathInsideRoot(root, filePath) {
9
+ return normalize(filePath).startsWith(normalize(root));
10
+ }
11
+ export function isNodeModulePath(filePath) {
12
+ return toPosixPath(filePath).includes('/node_modules/');
13
+ }
@@ -1,4 +1,9 @@
1
1
  import type { Node } from 'ts-morph';
2
+ interface AnalysisExample {
3
+ title: string | null;
4
+ language: string | null;
5
+ code: string;
6
+ }
2
7
  /***
3
8
  * Describes one exported declaration discovered in a package.
4
9
  */
@@ -25,11 +30,16 @@ export interface AnalysisMember {
25
30
  type: string;
26
31
  required: boolean;
27
32
  description: string | null;
33
+ defaultValue?: string;
34
+ inheritedFrom?: string;
35
+ children?: AnalysisMember[];
28
36
  }
29
37
  export interface AnalysisExport {
30
38
  name: string;
31
39
  node: Node;
32
40
  description: string | null;
41
+ isReadme: boolean;
42
+ examples: AnalysisExample[];
33
43
  kind: 'function' | 'type' | 'unknown';
34
44
  modulePath: string;
35
45
  sourceLocation: AnalysisSourceLocation;
@@ -44,6 +54,8 @@ export interface AnalysisExport {
44
54
  export interface AnalysisComponent {
45
55
  name: string;
46
56
  description: string | null;
57
+ isReadme: boolean;
58
+ examples: AnalysisExample[];
47
59
  modulePath: string;
48
60
  sourceLocation: AnalysisSourceLocation;
49
61
  exportPaths: string[];
@@ -51,6 +63,7 @@ export interface AnalysisComponent {
51
63
  name: string;
52
64
  type: string;
53
65
  required: boolean;
66
+ defaultValue?: string;
54
67
  description: string | null;
55
68
  }[];
56
69
  }
@@ -58,7 +71,7 @@ export interface AnalysisUsage {
58
71
  packageName: string;
59
72
  commands: AnalysisUsageCommand[];
60
73
  }
61
- export interface AnalysisUsageCommand {
74
+ interface AnalysisUsageCommand {
62
75
  name: string;
63
76
  command: string;
64
77
  }
@@ -74,6 +87,43 @@ export interface AnalysisModule {
74
87
  dependencies: string[];
75
88
  exports: string[];
76
89
  }
90
+ interface AnalysisTypeMember {
91
+ name: string;
92
+ type: string;
93
+ required: boolean;
94
+ description: string | null;
95
+ defaultValue?: string;
96
+ inheritedFrom?: string;
97
+ children?: AnalysisTypeMember[];
98
+ }
99
+ interface ImportEdge {
100
+ fromPath: string;
101
+ toPath: string;
102
+ sourcePath: string;
103
+ }
104
+ interface CallEdge {
105
+ fromSymbol: string;
106
+ toSymbol: string;
107
+ callExpression: string;
108
+ sourcePath: string;
109
+ }
110
+ interface TypeReferenceEdge {
111
+ fromSymbol: string;
112
+ toType: string;
113
+ sourcePath: string;
114
+ }
115
+ interface ComponentCompositionEdge {
116
+ fromComponent: string;
117
+ toComponent: string;
118
+ jsxElement: string;
119
+ sourcePath: string;
120
+ }
121
+ interface AnalysisGraphs {
122
+ imports: ImportEdge[];
123
+ calls: CallEdge[];
124
+ typeReferences: TypeReferenceEdge[];
125
+ componentComposition: ComponentCompositionEdge[];
126
+ }
77
127
  /***
78
128
  * Complete analysis output used to build the documentation model.
79
129
  */
@@ -89,5 +139,9 @@ export interface AnalysisResult {
89
139
  usage: AnalysisUsage | null;
90
140
  config: {
91
141
  exportName: string;
142
+ isReadme: boolean;
143
+ members: AnalysisTypeMember[];
92
144
  } | null;
145
+ graphs: AnalysisGraphs;
93
146
  }
147
+ export {};
@@ -4,9 +4,16 @@
4
4
  interface ParsedParadoxComment {
5
5
  description: string | null;
6
6
  isConfig: boolean;
7
+ isReadme: boolean;
8
+ examples: ParsedExample[];
7
9
  params: Record<string, string>;
8
10
  returns: string | null;
9
11
  }
12
+ interface ParsedExample {
13
+ title: string | null;
14
+ language: string | null;
15
+ code: string;
16
+ }
10
17
  /***
11
18
  * Parses a Paradox doc comment into structured metadata.
12
19
  */
@@ -2,20 +2,29 @@
2
2
  * Parses a Paradox doc comment into structured metadata.
3
3
  */
4
4
  export function parseParadoxComment(rawComment) {
5
- const lines = rawComment
6
- .replace(/^\/\*\*\*/, '')
7
- .replace(/\*\/$/, '')
8
- .split('\n')
9
- .map((line) => line.replace(/^\s*\*\s?/, '').trimEnd());
5
+ const lines = normalizeCommentLines(rawComment);
6
+ const descriptionLines = [];
7
+ const examples = [];
10
8
  let isConfig = false;
9
+ let isReadme = false;
11
10
  const params = {};
12
11
  let returns = null;
13
- const description = lines
14
- .filter((line) => {
12
+ for (let index = 0; index < lines.length; index += 1) {
13
+ const line = lines[index] ?? '';
15
14
  const trimmed = line.trimStart();
16
15
  if (trimmed.startsWith('@config')) {
17
16
  isConfig = true;
18
- return false;
17
+ continue;
18
+ }
19
+ if (trimmed.startsWith('@readme')) {
20
+ isReadme = true;
21
+ continue;
22
+ }
23
+ if (trimmed.startsWith('@example')) {
24
+ const parsed = parseExample(lines, index);
25
+ examples.push(parsed.example);
26
+ index = parsed.nextIndex;
27
+ continue;
19
28
  }
20
29
  if (trimmed.startsWith('@param ')) {
21
30
  const paramBody = trimmed.slice('@param '.length).trim();
@@ -23,21 +32,59 @@ export function parseParadoxComment(rawComment) {
23
32
  if (name) {
24
33
  params[name] = descriptionParts.join(' ').trim();
25
34
  }
26
- return false;
35
+ continue;
27
36
  }
28
37
  if (trimmed.startsWith('@returns') || trimmed.startsWith('@return')) {
29
38
  const returnBody = trimmed.replace(/^@returns?/, '').trim();
30
39
  returns = returnBody.length > 0 ? returnBody : null;
31
- return false;
40
+ continue;
32
41
  }
33
- return true;
34
- })
35
- .join('\n')
36
- .trim();
42
+ descriptionLines.push(line);
43
+ }
44
+ const description = descriptionLines.join('\n').trim();
37
45
  return {
38
46
  description: description.length > 0 ? description : null,
39
47
  isConfig,
48
+ isReadme,
49
+ examples,
40
50
  params,
41
51
  returns,
42
52
  };
43
53
  }
54
+ function parseExample(lines, startIndex) {
55
+ const header = lines[startIndex]?.trimStart() ?? '';
56
+ const title = header.slice('@example'.length).trim();
57
+ let language = null;
58
+ const codeLines = [];
59
+ let index = startIndex + 1;
60
+ while (index < lines.length && (lines[index] ?? '').trim() === '') {
61
+ index += 1;
62
+ }
63
+ const firstCodeLine = lines[index]?.trim() ?? '';
64
+ if (firstCodeLine.startsWith('```')) {
65
+ language = firstCodeLine.slice('```'.length).trim() || null;
66
+ index += 1;
67
+ while (index < lines.length) {
68
+ const current = lines[index] ?? '';
69
+ if (current.trim() === '```')
70
+ break;
71
+ codeLines.push(current);
72
+ index += 1;
73
+ }
74
+ }
75
+ return {
76
+ example: {
77
+ title: title.length > 0 ? title : null,
78
+ language,
79
+ code: codeLines.join('\n').trimEnd(),
80
+ },
81
+ nextIndex: index,
82
+ };
83
+ }
84
+ function normalizeCommentLines(rawComment) {
85
+ return rawComment
86
+ .replace(/^\/\*\*\*/, '')
87
+ .replace(/\*\/$/, '')
88
+ .split('\n')
89
+ .map((line) => line.replace(/^\s*\*\s?/, '').trimEnd());
90
+ }
@@ -1,5 +1,7 @@
1
1
  import type { ParadoxConfig } from './types.js';
2
2
  /***
3
3
  * Defines a Paradox configuration object without changing its shape.
4
+ *
5
+ * @readme
4
6
  */
5
7
  export declare function defineParadoxConfig(config: ParadoxConfig): ParadoxConfig;
@@ -1,5 +1,7 @@
1
1
  /***
2
2
  * Defines a Paradox configuration object without changing its shape.
3
+ *
4
+ * @readme
3
5
  */
4
6
  export function defineParadoxConfig(config) {
5
7
  return config;
@@ -2,6 +2,7 @@
2
2
  * Configuration for running Paradox.
3
3
  *
4
4
  * @config
5
+ * @readme
5
6
  */
6
7
  export interface ParadoxConfig {
7
8
  mode?: 'safe' | 'write';
@@ -1,4 +1,28 @@
1
1
  import type { DocumentationModel, ExportKind } from './types.js';
2
+ interface ExampleInput {
3
+ title: string | null;
4
+ language: string | null;
5
+ code: string;
6
+ }
7
+ interface ExportMemberInput {
8
+ name: string;
9
+ kind: 'property' | 'method';
10
+ type: string;
11
+ required: boolean;
12
+ description: string | null;
13
+ defaultValue?: string;
14
+ inheritedFrom?: string;
15
+ children?: ExportMemberInput[];
16
+ }
17
+ interface ConfigMemberInput {
18
+ name: string;
19
+ type: string;
20
+ required: boolean;
21
+ description: string | null;
22
+ defaultValue?: string;
23
+ inheritedFrom?: string;
24
+ children?: ConfigMemberInput[];
25
+ }
2
26
  interface BuildModelInput {
3
27
  packageName: string;
4
28
  packageId: string;
@@ -12,6 +36,8 @@ interface BuildModelInput {
12
36
  exports: {
13
37
  name: string;
14
38
  description: string | null;
39
+ isReadme: boolean;
40
+ examples: ExampleInput[];
15
41
  kind: ExportKind;
16
42
  modulePath: string;
17
43
  sourceLocation: {
@@ -32,17 +58,13 @@ interface BuildModelInput {
32
58
  returnType: string | null;
33
59
  returnDescription: string | null;
34
60
  }[];
35
- members: {
36
- name: string;
37
- kind: 'property' | 'method';
38
- type: string;
39
- required: boolean;
40
- description: string | null;
41
- }[];
61
+ members: ExportMemberInput[];
42
62
  }[];
43
63
  components: {
44
64
  name: string;
45
65
  description: string | null;
66
+ isReadme: boolean;
67
+ examples: ExampleInput[];
46
68
  modulePath: string;
47
69
  sourceLocation: {
48
70
  filePath: string;
@@ -54,6 +76,7 @@ interface BuildModelInput {
54
76
  name: string;
55
77
  type: string;
56
78
  required: boolean;
79
+ defaultValue?: string;
57
80
  description: string | null;
58
81
  }[];
59
82
  }[];
@@ -66,6 +89,8 @@ interface BuildModelInput {
66
89
  } | null;
67
90
  config: {
68
91
  exportName: string;
92
+ isReadme: boolean;
93
+ members: ConfigMemberInput[];
69
94
  } | null;
70
95
  entrypoints: string[];
71
96
  modules: {
@@ -74,6 +99,30 @@ interface BuildModelInput {
74
99
  dependencies: string[];
75
100
  exports: string[];
76
101
  }[];
102
+ graphs: {
103
+ imports: {
104
+ fromPath: string;
105
+ toPath: string;
106
+ sourcePath: string;
107
+ }[];
108
+ calls: {
109
+ fromSymbol: string;
110
+ toSymbol: string;
111
+ callExpression: string;
112
+ sourcePath: string;
113
+ }[];
114
+ typeReferences: {
115
+ fromSymbol: string;
116
+ toType: string;
117
+ sourcePath: string;
118
+ }[];
119
+ componentComposition: {
120
+ fromComponent: string;
121
+ toComponent: string;
122
+ jsxElement: string;
123
+ sourcePath: string;
124
+ }[];
125
+ };
77
126
  }
78
127
  /***
79
128
  * Converts analysis output into a serializable documentation model.
@@ -27,10 +27,12 @@ export function buildModel(analysis) {
27
27
  config: analysis.config !== null
28
28
  ? {
29
29
  exportName: analysis.config.exportName,
30
+ isReadme: analysis.config.isReadme,
30
31
  configFile: getDefaultConfigFileName(analysis.packageId),
31
32
  factoryName: findConfigFactoryName(analysis.config.exportName, [
32
33
  ...exportsByName.keys(),
33
34
  ]),
35
+ members: analysis.config.members,
34
36
  }
35
37
  : null,
36
38
  entrypoints: [...analysis.entrypoints].sort((a, b) => a.localeCompare(b)),
@@ -44,12 +46,20 @@ export function buildModel(analysis) {
44
46
  .sort((left, right) => left.path.localeCompare(right.path)),
45
47
  exports,
46
48
  components: sortByName(analysis.components.map((component) => mapComponent(component, exportsByName.get(component.name)))),
49
+ graphs: {
50
+ imports: [...analysis.graphs.imports],
51
+ calls: [...analysis.graphs.calls],
52
+ typeReferences: [...analysis.graphs.typeReferences],
53
+ componentComposition: [...analysis.graphs.componentComposition],
54
+ },
47
55
  };
48
56
  }
49
57
  function mapExport(item, exportNames) {
50
58
  return {
51
59
  name: item.name,
52
60
  description: item.description,
61
+ isReadme: item.isReadme,
62
+ examples: item.examples.map((example) => ({ ...example })),
53
63
  kind: item.kind,
54
64
  modulePath: item.modulePath,
55
65
  sourceLocation: {
@@ -78,6 +88,9 @@ function mapExport(item, exportNames) {
78
88
  type: member.type,
79
89
  required: member.required,
80
90
  description: member.description,
91
+ defaultValue: member.defaultValue,
92
+ inheritedFrom: member.inheritedFrom,
93
+ children: member.children,
81
94
  }))),
82
95
  };
83
96
  }
@@ -85,6 +98,8 @@ function mapComponent(component, exportModel) {
85
98
  return {
86
99
  name: component.name,
87
100
  description: component.description,
101
+ isReadme: component.isReadme,
102
+ examples: component.examples.map((example) => ({ ...example })),
88
103
  modulePath: component.modulePath,
89
104
  sourceLocation: {
90
105
  filePath: component.sourceLocation.filePath,
@@ -96,6 +111,7 @@ function mapComponent(component, exportModel) {
96
111
  name: prop.name,
97
112
  type: prop.type,
98
113
  required: prop.required,
114
+ defaultValue: prop.defaultValue,
99
115
  description: prop.description,
100
116
  }))),
101
117
  };