Clean up changesets and addon package API surface.

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2022-04-11 10:43:48 +02:00
parent d26e1b0146
commit aaf51bd492
8 changed files with 21 additions and 38 deletions
+4 -2
View File
@@ -1,5 +1,7 @@
---
'@backstage/plugin-techdocs-addons': minor
'@backstage/techdocs-addons': minor
---
Introducing an addon framework for TechDocs.
Introducing `@backstage/techdocs-addons`, a web library you can use to create TechDocs addons.
Note: this package is not necessarily stable yet. After iteration on this package, its stability will be signaled by a major-version bump.
@@ -1,5 +0,0 @@
---
'@backstage/plugin-techdocs-addons': patch
---
Separation between contexts and hooks
+3 -5
View File
@@ -2,15 +2,14 @@
'@backstage/plugin-techdocs': minor
---
TechDocs now supports a new method of customization: addons!
TechDocs supports a new, experimental method of customization: addons!
To customize the standalone TechDocs reader page experience, update your `/packages/app/src/App.tsx` in the following way:
```diff
import { TechDocsIndexPage, TechDocsReaderPage } from '@backstage/plugin-techdocs';
+ import { TechDocsAddons } from '@backstage/plugin-techdocs-addons';
+ import { TechDocsAddons } from '@backstage/techdocs-addons';
+ import { SomeAddon } from '@backstage/plugin-some-plugin';
- import { techDocsPage } from './components/techdocs/TechDocsPage';
// ...
@@ -19,7 +18,6 @@ import { TechDocsIndexPage, TechDocsReaderPage } from '@backstage/plugin-techdoc
path="/docs/:namespace/:kind/:name/*"
element={<TechDocsReaderPage />}
>
- {techDocsPage}
+ <TechDocsAddons>
+ <SomeAddon />
+ </TechDocsAddons>
@@ -32,7 +30,7 @@ To customize the TechDocs reader experience on the Catalog entity page, update y
```diff
import { EntityTechdocsContent } from '@backstage/plugin-techdocs';
+ import { TechDocsAddons } from '@backstage/plugin-techdocs-addons';
+ import { TechDocsAddons } from '@backstage/techdocs-addons';
+ import { SomeAddon } from '@backstage/plugin-some-plugin';
// ...
+6 -10
View File
@@ -3,23 +3,19 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { AsyncState } from 'react-use/lib/useAsyncFn';
import { ComponentType } from 'react';
import { Extension } from '@backstage/core-plugin-api';
import { default as React_2 } from 'react';
// @public
// @alpha
export function createTechDocsAddon<TComponentProps>(
options: TechDocsAddonOptions<TComponentProps>,
): Extension<ComponentType<TComponentProps>>;
// @public
// @alpha
export const TECHDOCS_ADDONS_WRAPPER_KEY = 'techdocs.addons.wrapper.v1';
// @public
export type TechDocsAddonAsyncMetadata<TValue> = AsyncState<TValue | undefined>;
// @public
// @alpha
export enum TechDocsAddonLocations {
CONTENT = 'content',
HEADER = 'header',
@@ -28,17 +24,17 @@ export enum TechDocsAddonLocations {
SUBHEADER = 'subheader',
}
// @public
// @alpha
export type TechDocsAddonOptions<TAddonProps = {}> = {
name: string;
location: TechDocsAddonLocations;
component: ComponentType<TAddonProps>;
};
// @public
// @alpha
export const TechDocsAddons: React_2.ComponentType;
// @public
// @alpha
export const useTechDocsAddons: () => {
renderComponentByName: (name: string) => React_2.ReactElement<
{
+1 -2
View File
@@ -42,8 +42,7 @@
"@material-ui/styles": "^4.11.0",
"jss": "~10.8.2",
"react-helmet": "6.1.0",
"react-router-dom": "6.0.0-beta.0",
"react-use": "^17.2.4"
"react-router-dom": "6.0.0-beta.0"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
+4 -4
View File
@@ -31,13 +31,13 @@ export const TECHDOCS_ADDONS_KEY = 'techdocs.addons.addon.v1';
/**
* Marks the <TechDocsAddons> registry component.
* @public
* @alpha
*/
export const TECHDOCS_ADDONS_WRAPPER_KEY = 'techdocs.addons.wrapper.v1';
/**
* TechDocs Addon registry.
* @public
* @alpha
*/
export const TechDocsAddons: React.ComponentType = () => null;
@@ -49,7 +49,7 @@ const getDataKeyByName = (name: string) => {
/**
* Create a TechDocs addon.
* @public
* @alpha
*/
export function createTechDocsAddon<TComponentProps>(
options: TechDocsAddonOptions<TComponentProps>,
@@ -93,7 +93,7 @@ const getAllTechDocsAddonsData = (collection: ElementCollection) => {
/**
* hook to use addons in components
* @public
* @alpha
*/
export const useTechDocsAddons = () => {
const node = useOutlet();
+1 -1
View File
@@ -27,4 +27,4 @@ export {
TECHDOCS_ADDONS_WRAPPER_KEY,
} from './addons';
export { TechDocsAddonLocations } from './types';
export type { TechDocsAddonAsyncMetadata, TechDocsAddonOptions } from './types';
export type { TechDocsAddonOptions } from './types';
+2 -9
View File
@@ -15,11 +15,10 @@
*/
import { ComponentType } from 'react';
import { AsyncState } from 'react-use/lib/useAsyncFn';
/**
* Locations for which TechDocs addons may be declared and rendered.
* @public
* @alpha
*/
export enum TechDocsAddonLocations {
/**
@@ -79,16 +78,10 @@ export enum TechDocsAddonLocations {
/**
* Options for creating a TechDocs addon.
* @public
* @alpha
*/
export type TechDocsAddonOptions<TAddonProps = {}> = {
name: string;
location: TechDocsAddonLocations;
component: ComponentType<TAddonProps>;
};
/**
* Common response envelope for addon-related hooks.
* @public
*/
export type TechDocsAddonAsyncMetadata<TValue> = AsyncState<TValue | undefined>;