Isaac Mann 12eb5df469
docs(core): powerpack docs (#27904)
-  Activate powerpack recipe
-  Powerpack owners documentation
- [x] Powerpack custom remote cache documentation
- [x] Powerpack conformance documentation

Infrastructure for powerpack docs

- Adds the ability to generate API docs from ocean packages

To generate API documentation for plugins in the ocean repository, run
the `nx documentation` command with the `NX_OCEAN_RELATIVE_PATH`
environment variable set to the relative path to your checked out copy
of the ocean repo.

```
NX_OCEAN_RELATIVE_PATH=../ocean nx documentation
```

This will create generated API documentation in the
`docs/external-generated` folder. This API will be merged into the
normal `docs/generated` documentation when the docs site is built.

Because there are two separate output folders, if someone runs `nx
documentation` without the `NX_OCEAN_RELATIVE_PATH` environment
variable, the ocean documentation will not be overwritten. The ocean
documentation will only be updated or deleted when someone explicitly
chooses to do so.

---------

Co-authored-by: Juri Strumpflohner <juri.strumpflohner@gmail.com>
2024-09-25 10:15:47 -04:00

72 lines
2.0 KiB
TypeScript

import * as chalk from 'chalk';
import { execSync } from 'child_process';
import { removeSync } from 'fs-extra';
import { join, resolve } from 'path';
import {
generateExternalPackageSchemas,
generateLocalPackageSchemas,
generatePackageSchemas,
} from '../package-schemas/generatePackageSchemas';
import { generateCliDocumentation } from './generate-cli-data';
import { generateCnwDocumentation } from './generate-cnw-documentation';
import { generateDevkitDocumentation } from './generate-devkit-documentation';
import { generateManifests } from './generate-manifests';
const workspaceRoot = resolve(__dirname, '../../../');
async function generate() {
try {
console.log(`${chalk.blue('i')} Generating Documentation`);
const generatedOutputDirectory = join(workspaceRoot, 'docs', 'generated');
removeSync(generatedOutputDirectory);
const commandsOutputDirectory = join(
workspaceRoot,
'docs',
'generated',
'cli'
);
await generateCnwDocumentation(commandsOutputDirectory);
await generateCliDocumentation(commandsOutputDirectory);
await generateDevkitDocumentation();
await generateLocalPackageSchemas();
await generateExternalPackageSchemas();
await generateManifests(workspaceRoot);
console.log(`\n${chalk.green('✓')} Generated Documentation\n`);
} catch (e) {
console.error(e);
process.exit(1);
}
}
function checkDocumentation() {
const output = execSync('git status --porcelain ./docs', {
windowsHide: true,
}).toString('utf-8');
if (output) {
console.log(
`${chalk.red(
'!'
)} 📄 Documentation has been modified, you need to commit the changes. ${chalk.red(
'!'
)} `
);
console.log('\nChanged Docs:');
execSync('git status --porcelain ./docs', {
stdio: 'inherit',
windowsHide: true,
});
process.exit(1);
} else {
console.log('📄 Documentation not modified');
}
}
generate().then(() => checkDocumentation());