Skip to content

Commit

Permalink
docs: integrate TypeDocs into vuepress output
Browse files Browse the repository at this point in the history
# What's changed?

* create sidebar from typedoc output
* use plugin markdown to generate typedoc as markdown
  • Loading branch information
bcakmakoglu committed Jun 12, 2022
1 parent 669f9a0 commit be5df65
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 6 deletions.
7 changes: 5 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"private": true,
"scripts": {
"dev": "vuepress dev src",
"build": "vuepress build src",
"lint": "eslint --ext \".js,.jsx,.ts,.tsx\" --fix --ignore-path .gitignore ."
"build": "vuepress build src && pnpm run typedoc",
"lint": "eslint --ext \".js,.jsx,.ts,.tsx\" --fix --ignore-path .gitignore .",
"typedoc": "typedoc --options ./typedoc.json"
},
"dependencies": {
"@animxyz/core": "^0.6.6",
Expand All @@ -26,6 +27,8 @@
"@windicss/plugin-scrollbar": "^1.2.3",
"dotenv": "^16.0.1",
"ohmyfetch": "^0.4.18",
"typedoc": "^0.22.17",
"typedoc-plugin-markdown": "^3.12.1",
"unplugin-auto-import": "^0.6.9",
"unplugin-icons": "^0.14.3",
"unplugin-vue-components": "^0.18.5",
Expand Down
3 changes: 1 addition & 2 deletions docs/src/.vuepress/copy-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ export function copyVueFlowPlugin(): Plugin {
return {
name: 'copy-vue-flow',
generateBundle() {
console.log('building')
const filePath = resolve(
__dirname,
'../../node_modules/@braks/vue-flow/dist/vue-flow.es.js'
)
if (!existsSync(filePath)) {
throw new Error(
`@braks/vue-flow/dist/vue-flow.es.js not built. ` +
`Run "pnpm build" first.`
`Run "pnpm -w build" first.`
)
}
this.emitFile({
Expand Down
36 changes: 34 additions & 2 deletions docs/src/.vuepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
import { resolve } from 'path'
import { defaultTheme, Theme } from 'vuepress'
import { defaultTheme, SidebarConfigArray, Theme } from 'vuepress'
import { path } from '@vuepress/utils'
import { useVueFlow } from '@braks/vue-flow'
import { readdirSync } from 'fs'

const { vueFlowVersion } = useVueFlow()

const typedocSidebarEntries = (): SidebarConfigArray => {
const filePath = resolve(
__dirname,
'../../typedocs'
)

const classes = readdirSync(`${filePath}/classes/`).map(entry => `/typedocs/classes/${entry}`)
const enums = readdirSync(`${filePath}/enums/`).map(entry => `/typedocs/enums/${entry}`)
const interfaces = readdirSync(`${filePath}/interfaces/`).map(entry => `/typedocs/interfaces/${entry}`)
const modules = readdirSync(`${filePath}/modules/`).map(entry => `/typedocs/modules/${entry}`)

return [
{
text: 'TypeDocs',
link: '/typedocs/',
children: [
{ text: 'Exports', children: ['/typedocs/modules.md'] },
{ text: 'Modules', children: modules },
{ text: 'Classes', children: classes },
{ text: 'Enums', children: enums },
{ text: 'Interfaces', children: interfaces },
],
}
]
}

export default {
name: 'vuepress-theme-local',
extends: defaultTheme({
Expand Down Expand Up @@ -61,6 +88,7 @@ export default {
],
},
],
'/typedocs/': typedocSidebarEntries(),
},
navbar: [
{ text: `v${vueFlowVersion.value}`, link: '' },
Expand All @@ -70,7 +98,11 @@ export default {
link: '/examples/',
activeMatch: '^/examples/',
},
{ text: 'TypeDocs', link: 'https://types.vueflow.dev/' },
{
text: 'TypeDocs',
link: '/typedocs/',
activeMatch: '^/typedocs/',
},
],
}),
layouts: {
Expand Down
7 changes: 7 additions & 0 deletions docs/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://typedoc.org/schema.json",
"plugin": "typedoc-plugin-markdown",
"entryPoints": ["../packages/vue-flow/src/index.ts"],
"out": "src/typedocs",
"tsconfig": "../packages/vue-flow/tsconfig.docs.json"
}
37 changes: 37 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit be5df65

Please sign in to comment.