Integration of vue-docgen-cli with vuepress 2
npm add --save vuepress-plugin-vue-docgen
# pnpm add vuepress-plugin-vue-docgen
# yarn add vuepress-plugin-vue-docgen
// .vuepress/config.ts
import { defineUserConfig } from 'vuepress';
import { VueDocgenPlugin } from 'vuepress-plugin-docgen';
export default defineUserConfig({
plugins: [
VueDocgenPlugin({
docgenCliConfigPath: null,
docgenCliConfig: null,
groups: 'components/**/*.vue',
}),
],
});
Partial<Omit<DocgenCLIConfig, 'outDir' | 'components'>>
false
Config for vue-docgen-cli
.
🔥 If you need change docgenCliConfig.templates.component
and save functionality of frontmatter
, you need use extractAndCutFrontmatter
.
string
false
File path to docgenCliConfig
. Worked only commonjs
syntax.
interface VueDocgenPluginGroup {
// Root of component (this part of file path would cutted)
root?: string;
// Glob string for find components
components: string | string[];
// Out path of docs in vuepress app for this group
outDir?: string;
// Custom docgenCliConfig for current group
docgenCliConfig?: Partial<Omit<DocgenCLIConfig, 'outDir' | UsedInVueDocgenConfigProcessingProperties>>;
}
string | string[] | VueDocgenPluginGroup[]
false
[{ components: ['**/components/**/*.vue', '!**/node_modules/**', '!**/.vuepress/**'] }]
List of component entries with custom root
and outDir
. string
types converted like this groups: '*.vue'
-> groups: [{ components: '*.vue' }]
.
boolean
true
Mode for generation files in tmp folder.
For right integration with frontmatter
, docgenCliConfig.templates.component
modified by this plugin to use and merge frontmatter
from ComponentDoc.docsBlocks
. Full usage code in /src/templates/component.ts
export const extractAndCutFrontmatter = (
// doc.docsBlocks will modified by this function
doc: Partial<Pick<ComponentDoc, 'docsBlocks'>>,
grayMatterOptions: GrayMatterOption<any, any>,
// Base markdown content (for example result of original templates.component)
content = '',
): {
// Content with injected all frontmatter
content: string;
// Separated frontmatter
frontmatter: Record<any, any>;
} => {}
"Edit this page" in stateless: true
mode will not work correctly and lead to a non-existent file.
Because it, editLink
disabled in stateless: true
mode by default.
Solutions:
stateless: false
and save all generated files in repodocgenCliConfig.getRepoEditUrl
and their sub-properties like docsRepo
, docsBranch
.