Skip to content

Commit

Permalink
Add optional note feature to plugin docs generator
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Aug 31, 2024
1 parent 70bf705 commit 9a11e1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/docs/scripts/generate-plugin-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ for await (const dir of directories) {
const pluginDir = path.join(pluginsDir, pluginName);
const plugin: Plugin = (await import(path.join(pluginDir, 'index.ts'))).default;

const { title, enablers, config, entry, production, project } = plugin;
const { title, enablers, note, config, entry, production, project } = plugin;

plugins.push([title, pluginName]);

Expand Down Expand Up @@ -76,10 +76,13 @@ for await (const dir of directories) {
? parseFragment(enablers)
: [u('paragraph', [u('text', 'N/A')])];

const n = note ? [u('heading', { depth: 2 }, [u('text', 'Note')]), ...parseFragment(note)] : [];

const tree = u('root', [
frontmatter,
u('heading', { depth: 2 }, [u('text', 'Enabled')]),
...en,
...n,
u('heading', { depth: 2 }, [u('text', 'Default configuration')]),
...parseFragment('This configuration is added automatically if the plugin is enabled:'),
u('code', {
Expand Down
1 change: 1 addition & 0 deletions packages/knip/src/types/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type Resolve = (options: PluginOptions) => Promise<string[]> | string[];
export interface Plugin {
title: string;
enablers: IgnorePatterns | string;
note?: string;
packageJsonPath?: string | ((manifest: PackageJson) => string);
isEnabled: IsPluginEnabled;
config?: string[];
Expand Down

0 comments on commit 9a11e1c

Please sign in to comment.