Merge pull request #8126 from gotson/todo-documentation

[Doc] add missing installation steps for the todo plugin
This commit is contained in:
Fredrik Adelöw
2021-11-18 11:16:45 +01:00
committed by GitHub
2 changed files with 84 additions and 0 deletions
+71
View File
@@ -2,6 +2,77 @@
This plugin lists `// TODO` comments in source code. It currently exports a single component extension for use on entity pages.
## Setup
1. Run:
```bash
# From your Backstage root directory
yarn --cwd packages/app add @backstage/plugin-todo
yarn --cwd packages/backend add @backstage/plugin-todo-backend
```
2. Add the plugin backend:
In a new file named `todo.ts` under `backend/src/plugins`:
```js
import { Router } from 'express';
import { CatalogClient } from '@backstage/catalog-client';
import {
createRouter,
TodoReaderService,
TodoScmReader,
} from '@backstage/plugin-todo-backend';
import { PluginEnvironment } from '../types';
export default async function createPlugin({
logger,
reader,
config,
discovery,
}: PluginEnvironment): Promise<Router> {
const todoReader = TodoScmReader.fromConfig(config, {
logger,
reader,
});
const catalogClient = new CatalogClient({ discoveryApi: discovery });
const todoService = new TodoReaderService({
todoReader,
catalogClient,
});
return await createRouter({ todoService });
}
```
And then add to `packages/backend/src/index.ts`:
```js
// In packages/backend/src/index.ts
import todo from './plugins/todo';
// ...
async function main() {
// ...
const todoEnv = useHotMemoize(module, () => createEnv('todo'));
// ...
apiRouter.use('/todo', await kafka(todoEnv));
```
3. Add the plugin as a tab to your service entities:
```jsx
// In packages/app/src/components/catalog/EntityPage.tsx
import { EntityTodoContent } from '@backstage/plugin-todo';
const serviceEntityPage = (
<EntityLayout>
{/* other tabs... */}
<EntityLayout.Route path="/todo" title="Todo">
<EntityTodoContent />
</EntityLayout.Route>
```
## Format
The default parser uses [Leasot](https://github.com/pgilad/leasot), which supports a wide range of languages. By default it supports the `TODO` and `FIXME` tags, along with `@` prefix and author reference through with either a `(<name>)` suffix or trailing `/<name>`. For more information on how to configure the parser, see `@backstage/plugin-todo-backend`.