diff --git a/.changeset/twelve-elephants-pay.md b/.changeset/twelve-elephants-pay.md index f82b0464b0..08fb983b6f 100644 --- a/.changeset/twelve-elephants-pay.md +++ b/.changeset/twelve-elephants-pay.md @@ -1,18 +1,7 @@ --- '@backstage/plugin-techdocs-backend': minor '@backstage/plugin-techdocs-node': minor +'@techdocs/cli': minor --- -Add support for default mkdocs plugins. - -So far only `techdocs-core` was added as default to the list of mkdocs plugins. In case you use a -custom image for techdocs, you also might want to add custom default plugins for mkdocs. -With this change one can do that - example: - -```yaml -techdocs: - generator: - mkdocs: - defaultPlugins: - - section-index -``` +Add optional config and cli option for techdocs to specify default mkdocs plugins. diff --git a/docs/features/techdocs/cli.md b/docs/features/techdocs/cli.md index 76589de5a8..87eb67d04a 100644 --- a/docs/features/techdocs/cli.md +++ b/docs/features/techdocs/cli.md @@ -141,6 +141,7 @@ Options: if not found. --etag A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json. + --defaultPlugin Plugins which should be added automatically to the mkdocs.yaml file. (default: []) --omitTechdocsCoreMkdocsPlugin An option to disable automatic addition of techdocs-core plugin to the mkdocs.yaml files. Defaults to false, which means that the techdocs-core plugin is always added to the mkdocs file. --legacyCopyReadmeMdToIndexMd Attempt to ensure an index.md exists falling back to using /README.md or README.md diff --git a/packages/techdocs-cli/cli-report.md b/packages/techdocs-cli/cli-report.md index 556068de85..5f148daf24 100644 --- a/packages/techdocs-cli/cli-report.md +++ b/packages/techdocs-cli/cli-report.md @@ -37,6 +37,7 @@ Options: -v --verbose --omitTechdocsCoreMkdocsPlugin --legacyCopyReadmeMdToIndexMd + --defaultPlugin [defaultPlugins...] -h, --help ``` diff --git a/packages/techdocs-cli/src/commands/generate/generate.ts b/packages/techdocs-cli/src/commands/generate/generate.ts index 5d80beb38a..934eaf1efd 100644 --- a/packages/techdocs-cli/src/commands/generate/generate.ts +++ b/packages/techdocs-cli/src/commands/generate/generate.ts @@ -47,6 +47,7 @@ export default async function generate(opts: OptionValues) { const dockerImage = opts.dockerImage; const pullImage = opts.pull; const legacyCopyReadmeMdToIndexMd = opts.legacyCopyReadmeMdToIndexMd; + const defaultPlugins = opts.defaultPlugin; logger.info(`Using source dir ${sourceDir}`); logger.info(`Will output generated files in ${outputDir}`); @@ -68,6 +69,7 @@ export default async function generate(opts: OptionValues) { mkdocs: { legacyCopyReadmeMdToIndexMd, omitTechdocsCorePlugin, + defaultPlugins, }, }, }, diff --git a/packages/techdocs-cli/src/commands/index.ts b/packages/techdocs-cli/src/commands/index.ts index 98816a6b32..3321bb7f43 100644 --- a/packages/techdocs-cli/src/commands/index.ts +++ b/packages/techdocs-cli/src/commands/index.ts @@ -70,6 +70,11 @@ export function registerCommands(program: Command) { 'Attempt to ensure an index.md exists falling back to using /README.md or README.md in case a default /index.md is not provided.', false, ) + .option( + '--defaultPlugin [defaultPlugins...]', + 'Plugins which should be added automatically to the mkdocs.yaml file', + [], + ) .alias('build') .action(lazy(() => import('./generate/generate').then(m => m.default)));