@textmode/docs 0.2.1 → 0.2.2
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/package.json
CHANGED
|
@@ -62,6 +62,7 @@ async function loadPrimaryCheckProject(config) {
|
|
|
62
62
|
entryPoint: primaryEntryPoint.path,
|
|
63
63
|
tsconfig: primaryEntryPoint.tsconfig,
|
|
64
64
|
packageName: config.packageName,
|
|
65
|
+
projectRoot: config.projectRoot,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -183,6 +184,7 @@ async function collectPendingEdits(config, routes) {
|
|
|
183
184
|
entryPoint: entryPoint.path,
|
|
184
185
|
tsconfig: entryPoint.tsconfig,
|
|
185
186
|
packageName: config.packageName,
|
|
187
|
+
projectRoot: config.projectRoot,
|
|
186
188
|
});
|
|
187
189
|
const reflections = getIncludedReflections(project, targetKinds);
|
|
188
190
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Application, TSConfigReader } from 'typedoc';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
2
5
|
import { load as loadFrontmatter } from 'typedoc-plugin-frontmatter';
|
|
3
6
|
import { load as loadMarkdown } from 'typedoc-plugin-markdown';
|
|
4
7
|
import { load as loadVitepressTheme } from 'typedoc-vitepress-theme';
|
|
@@ -66,13 +69,46 @@ function pluginInitializers(config) {
|
|
|
66
69
|
return plugins;
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
function createEntrypointTsconfig({ tsconfig, projectRoot, entryPoints }) {
|
|
73
|
+
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'textmode-docs-tsconfig-'));
|
|
74
|
+
const configPath = path.join(temporaryDirectory, 'tsconfig.json');
|
|
75
|
+
fs.writeFileSync(
|
|
76
|
+
configPath,
|
|
77
|
+
`${JSON.stringify(
|
|
78
|
+
{
|
|
79
|
+
extends: tsconfig,
|
|
80
|
+
compilerOptions: {
|
|
81
|
+
noEmit: true,
|
|
82
|
+
rootDir: projectRoot,
|
|
83
|
+
types: [],
|
|
84
|
+
},
|
|
85
|
+
files: entryPoints,
|
|
86
|
+
},
|
|
87
|
+
null,
|
|
88
|
+
2
|
|
89
|
+
)}\n`
|
|
90
|
+
);
|
|
91
|
+
return {
|
|
92
|
+
configPath,
|
|
93
|
+
cleanup() {
|
|
94
|
+
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
69
99
|
function applicationOptions(config, { outputDir, strict = false, watch = false } = {}) {
|
|
100
|
+
const { compilerOptions = {}, ...typedocOptions } = config.typedoc;
|
|
70
101
|
return {
|
|
71
102
|
...BASE_TYPEDOC_OPTIONS,
|
|
72
|
-
...
|
|
103
|
+
...typedocOptions,
|
|
73
104
|
entryPoints: config.entryPoints,
|
|
74
105
|
entryPointStrategy: 'resolve',
|
|
75
106
|
tsconfig: config.tsconfig,
|
|
107
|
+
compilerOptions: {
|
|
108
|
+
...compilerOptions,
|
|
109
|
+
noEmit: true,
|
|
110
|
+
rootDir: config.projectRoot,
|
|
111
|
+
},
|
|
76
112
|
out: outputDir ?? config.outputDir,
|
|
77
113
|
name: config.packageName,
|
|
78
114
|
emit: 'docs',
|
|
@@ -85,7 +121,26 @@ function applicationOptions(config, { outputDir, strict = false, watch = false }
|
|
|
85
121
|
}
|
|
86
122
|
|
|
87
123
|
export async function createDocsApplication(config, options = {}) {
|
|
88
|
-
|
|
124
|
+
const temporaryConfig = createEntrypointTsconfig({
|
|
125
|
+
tsconfig: config.tsconfig,
|
|
126
|
+
projectRoot: config.projectRoot,
|
|
127
|
+
entryPoints: config.entryPoints,
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
const app = await Application.bootstrapWithPlugins(
|
|
131
|
+
applicationOptions({ ...config, tsconfig: temporaryConfig.configPath }, options),
|
|
132
|
+
[new TSConfigReader()]
|
|
133
|
+
);
|
|
134
|
+
if (options.watch) {
|
|
135
|
+
process.once('exit', temporaryConfig.cleanup);
|
|
136
|
+
} else {
|
|
137
|
+
temporaryConfig.cleanup();
|
|
138
|
+
}
|
|
139
|
+
return app;
|
|
140
|
+
} catch (error) {
|
|
141
|
+
temporaryConfig.cleanup();
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
89
144
|
}
|
|
90
145
|
|
|
91
146
|
export async function buildDocs(config, { outputDir, strict = false } = {}) {
|
|
@@ -115,22 +170,28 @@ export async function watchDocs(config, { outputDir } = {}) {
|
|
|
115
170
|
return { app, ok: started };
|
|
116
171
|
}
|
|
117
172
|
|
|
118
|
-
export async function loadEntryPointProject({ entryPoint, tsconfig, packageName }) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
173
|
+
export async function loadEntryPointProject({ entryPoint, tsconfig, packageName, projectRoot }) {
|
|
174
|
+
const temporaryConfig = createEntrypointTsconfig({ tsconfig, projectRoot, entryPoints: [entryPoint] });
|
|
175
|
+
let app;
|
|
176
|
+
try {
|
|
177
|
+
app = await Application.bootstrap(
|
|
178
|
+
{
|
|
179
|
+
entryPoints: [entryPoint],
|
|
180
|
+
entryPointStrategy: 'resolve',
|
|
181
|
+
tsconfig: temporaryConfig.configPath,
|
|
182
|
+
name: packageName,
|
|
183
|
+
excludeInternal: true,
|
|
184
|
+
excludePrivate: true,
|
|
185
|
+
excludeProtected: true,
|
|
186
|
+
readme: 'none',
|
|
187
|
+
emit: 'none',
|
|
188
|
+
logLevel: 'Error',
|
|
189
|
+
},
|
|
190
|
+
[new TSConfigReader()]
|
|
191
|
+
);
|
|
192
|
+
} finally {
|
|
193
|
+
temporaryConfig.cleanup();
|
|
194
|
+
}
|
|
134
195
|
const project = await app.convert();
|
|
135
196
|
if (!project || app.logger.hasErrors()) {
|
|
136
197
|
throw new Error(`TypeDoc failed to resolve ${entryPoint}.`);
|