add basic api page
This commit is contained in:
@@ -2,43 +2,63 @@ const path = require('path')
|
|||||||
const globby = require('globby')
|
const globby = require('globby')
|
||||||
const TypeDoc = require('typedoc')
|
const TypeDoc = require('typedoc')
|
||||||
|
|
||||||
|
const packages = globby.sync('../packages/*', { onlyDirectories: true })
|
||||||
|
.map(name => name.replace('../packages/', ''))
|
||||||
|
.filter(name => name.startsWith('core'))
|
||||||
|
.map(name => {
|
||||||
|
const app = new TypeDoc.Application()
|
||||||
|
|
||||||
|
app.options.addReader(new TypeDoc.TSConfigReader())
|
||||||
|
app.options.addReader(new TypeDoc.TypeDocReader())
|
||||||
|
app.bootstrap({
|
||||||
|
ignoreCompilerErrors: true,
|
||||||
|
experimentalDecorators: true,
|
||||||
|
excludeExternals: true,
|
||||||
|
excludeNotExported: true,
|
||||||
|
excludeProtected: true,
|
||||||
|
excludePrivate: true,
|
||||||
|
// excludeNotDocumented: true,
|
||||||
|
exclude: [
|
||||||
|
"**/*.test.ts",
|
||||||
|
"**/__tests__/*",
|
||||||
|
"**/__mocks__/*"
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
const project = app.convert(app.expandInputFiles([`../packages/${name}`]))
|
||||||
|
|
||||||
|
if (project) {
|
||||||
|
// app.generateDocs(project, `api/${name}`)
|
||||||
|
// app.generateJson(project, `api/${name}.json`)
|
||||||
|
const json = app.serializer.projectToObject(project)
|
||||||
|
return json
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
.filter(package => !!package)
|
||||||
|
|
||||||
module.exports = function (api) {
|
module.exports = function (api) {
|
||||||
|
|
||||||
// api.loadSource(({ addCollection }) => {
|
api.loadSource(({ addCollection }) => {
|
||||||
// const appCollection = addCollection({ typeName: 'Package' })
|
const appCollection = addCollection({ typeName: 'Package' })
|
||||||
|
|
||||||
// globby.sync('../packages/*', { onlyDirectories: true })
|
packages.forEach(package => {
|
||||||
// .map(name => name.replace('../packages/', ''))
|
appCollection.addNode(package)
|
||||||
// .filter(name => name.startsWith('core'))
|
})
|
||||||
// .forEach(name => {
|
})
|
||||||
// const app = new TypeDoc.Application()
|
|
||||||
|
|
||||||
// app.options.addReader(new TypeDoc.TSConfigReader())
|
api.createPages(({ createPage }) => {
|
||||||
// app.options.addReader(new TypeDoc.TypeDocReader())
|
packages.forEach(package => {
|
||||||
// app.bootstrap({
|
createPage({
|
||||||
// ignoreCompilerErrors: true,
|
path: `/api/${package.name}`,
|
||||||
// experimentalDecorators: true,
|
component: './src/templates/ApiPage/index.vue',
|
||||||
// excludeExternals: true,
|
context: {
|
||||||
// excludeNotExported: true,
|
package,
|
||||||
// excludeProtected: true,
|
},
|
||||||
// excludePrivate: true,
|
})
|
||||||
// // excludeNotDocumented: true,
|
})
|
||||||
// exclude: [
|
})
|
||||||
// "**/*.test.ts",
|
|
||||||
// "**/__tests__/*",
|
|
||||||
// "**/__mocks__/*"
|
|
||||||
// ],
|
|
||||||
// })
|
|
||||||
|
|
||||||
// const project = app.convert(app.expandInputFiles([`../packages/${name}`]))
|
|
||||||
|
|
||||||
// if (project) {
|
|
||||||
// app.generateJson(project, `api/${name}.json`)
|
|
||||||
// const json = app.serializer.projectToObject(project)
|
|
||||||
// appCollection.addNode(json)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
api.chainWebpack(config => {
|
api.chainWebpack(config => {
|
||||||
config.resolve.extensions
|
config.resolve.extensions
|
||||||
|
|||||||
38
docs/src/templates/ApiPage/index.vue
Normal file
38
docs/src/templates/ApiPage/index.vue
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<template>
|
||||||
|
<Layout>
|
||||||
|
<div>
|
||||||
|
<div v-for="(file, i) in this.package.children" :key="i">
|
||||||
|
<h2>
|
||||||
|
{{ file.name }}
|
||||||
|
</h2>
|
||||||
|
<div v-for="(bla, j) in file.children" :key="j">
|
||||||
|
<template v-if="['Class', 'Method', 'Module'].includes(bla.kindString)">
|
||||||
|
<h3>
|
||||||
|
{{ bla.name }}
|
||||||
|
</h3>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
// props: {
|
||||||
|
// package: {
|
||||||
|
// default: null,
|
||||||
|
// type: Object
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
package() {
|
||||||
|
console.log(this.$context.package)
|
||||||
|
return this.$context.package
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" src="./style.scss" scoped></style>
|
||||||
0
docs/src/templates/ApiPage/style.scss
Normal file
0
docs/src/templates/ApiPage/style.scss
Normal file
Reference in New Issue
Block a user