generate api docs
This commit is contained in:
1
packages/docs/.gitignore
vendored
1
packages/docs/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.asset-cache
|
||||
node_modules
|
||||
/api
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
"pino-colada": "^2.2.2",
|
||||
"pino-http": "^6.5.0",
|
||||
"postcss": "^8.4.5",
|
||||
"react-ssr-prepass": "^1.5.0",
|
||||
"reacord": "workspace:*",
|
||||
"react": "^18.0.0-rc.0",
|
||||
"react-dom": "^18.0.0-rc.0",
|
||||
"tailwindcss": "^3.0.8"
|
||||
"react-ssr-prepass": "^1.5.0",
|
||||
"tailwindcss": "^3.0.8",
|
||||
"typedoc": "^0.22.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/browser-sync": "^2.26.3",
|
||||
|
||||
29
packages/docs/src/api/serve-api-docs.ts
Normal file
29
packages/docs/src/api/serve-api-docs.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import express, { RequestHandler } from "express"
|
||||
import PromiseRouter from "express-promise-router"
|
||||
import * as TypeDoc from "typedoc"
|
||||
|
||||
let built = false
|
||||
const outputDir = "api"
|
||||
|
||||
export function serveApiDocs(): RequestHandler {
|
||||
return PromiseRouter()
|
||||
.use(async (_, __, next) => {
|
||||
if (!built) {
|
||||
const app = new TypeDoc.Application()
|
||||
app.options.addReader(new TypeDoc.TSConfigReader())
|
||||
app.options.addReader(new TypeDoc.TypeDocReader())
|
||||
app.bootstrap()
|
||||
|
||||
const project = app.convert()
|
||||
|
||||
if (!project) {
|
||||
throw new Error("Failed to convert project")
|
||||
}
|
||||
|
||||
await app.generateDocs(project, outputDir)
|
||||
built = true
|
||||
}
|
||||
next()
|
||||
})
|
||||
.use(express.static(outputDir))
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import httpTerminator from "http-terminator"
|
||||
import pino from "pino"
|
||||
import pinoHttp from "pino-http"
|
||||
import * as React from "react"
|
||||
import { serveApiDocs } from "./api/serve-api-docs"
|
||||
import { AssetBuilder } from "./asset-builder/asset-builder.js"
|
||||
import { fromProjectRoot } from "./constants"
|
||||
import { GuidePage } from "./guides/guide-page"
|
||||
@@ -24,6 +25,7 @@ const router = PromiseRouter()
|
||||
.use(pinoHttp({ logger }))
|
||||
.use(compression())
|
||||
.use(builder.middleware())
|
||||
.use("/api", serveApiDocs())
|
||||
|
||||
.get("/guides/*", async (req: Request<{ 0: string }>, res) => {
|
||||
res
|
||||
|
||||
12
packages/docs/typedoc.json
Normal file
12
packages/docs/typedoc.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"entryPoints": ["../reacord/library/main.ts"],
|
||||
"out": ["public/docs/api"],
|
||||
"tsconfig": "../reacord/tsconfig.json",
|
||||
"excludeInternal": true,
|
||||
"excludePrivate": true,
|
||||
"excludeProtected": true,
|
||||
"categorizeByGroup": false,
|
||||
"preserveWatchOutput": true,
|
||||
"githubPages": false,
|
||||
"readme": "none"
|
||||
}
|
||||
Reference in New Issue
Block a user