feat(techdocs-cli): add --defaultPlugin argument to the generate command

Signed-off-by: Dominik Schwank <dominik.schwank@sda.se>
This commit is contained in:
Dominik Schwank
2023-07-26 11:57:36 +02:00
parent 10a86bd4ae
commit fe81abb8da
5 changed files with 11 additions and 13 deletions
+2 -13
View File
@@ -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.
+1
View File
@@ -141,6 +141,7 @@ Options:
if not found.
--etag <ETAG> A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored
in techdocs_metadata.json.
--defaultPlugin <PLUGIN_NAME> 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 <docs-dir>/README.md or README.md
+1
View File
@@ -37,6 +37,7 @@ Options:
-v --verbose
--omitTechdocsCoreMkdocsPlugin
--legacyCopyReadmeMdToIndexMd
--defaultPlugin [defaultPlugins...]
-h, --help
```
@@ -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,
},
},
},
@@ -70,6 +70,11 @@ export function registerCommands(program: Command) {
'Attempt to ensure an index.md exists falling back to using <docs-dir>/README.md or README.md in case a default <docs-dir>/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)));