Updates the docs structure, navigation etc to be easier + better suited for showing Nx technology support beyond just TS. **Notes:** - API (`/nx-api`) tab is removed from the navigation (i.e. menu bar), but pages still remain for now until we update references in `*.md` files. - Redirects are set up `/nx-api` to go to their respect new location e.g. `/technologies` or `/reference/core-api` - Old URLs still exist in the sitemap for now, but majority of them will be redirected -- a follow-up PR can remove them. **Preview:** https://nx-dev-git-nx-dev-polyglot-docs-restructure-nrwl.vercel.app/docs --------- Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
103 lines
2.9 KiB
TypeScript
103 lines
2.9 KiB
TypeScript
import * as chalk from 'chalk';
|
|
import * as typedoc from 'typedoc';
|
|
import { execSync, ExecSyncOptions } from 'child_process';
|
|
import { cpSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
export async function generateDevkitDocumentation() {
|
|
console.log(`\n${chalk.blue('i')} Generating Documentation for Devkit\n`);
|
|
|
|
const execSyncOptions: ExecSyncOptions = {
|
|
stdio: 'true' === 'true' ? 'inherit' : 'ignore',
|
|
// stdio: process.env.CI === 'true' ? 'inherit' : 'ignore',
|
|
windowsHide: false,
|
|
};
|
|
|
|
rmSync('node_modules/@nx/typedoc-theme', { recursive: true, force: true });
|
|
|
|
cpSync('dist/typedoc-theme', 'node_modules/@nx/typedoc-theme', {
|
|
recursive: true,
|
|
});
|
|
|
|
cpSync(
|
|
'packages/devkit/tsconfig.lib.json',
|
|
'build/packages/devkit/tsconfig.lib.json',
|
|
{ recursive: true }
|
|
);
|
|
|
|
writeFileSync(
|
|
'build/packages/devkit/tsconfig.lib.json',
|
|
readFileSync('build/packages/devkit/tsconfig.lib.json')
|
|
.toString()
|
|
.replace(
|
|
'"extends": "./tsconfig.json"',
|
|
'"extends": "../../../packages/devkit/tsconfig.json"'
|
|
)
|
|
);
|
|
|
|
rmSync('docs/generated/devkit', { recursive: true, force: true });
|
|
|
|
const commonTypedocOptions: Partial<typedoc.TypeDocOptions> & {
|
|
[key: string]: unknown;
|
|
} = {
|
|
plugin: ['typedoc-plugin-markdown', '@nx/typedoc-theme'],
|
|
disableSources: true,
|
|
theme: 'nx-markdown-theme',
|
|
readme: 'none',
|
|
hideBreadcrumbs: true,
|
|
allReflectionsHaveOwnDocument: true,
|
|
} as const;
|
|
|
|
await runTypedoc({
|
|
...commonTypedocOptions,
|
|
entryPoints: ['build/packages/devkit/index.d.ts'],
|
|
tsconfig: 'build/packages/devkit/tsconfig.lib.json',
|
|
out: 'docs/generated/devkit',
|
|
excludePrivate: true,
|
|
publicPath: '/reference/core-api/devkit/',
|
|
});
|
|
|
|
await runTypedoc({
|
|
...commonTypedocOptions,
|
|
entryPoints: ['build/packages/devkit/ngcli-adapter.d.ts'],
|
|
tsconfig: 'build/packages/devkit/tsconfig.lib.json',
|
|
out: 'docs/generated/devkit/ngcli_adapter',
|
|
publicPath: '/reference/core-api/devkit/ngcli_adapter/',
|
|
});
|
|
|
|
rmSync('build/packages/devkit/tsconfig.lib.json', {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
rmSync('docs/generated/devkit/.nojekyll', { recursive: true, force: true });
|
|
|
|
execSync(
|
|
`pnpm prettier docs/generated/devkit --write --config ${join(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'..',
|
|
'.prettierrc'
|
|
)}`,
|
|
execSyncOptions
|
|
);
|
|
}
|
|
|
|
async function runTypedoc(
|
|
options: Partial<typedoc.TypeDocOptions> & { [key: string]: unknown }
|
|
) {
|
|
const app = await typedoc.Application.bootstrapWithPlugins(
|
|
options as Partial<typedoc.TypeDocOptions>,
|
|
[
|
|
new typedoc.TypeDocReader(),
|
|
new typedoc.PackageJsonReader(),
|
|
new typedoc.TSConfigReader(),
|
|
]
|
|
);
|
|
const project = await app.convert();
|
|
if (!project) {
|
|
throw new Error('Failed to convert the project');
|
|
}
|
|
await app.generateDocs(project, app.options.getValue('out'));
|
|
}
|