diff --git a/docs/features/techdocs/extensions.md b/docs/features/techdocs/extensions.md new file mode 100644 index 0000000000..c92939ad0b --- /dev/null +++ b/docs/features/techdocs/extensions.md @@ -0,0 +1,54 @@ +--- +id: extensions +title: Using TechDocs Extensions +sidebar_label: Using TechDocs Extensions +description: How to use the built-in TechDocs extension points +--- + +# TechDocs Backend Extensions + +The TechDocs backend plugin provides the following extension points: + +- `techdocsBuildsExtensionPoint` +- `techdocsGeneratorExtensionPoint` +- `techdocsPreparerExtensionPoint` +- `techdocsPublisherExtensionPoint` + +## Build Extensions + +### Set Log Transport + +By default, the TechDocs build phase does not log out much information while building out TechDocs. However, the +`techdocsBuildsExtensionPoint` can be used to setup a custom Winston transport for TechDocs build logs. + +Here is an example of logging to console: + +```typescript jsx title="packages/backend/src/extensions/techDocsExtension.ts" +import { techdocsBuildsExtensionPoint } from '@backstage/plugin-techdocs-backend'; +import { createBackendModule } from '@backstage/backend-plugin-api'; +import { transports } from 'winston'; + +export const techDocsExtension = createBackendModule({ + pluginId: 'techdocs', + moduleId: 'extension', + register(env) { + env.registerInit({ + deps: { + build: techdocsBuildsExtensionPoint, + }, + async init({ build }) { + // You can obviously use any custom transport here... + build.setBuildLogTransport(new transports.Console()); + }, + }); + }, +}); +``` + +And then of course register this extension with the backend: + +```typescript jsx title="packages/backend/src/index.ts" +import {techDocsExtension} from "./extensions/techDocsExtension"; +... +backend.add(techDocsExtension()); +``` diff --git a/mkdocs.yml b/mkdocs.yml index b2d0a5489d..aa545111d4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -85,6 +85,7 @@ nav: - Configuring CI/CD to generate and publish TechDocs sites: 'features/techdocs/configuring-ci-cd.md' - CLI: 'features/techdocs/cli.md' - HOW TO guides: 'features/techdocs/how-to-guides.md' + - Extensions: 'features/techdocs/extensions.md' - Troubleshooting: 'features/techdocs/troubleshooting.md' - FAQ: 'features/techdocs/FAQ.md' - Integrations: