From 39b96e42444d7d7390ab5743f70235806be637c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 18 Aug 2020 09:36:26 +0200 Subject: [PATCH] add basic api page --- docs/gridsome.server.js | 86 +++++++++++++++++---------- docs/src/templates/ApiPage/index.vue | 38 ++++++++++++ docs/src/templates/ApiPage/style.scss | 0 3 files changed, 91 insertions(+), 33 deletions(-) create mode 100644 docs/src/templates/ApiPage/index.vue create mode 100644 docs/src/templates/ApiPage/style.scss diff --git a/docs/gridsome.server.js b/docs/gridsome.server.js index 7ba89cd8c..43c1ba5ef 100644 --- a/docs/gridsome.server.js +++ b/docs/gridsome.server.js @@ -2,43 +2,63 @@ const path = require('path') const globby = require('globby') 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) { - // api.loadSource(({ addCollection }) => { - // const appCollection = addCollection({ typeName: 'Package' }) + api.loadSource(({ addCollection }) => { + const appCollection = addCollection({ typeName: 'Package' }) - // globby.sync('../packages/*', { onlyDirectories: true }) - // .map(name => name.replace('../packages/', '')) - // .filter(name => name.startsWith('core')) - // .forEach(name => { - // const app = new TypeDoc.Application() + packages.forEach(package => { + appCollection.addNode(package) + }) + }) - // 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.generateJson(project, `api/${name}.json`) - // const json = app.serializer.projectToObject(project) - // appCollection.addNode(json) - // } - // }) - // }) + api.createPages(({ createPage }) => { + packages.forEach(package => { + createPage({ + path: `/api/${package.name}`, + component: './src/templates/ApiPage/index.vue', + context: { + package, + }, + }) + }) + }) api.chainWebpack(config => { config.resolve.extensions diff --git a/docs/src/templates/ApiPage/index.vue b/docs/src/templates/ApiPage/index.vue new file mode 100644 index 000000000..54c64f100 --- /dev/null +++ b/docs/src/templates/ApiPage/index.vue @@ -0,0 +1,38 @@ + + + + + \ No newline at end of file diff --git a/docs/src/templates/ApiPage/style.scss b/docs/src/templates/ApiPage/style.scss new file mode 100644 index 000000000..e69de29bb