@reicek/neataptic-ts 0.1.25 → 0.1.26
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/.github/copilot-instructions.md +11 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/package.json +19 -13
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
- package/plans/README.md +24 -0
- package/plans/Roadmap.md +62 -40
- package/plans/analyze-trace-solid-split.plans.md +66 -0
- package/plans/architecture-solid-split.plans.md +9 -15
- package/plans/asciiMaze-typescript-repair.plans.md +1 -1
- package/plans/generate-docs-solid-split.plans.md +87 -0
- package/plans/methods-docs.plans.md +25 -1
- package/plans/methods-solid-split.plans.md +14 -14
- package/plans/neat-docs.plans.md +9 -1
- package/plans/neat-test-surface-repair.plans.md +1 -1
- package/plans/render-docs-html-solid-split.plans.md +68 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
- package/plans/utils-docs.plans.md +6 -1
- package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
- package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
- package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
- package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
- package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
- package/scripts/analyze-trace/analyze-trace.ts +45 -0
- package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
- package/scripts/assets/theme.css +80 -23
- package/scripts/copy-examples.ts +239 -0
- package/scripts/export-onnx.ts +223 -0
- package/scripts/generate-bench-tables.ts +378 -37
- package/scripts/generate-docs/generate-docs.constants.ts +107 -0
- package/scripts/generate-docs/generate-docs.order.ts +355 -0
- package/scripts/generate-docs/generate-docs.state.ts +31 -0
- package/scripts/generate-docs/generate-docs.targets.ts +165 -0
- package/scripts/generate-docs/generate-docs.ts +63 -0
- package/scripts/generate-docs/generate-docs.types.ts +112 -0
- package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
- package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
- package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
- package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
- package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
- package/scripts/mermaid-cli.mjs +102 -22
- package/scripts/mermaid-cli.ts +736 -0
- package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
- package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
- package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
- package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
- package/scripts/render-docs-html.ts +23 -587
- package/scripts/run-docs.ts +238 -0
- package/scripts/write-dist-docs-pkg.ts +40 -0
- package/src/README.md +75 -75
- package/src/architecture/connection/README.md +5 -5
- package/src/architecture/layer/README.md +508 -508
- package/src/architecture/network/README.md +1458 -1458
- package/src/architecture/network/activate/README.md +694 -694
- package/src/architecture/network/bootstrap/README.md +77 -77
- package/src/architecture/network/connect/README.md +74 -74
- package/src/architecture/network/deterministic/README.md +135 -135
- package/src/architecture/network/evolve/README.md +364 -364
- package/src/architecture/network/gating/README.md +130 -130
- package/src/architecture/network/genetic/README.md +399 -399
- package/src/architecture/network/mutate/README.md +897 -897
- package/src/architecture/network/onnx/README.md +720 -720
- package/src/architecture/network/onnx/export/README.md +728 -728
- package/src/architecture/network/onnx/export/layers/README.md +450 -450
- package/src/architecture/network/onnx/import/README.md +618 -618
- package/src/architecture/network/onnx/schema/README.md +32 -32
- package/src/architecture/network/prune/README.md +245 -245
- package/src/architecture/network/remove/README.md +135 -135
- package/src/architecture/network/runtime/README.md +106 -106
- package/src/architecture/network/serialize/README.md +542 -542
- package/src/architecture/network/slab/README.md +608 -608
- package/src/architecture/network/standalone/README.md +212 -212
- package/src/architecture/network/stats/README.md +84 -84
- package/src/architecture/network/topology/README.md +465 -465
- package/src/architecture/network/training/README.md +200 -200
- package/src/architecture/node/README.md +5 -5
- package/src/architecture/nodePool/README.md +14 -14
- package/src/methods/README.md +99 -99
- package/src/methods/activation/README.md +189 -189
- package/src/methods/cost/README.md +131 -131
- package/src/methods/rate/README.md +86 -86
- package/src/multithreading/README.md +77 -77
- package/src/multithreading/workers/browser/README.md +8 -8
- package/src/multithreading/workers/node/README.md +8 -8
- package/src/neat/README.md +148 -148
- package/src/neat/adaptive/README.md +120 -120
- package/src/neat/adaptive/acceptance/README.md +40 -40
- package/src/neat/adaptive/complexity/README.md +137 -137
- package/src/neat/adaptive/core/README.md +197 -197
- package/src/neat/adaptive/lineage/README.md +90 -90
- package/src/neat/adaptive/mutation/README.md +284 -284
- package/src/neat/compat/README.md +43 -43
- package/src/neat/compat/core/README.md +90 -90
- package/src/neat/diversity/README.md +35 -35
- package/src/neat/diversity/core/README.md +88 -88
- package/src/neat/evaluate/README.md +85 -85
- package/src/neat/evaluate/auto-distance/README.md +75 -75
- package/src/neat/evaluate/entropy-compat/README.md +37 -37
- package/src/neat/evaluate/entropy-sharing/README.md +43 -43
- package/src/neat/evaluate/fitness/README.md +23 -23
- package/src/neat/evaluate/novelty/README.md +120 -120
- package/src/neat/evaluate/objectives/README.md +17 -17
- package/src/neat/evaluate/shared/README.md +94 -94
- package/src/neat/evolve/README.md +96 -96
- package/src/neat/evolve/adaptive/README.md +60 -60
- package/src/neat/evolve/objectives/README.md +63 -63
- package/src/neat/evolve/offspring/README.md +56 -56
- package/src/neat/evolve/population/README.md +171 -171
- package/src/neat/evolve/runtime/README.md +79 -79
- package/src/neat/evolve/speciation/README.md +74 -74
- package/src/neat/evolve/warnings/README.md +10 -10
- package/src/neat/export/README.md +114 -114
- package/src/neat/helpers/README.md +50 -50
- package/src/neat/init/README.md +9 -9
- package/src/neat/lineage/core/README.md +101 -101
- package/src/neat/multiobjective/category/README.md +74 -74
- package/src/neat/multiobjective/crowding/README.md +272 -272
- package/src/neat/multiobjective/dominance/README.md +171 -171
- package/src/neat/multiobjective/fronts/README.md +68 -68
- package/src/neat/multiobjective/metrics/README.md +43 -43
- package/src/neat/multiobjective/objectives/README.md +31 -31
- package/src/neat/multiobjective/shared/README.md +27 -27
- package/src/neat/mutation/README.md +97 -97
- package/src/neat/mutation/add-conn/README.md +115 -115
- package/src/neat/mutation/add-node/README.md +126 -126
- package/src/neat/mutation/flow/README.md +149 -149
- package/src/neat/mutation/repair/README.md +185 -185
- package/src/neat/mutation/select/README.md +117 -117
- package/src/neat/mutation/shared/README.md +32 -32
- package/src/neat/objectives/README.md +25 -25
- package/src/neat/objectives/core/README.md +67 -67
- package/src/neat/pruning/README.md +40 -40
- package/src/neat/pruning/core/README.md +171 -171
- package/src/neat/pruning/facade/README.md +32 -32
- package/src/neat/rng/README.md +104 -104
- package/src/neat/rng/core/README.md +137 -137
- package/src/neat/rng/facade/README.md +50 -50
- package/src/neat/selection/README.md +111 -111
- package/src/neat/selection/core/README.md +227 -227
- package/src/neat/selection/facade/README.md +61 -61
- package/src/neat/shared/README.md +163 -163
- package/src/neat/speciation/README.md +31 -31
- package/src/neat/speciation/threshold/README.md +35 -35
- package/src/neat/species/README.md +25 -25
- package/src/neat/species/core/README.md +20 -20
- package/src/neat/species/core/shared/README.md +18 -18
- package/src/neat/species/history/context/README.md +22 -22
- package/src/neat/telemetry/accessors/README.md +58 -58
- package/src/neat/telemetry/exports/README.md +233 -233
- package/src/neat/telemetry/facade/README.md +252 -252
- package/src/neat/telemetry/facade/archive/README.md +57 -57
- package/src/neat/telemetry/facade/buffer/README.md +43 -43
- package/src/neat/telemetry/facade/lineage/README.md +12 -12
- package/src/neat/telemetry/facade/objectives/README.md +44 -44
- package/src/neat/telemetry/facade/runtime/README.md +26 -26
- package/src/neat/telemetry/facade/species/README.md +27 -27
- package/src/neat/telemetry/metrics/README.md +696 -696
- package/src/neat/telemetry/recorder/README.md +57 -57
- package/src/neat/telemetry/types/README.md +32 -32
- package/src/neat/topology-intent/README.md +75 -75
- package/src/utils/README.md +193 -193
- package/test/examples/asciiMaze/browser-entry/README.md +92 -92
- package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
- package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
- package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
- package/test/examples/flappy_bird/browser-entry/README.md +508 -508
- package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
- package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
- package/test/examples/flappy_bird/constants/README.md +1070 -1070
- package/test/examples/flappy_bird/environment/README.md +22 -22
- package/test/examples/flappy_bird/evaluation/README.md +32 -32
- package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
- package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
- package/test/examples/flappy_bird/trainer/README.md +325 -325
- package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
- package/scripts/analyze-trace.ts +0 -590
- package/scripts/copy-examples.mjs +0 -114
- package/scripts/export-onnx.mjs +0 -86
- package/scripts/generate-bench-tables.mjs +0 -182
- package/scripts/generate-docs.ts +0 -2900
- package/scripts/write-dist-docs-pkg.mjs +0 -16
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Emits docs.order.json warning messages scoped to the output boundary.
|
|
3
|
+
*
|
|
4
|
+
* Ordering helpers depend on these checks to explain stale config references
|
|
5
|
+
* without mixing repetitive warning logic back into the main README and index
|
|
6
|
+
* rendering flow.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
|
|
11
|
+
import { warnDirectoryDocsOrderConfig } from '../generate-docs.order.js';
|
|
12
|
+
import type { RenderedSymbol } from '../generate-docs.types.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Warns when `fileOrder` references files missing from the current folder.
|
|
16
|
+
*
|
|
17
|
+
* @param configuredFileOrder - Configured file order entries.
|
|
18
|
+
* @param filePaths - Actual files in the current directory README.
|
|
19
|
+
* @param configPath - Absolute config path.
|
|
20
|
+
* @returns Nothing.
|
|
21
|
+
*/
|
|
22
|
+
export function warnForUnknownConfiguredDirectoryFiles(
|
|
23
|
+
configuredFileOrder: readonly string[],
|
|
24
|
+
filePaths: readonly string[],
|
|
25
|
+
configPath: string | undefined,
|
|
26
|
+
): void {
|
|
27
|
+
if (!configPath) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const knownFileNames = new Set(
|
|
32
|
+
filePaths.map((filePath) => path.basename(filePath)),
|
|
33
|
+
);
|
|
34
|
+
const unknownFileNames = configuredFileOrder.filter(
|
|
35
|
+
(fileName) => !knownFileNames.has(fileName),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (unknownFileNames.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
warnDirectoryDocsOrderConfig(
|
|
43
|
+
configPath,
|
|
44
|
+
`Field "fileOrder" references unknown files for this folder: ${unknownFileNames.join(', ')}`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Warns when `hiddenFiles` references files missing from the current folder.
|
|
50
|
+
*
|
|
51
|
+
* @param configuredHiddenFiles - Configured hidden file entries.
|
|
52
|
+
* @param filePaths - Actual files in the current directory README.
|
|
53
|
+
* @param configPath - Absolute config path.
|
|
54
|
+
* @returns Nothing.
|
|
55
|
+
*/
|
|
56
|
+
export function warnForUnknownConfiguredHiddenFiles(
|
|
57
|
+
configuredHiddenFiles: readonly string[],
|
|
58
|
+
filePaths: readonly string[],
|
|
59
|
+
configPath: string | undefined,
|
|
60
|
+
): void {
|
|
61
|
+
if (!configPath) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const knownFileNames = new Set(
|
|
66
|
+
filePaths.map((filePath) => path.basename(filePath)),
|
|
67
|
+
);
|
|
68
|
+
const unknownFileNames = configuredHiddenFiles.filter(
|
|
69
|
+
(fileName) => !knownFileNames.has(fileName),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (unknownFileNames.length === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
warnDirectoryDocsOrderConfig(
|
|
77
|
+
configPath,
|
|
78
|
+
`Field "hiddenFiles" references unknown files for this folder: ${unknownFileNames.join(', ')}`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Warns when `introFile` references a file missing from the current folder.
|
|
84
|
+
*
|
|
85
|
+
* @param configuredIntroFile - Configured intro file name.
|
|
86
|
+
* @param filePaths - Actual files in the current directory README.
|
|
87
|
+
* @param configPath - Absolute config path.
|
|
88
|
+
* @returns Nothing.
|
|
89
|
+
*/
|
|
90
|
+
export function warnForUnknownConfiguredDirectoryIntroFile(
|
|
91
|
+
configuredIntroFile: string,
|
|
92
|
+
filePaths: readonly string[],
|
|
93
|
+
configPath: string | undefined,
|
|
94
|
+
): void {
|
|
95
|
+
if (!configPath) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const knownFileNames = new Set(
|
|
100
|
+
filePaths.map((filePath) => path.basename(filePath)),
|
|
101
|
+
);
|
|
102
|
+
if (knownFileNames.has(configuredIntroFile)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
warnDirectoryDocsOrderConfig(
|
|
107
|
+
configPath,
|
|
108
|
+
`Field "introFile" references an unknown file for this folder: ${configuredIntroFile}`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Warns when `symbolOrder` references top-level symbols missing from one file
|
|
114
|
+
* section.
|
|
115
|
+
*
|
|
116
|
+
* @param configuredSymbolOrder - Configured symbol order entries.
|
|
117
|
+
* @param topLevelSymbols - Top-level symbols rendered for the current file.
|
|
118
|
+
* @param configPath - Absolute config path.
|
|
119
|
+
* @param filePath - Absolute source file path for warning context.
|
|
120
|
+
* @returns Nothing.
|
|
121
|
+
*/
|
|
122
|
+
export function warnForUnknownConfiguredFileSectionSymbols(
|
|
123
|
+
configuredSymbolOrder: readonly string[],
|
|
124
|
+
topLevelSymbols: readonly RenderedSymbol[],
|
|
125
|
+
configPath: string | undefined,
|
|
126
|
+
filePath: string,
|
|
127
|
+
): void {
|
|
128
|
+
if (!configPath) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const knownSymbolNames = new Set(
|
|
133
|
+
topLevelSymbols.map((symbol) => symbol.name),
|
|
134
|
+
);
|
|
135
|
+
const unknownSymbolNames = configuredSymbolOrder.filter(
|
|
136
|
+
(symbolName) => !knownSymbolNames.has(symbolName),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
if (unknownSymbolNames.length === 0) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
warnDirectoryDocsOrderConfig(
|
|
144
|
+
configPath,
|
|
145
|
+
`Field "symbolOrder.${path.basename(filePath)}" references unknown top-level symbols for this file section: ${unknownSymbolNames.join(', ')}`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Warns when `hiddenSymbols` references symbols missing from the current
|
|
151
|
+
* directory README.
|
|
152
|
+
*
|
|
153
|
+
* @param configuredHiddenSymbols - Configured hidden symbol entries.
|
|
154
|
+
* @param fileSymbolMap - Symbols grouped by file within the directory.
|
|
155
|
+
* @param configPath - Absolute config path.
|
|
156
|
+
* @returns Nothing.
|
|
157
|
+
*/
|
|
158
|
+
export function warnForUnknownConfiguredHiddenSymbols(
|
|
159
|
+
configuredHiddenSymbols: readonly string[],
|
|
160
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
161
|
+
configPath: string | undefined,
|
|
162
|
+
): void {
|
|
163
|
+
if (!configPath) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const knownSymbolNames = new Set(
|
|
168
|
+
[...fileSymbolMap.values()].flatMap((renderedSymbols) =>
|
|
169
|
+
renderedSymbols.map((symbol) => symbol.name),
|
|
170
|
+
),
|
|
171
|
+
);
|
|
172
|
+
const unknownSymbolNames = configuredHiddenSymbols.filter(
|
|
173
|
+
(symbolName) => !knownSymbolNames.has(symbolName),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
if (unknownSymbolNames.length === 0) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
warnDirectoryDocsOrderConfig(
|
|
181
|
+
configPath,
|
|
182
|
+
`Field "hiddenSymbols" references unknown symbols for this folder: ${unknownSymbolNames.join(', ')}`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Warns when `folderOrder` references child folders missing from one folder
|
|
188
|
+
* index node.
|
|
189
|
+
*
|
|
190
|
+
* @param configuredFolderOrder - Configured folder order entries.
|
|
191
|
+
* @param childFolderNames - Actual child folder names under the current node.
|
|
192
|
+
* @param configPath - Absolute config path.
|
|
193
|
+
* @param nodePath - Relative folder-index node path for warning context.
|
|
194
|
+
* @returns Nothing.
|
|
195
|
+
*/
|
|
196
|
+
export function warnForUnknownConfiguredFolderIndexChildren(
|
|
197
|
+
configuredFolderOrder: readonly string[],
|
|
198
|
+
childFolderNames: readonly string[],
|
|
199
|
+
configPath: string | undefined,
|
|
200
|
+
nodePath: string,
|
|
201
|
+
): void {
|
|
202
|
+
if (!configPath) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const knownFolderNames = new Set(childFolderNames);
|
|
207
|
+
const unknownFolderNames = configuredFolderOrder.filter(
|
|
208
|
+
(folderName) => !knownFolderNames.has(folderName),
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
if (unknownFolderNames.length === 0) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
warnDirectoryDocsOrderConfig(
|
|
216
|
+
configPath,
|
|
217
|
+
`Field "folderOrder" references unknown child folders for ${nodePath}: ${unknownFolderNames.join(', ')}`,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Collects docs-ready symbols from ts-morph source files.
|
|
3
|
+
*
|
|
4
|
+
* This chapter owns source-file scanning, export walking, and the bookkeeping
|
|
5
|
+
* needed to accumulate one directory/file symbol map without pulling JSDoc
|
|
6
|
+
* parsing or signature formatting concerns into the traversal flow.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
|
|
11
|
+
import type { SourceFile } from 'ts-morph';
|
|
12
|
+
|
|
13
|
+
import { FILE_SUMMARY_SYMBOL_NAME } from '../generate-docs.constants.js';
|
|
14
|
+
import type {
|
|
15
|
+
DirectorySymbolMap,
|
|
16
|
+
RenderedSymbol,
|
|
17
|
+
} from '../generate-docs.types.js';
|
|
18
|
+
import { resolveFileSummary } from './generate-docs.symbols.jsdoc.utils.js';
|
|
19
|
+
import {
|
|
20
|
+
renderDeclaration,
|
|
21
|
+
renderSymbol,
|
|
22
|
+
} from './generate-docs.symbols.render.utils.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Collects renderable symbols grouped by directory and then by file.
|
|
26
|
+
*
|
|
27
|
+
* @param sourceFiles - Loaded source files to scan.
|
|
28
|
+
* @returns Nested symbol map keyed by directory and then source file path.
|
|
29
|
+
*/
|
|
30
|
+
export function collectDirectorySymbols(
|
|
31
|
+
sourceFiles: readonly SourceFile[],
|
|
32
|
+
): DirectorySymbolMap {
|
|
33
|
+
const directorySymbolMap: DirectorySymbolMap = new Map();
|
|
34
|
+
|
|
35
|
+
for (const sourceFile of sourceFiles) {
|
|
36
|
+
collectSourceFileSymbols(sourceFile, directorySymbolMap);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return directorySymbolMap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Collects every renderable symbol from a single source file.
|
|
44
|
+
*
|
|
45
|
+
* @param sourceFile - Source file being scanned.
|
|
46
|
+
* @param directorySymbolMap - Aggregate directory symbol map.
|
|
47
|
+
* @returns Nothing.
|
|
48
|
+
*/
|
|
49
|
+
function collectSourceFileSymbols(
|
|
50
|
+
sourceFile: SourceFile,
|
|
51
|
+
directorySymbolMap: DirectorySymbolMap,
|
|
52
|
+
): void {
|
|
53
|
+
const filePath = sourceFile.getFilePath();
|
|
54
|
+
const fileSymbolMap = resolveFileSymbolMap(directorySymbolMap, filePath);
|
|
55
|
+
|
|
56
|
+
addFileSummarySymbol(sourceFile, fileSymbolMap);
|
|
57
|
+
collectExportedDeclarations(sourceFile, fileSymbolMap);
|
|
58
|
+
collectDocumentedTopLevelDeclarations(sourceFile, fileSymbolMap);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Resolves the mutable file-symbol map for the file's directory.
|
|
63
|
+
*
|
|
64
|
+
* @param directorySymbolMap - Aggregate directory symbol map.
|
|
65
|
+
* @param filePath - Absolute source file path.
|
|
66
|
+
* @returns Per-directory file symbol map.
|
|
67
|
+
*/
|
|
68
|
+
function resolveFileSymbolMap(
|
|
69
|
+
directorySymbolMap: DirectorySymbolMap,
|
|
70
|
+
filePath: string,
|
|
71
|
+
): Map<string, RenderedSymbol[]> {
|
|
72
|
+
const directoryPath = path.dirname(filePath);
|
|
73
|
+
let fileSymbolMap = directorySymbolMap.get(directoryPath);
|
|
74
|
+
|
|
75
|
+
if (!fileSymbolMap) {
|
|
76
|
+
fileSymbolMap = new Map();
|
|
77
|
+
directorySymbolMap.set(directoryPath, fileSymbolMap);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return fileSymbolMap;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Adds a synthetic file-summary symbol when the file starts with a file-level
|
|
85
|
+
* JSDoc block.
|
|
86
|
+
*
|
|
87
|
+
* @param sourceFile - Source file being scanned.
|
|
88
|
+
* @param fileSymbolMap - Mutable symbol map for the file's directory.
|
|
89
|
+
* @returns Nothing.
|
|
90
|
+
*/
|
|
91
|
+
function addFileSummarySymbol(
|
|
92
|
+
sourceFile: SourceFile,
|
|
93
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
94
|
+
): void {
|
|
95
|
+
const fileSummary = resolveFileSummary(sourceFile);
|
|
96
|
+
if (!fileSummary.description && !fileSummary.examples?.length) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
appendRenderedSymbol(fileSymbolMap, sourceFile.getFilePath(), {
|
|
101
|
+
kind: 'File',
|
|
102
|
+
name: FILE_SUMMARY_SYMBOL_NAME,
|
|
103
|
+
filePath: sourceFile.getFilePath(),
|
|
104
|
+
jsdoc: {
|
|
105
|
+
description: fileSummary.description,
|
|
106
|
+
examples: fileSummary.examples,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
console.log(`[docs] Added file summary for ${sourceFile.getBaseName()}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Collects exported declarations and supported child members.
|
|
115
|
+
*
|
|
116
|
+
* @param sourceFile - Source file being scanned.
|
|
117
|
+
* @param fileSymbolMap - Mutable symbol map for the file's directory.
|
|
118
|
+
* @returns Nothing.
|
|
119
|
+
*/
|
|
120
|
+
function collectExportedDeclarations(
|
|
121
|
+
sourceFile: SourceFile,
|
|
122
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
123
|
+
): void {
|
|
124
|
+
const exportedDeclarations = sourceFile.getExportedDeclarations();
|
|
125
|
+
if (exportedDeclarations.size === 0) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
console.log(
|
|
130
|
+
`[docs] ${sourceFile.getBaseName()} exports: ${exportedDeclarations.size}`,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
for (const [, declarations] of exportedDeclarations) {
|
|
134
|
+
for (const declaration of declarations) {
|
|
135
|
+
const symbol = declaration.getSymbol();
|
|
136
|
+
if (!symbol) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const renderedSymbol = renderSymbol(
|
|
141
|
+
symbol,
|
|
142
|
+
declaration.getKindName(),
|
|
143
|
+
sourceFile.getFilePath(),
|
|
144
|
+
);
|
|
145
|
+
if (renderedSymbol) {
|
|
146
|
+
appendRenderedSymbol(
|
|
147
|
+
fileSymbolMap,
|
|
148
|
+
sourceFile.getFilePath(),
|
|
149
|
+
renderedSymbol,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
collectExportedObjectLiteralMembers(
|
|
154
|
+
declaration as unknown as Record<string, unknown>,
|
|
155
|
+
symbol.getName(),
|
|
156
|
+
sourceFile.getFilePath(),
|
|
157
|
+
fileSymbolMap,
|
|
158
|
+
);
|
|
159
|
+
collectExportedClassMembers(
|
|
160
|
+
declaration as unknown as Record<string, unknown>,
|
|
161
|
+
symbol.getName(),
|
|
162
|
+
sourceFile.getFilePath(),
|
|
163
|
+
fileSymbolMap,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Collects documented properties from exported object-literal variables.
|
|
171
|
+
*
|
|
172
|
+
* @param declaration - Candidate declaration.
|
|
173
|
+
* @param parentName - Parent exported symbol name.
|
|
174
|
+
* @param filePath - Absolute source file path.
|
|
175
|
+
* @param fileSymbolMap - Mutable symbol map for the file's directory.
|
|
176
|
+
* @returns Nothing.
|
|
177
|
+
*/
|
|
178
|
+
function collectExportedObjectLiteralMembers(
|
|
179
|
+
declaration: Record<string, unknown>,
|
|
180
|
+
parentName: string,
|
|
181
|
+
filePath: string,
|
|
182
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
183
|
+
): void {
|
|
184
|
+
try {
|
|
185
|
+
const declarationKindName = (
|
|
186
|
+
declaration.getKindName as (() => string) | undefined
|
|
187
|
+
)?.();
|
|
188
|
+
if (declarationKindName !== 'VariableDeclaration') {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const initializer = (
|
|
193
|
+
declaration.getInitializer as (() => any) | undefined
|
|
194
|
+
)?.();
|
|
195
|
+
if (initializer?.getKindName?.() !== 'ObjectLiteralExpression') {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const properties = (initializer.getProperties?.() as any[]) || [];
|
|
200
|
+
for (const property of properties) {
|
|
201
|
+
const propertyName =
|
|
202
|
+
property.getName?.() || property.getSymbol?.()?.getName?.();
|
|
203
|
+
const renderedProperty = renderDeclaration(
|
|
204
|
+
property,
|
|
205
|
+
String(propertyName),
|
|
206
|
+
property.getKindName?.() || 'Property',
|
|
207
|
+
filePath,
|
|
208
|
+
parentName,
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
if (renderedProperty) {
|
|
212
|
+
appendRenderedSymbol(fileSymbolMap, filePath, renderedProperty);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch {
|
|
216
|
+
// Best-effort introspection only.
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Collects documented members from exported classes.
|
|
222
|
+
*
|
|
223
|
+
* @param declaration - Candidate declaration.
|
|
224
|
+
* @param parentName - Parent exported symbol name.
|
|
225
|
+
* @param filePath - Absolute source file path.
|
|
226
|
+
* @param fileSymbolMap - Mutable symbol map for the file's directory.
|
|
227
|
+
* @returns Nothing.
|
|
228
|
+
*/
|
|
229
|
+
function collectExportedClassMembers(
|
|
230
|
+
declaration: Record<string, unknown>,
|
|
231
|
+
parentName: string,
|
|
232
|
+
filePath: string,
|
|
233
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
234
|
+
): void {
|
|
235
|
+
try {
|
|
236
|
+
const declarationKindName = (
|
|
237
|
+
declaration.getKindName as (() => string) | undefined
|
|
238
|
+
)?.();
|
|
239
|
+
if (declarationKindName !== 'ClassDeclaration') {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const members =
|
|
244
|
+
(declaration.getMembers as (() => any[]) | undefined)?.() || [];
|
|
245
|
+
for (const member of members) {
|
|
246
|
+
const memberName = member.getName?.();
|
|
247
|
+
if (!memberName) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const renderedMember = renderDeclaration(
|
|
252
|
+
member,
|
|
253
|
+
String(memberName),
|
|
254
|
+
member.getKindName?.() || 'ClassMember',
|
|
255
|
+
filePath,
|
|
256
|
+
parentName,
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
if (renderedMember) {
|
|
260
|
+
appendRenderedSymbol(fileSymbolMap, filePath, renderedMember);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
// Best-effort introspection only.
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Collects documented top-level non-exported declarations.
|
|
270
|
+
*
|
|
271
|
+
* @param sourceFile - Source file being scanned.
|
|
272
|
+
* @param fileSymbolMap - Mutable symbol map for the file's directory.
|
|
273
|
+
* @returns Nothing.
|
|
274
|
+
*/
|
|
275
|
+
function collectDocumentedTopLevelDeclarations(
|
|
276
|
+
sourceFile: SourceFile,
|
|
277
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
278
|
+
): void {
|
|
279
|
+
try {
|
|
280
|
+
const statements =
|
|
281
|
+
(
|
|
282
|
+
sourceFile as unknown as { getStatements?: () => any[] }
|
|
283
|
+
).getStatements?.() || [];
|
|
284
|
+
|
|
285
|
+
for (const statement of statements) {
|
|
286
|
+
const declarations = statement.getDeclarations?.() || [statement];
|
|
287
|
+
|
|
288
|
+
for (const declaration of declarations) {
|
|
289
|
+
const jsDocs = declaration.getJsDocs?.() || [];
|
|
290
|
+
if (jsDocs.length === 0) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const name =
|
|
295
|
+
declaration.getName?.() || declaration.getSymbol?.()?.getName?.();
|
|
296
|
+
if (!name) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (
|
|
301
|
+
hasRenderedSymbol(
|
|
302
|
+
fileSymbolMap,
|
|
303
|
+
sourceFile.getFilePath(),
|
|
304
|
+
String(name),
|
|
305
|
+
)
|
|
306
|
+
) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const renderedDeclaration = renderDeclaration(
|
|
311
|
+
declaration,
|
|
312
|
+
String(name),
|
|
313
|
+
declaration.getKindName?.() || 'Declaration',
|
|
314
|
+
sourceFile.getFilePath(),
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
if (renderedDeclaration) {
|
|
318
|
+
appendRenderedSymbol(
|
|
319
|
+
fileSymbolMap,
|
|
320
|
+
sourceFile.getFilePath(),
|
|
321
|
+
renderedDeclaration,
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
} catch {
|
|
327
|
+
// Best-effort introspection only.
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Checks whether a symbol name has already been collected for a file.
|
|
333
|
+
*
|
|
334
|
+
* @param fileSymbolMap - Mutable symbol map for the directory.
|
|
335
|
+
* @param filePath - Absolute source file path.
|
|
336
|
+
* @param name - Candidate symbol name.
|
|
337
|
+
* @returns True when the symbol already exists in the collected set.
|
|
338
|
+
*/
|
|
339
|
+
function hasRenderedSymbol(
|
|
340
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
341
|
+
filePath: string,
|
|
342
|
+
name: string,
|
|
343
|
+
): boolean {
|
|
344
|
+
return (fileSymbolMap.get(filePath) ?? []).some(
|
|
345
|
+
(symbol) => symbol.name === name,
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Appends a rendered symbol to the per-file collection.
|
|
351
|
+
*
|
|
352
|
+
* @param fileSymbolMap - Mutable symbol map for the directory.
|
|
353
|
+
* @param filePath - Absolute source file path.
|
|
354
|
+
* @param renderedSymbol - Symbol to append.
|
|
355
|
+
* @returns Nothing.
|
|
356
|
+
*/
|
|
357
|
+
function appendRenderedSymbol(
|
|
358
|
+
fileSymbolMap: Map<string, RenderedSymbol[]>,
|
|
359
|
+
filePath: string,
|
|
360
|
+
renderedSymbol: RenderedSymbol,
|
|
361
|
+
): void {
|
|
362
|
+
const renderedSymbols = fileSymbolMap.get(filePath) ?? [];
|
|
363
|
+
renderedSymbols.push(renderedSymbol);
|
|
364
|
+
fileSymbolMap.set(filePath, renderedSymbols);
|
|
365
|
+
}
|