@wtf/project-typedoc
v3.0.1
Published
The shared TypeDoc config for a docs package: the workspace's reference in markdown, with an llms.txt, each source linked to its file in the repository at a git revision (./config), and its plugins (./plugins). The schema of typedocConfig()'s options (./s
Readme
@wtf/project-typedoc
A shared TypeDoc config for a docs package. It writes the markdown reference of the workspace's
packages into api/, with an llms.txt, links each source to its file in your repository at a git
revision, and fails the build on a warning. TypeDoc, typedoc-plugin-markdown and
typedoc-plugin-llms-txt are peer dependencies.
| Subpath | What you get |
| ----------- | ------------------------------------------------------------------------------------------------------- |
| ./config | typedocConfig(), and gitRevisionOf(), the revision each source links to |
| ./plugins | cleanGeneratedMarkdown, preventMediaFiles and linkTrackedSources |
| ./schema | typedocSchema: the Standard Schema of the options of typedocConfig(), which gives their JSON Schema |
// packages/docs/typedoc.config.mjs
import { nodeStorage } from '@wtf/platform-fs-node/storage'
import { nodePlatform } from '@wtf/platform-node/platform'
import { typedocConfig } from '@wtf/project-typedoc/config'
export default typedocConfig({
platform: nodePlatform({ fetch, storage: nodeStorage() }),
docs: import.meta.url,
repository: 'https://gitlab.com/wetryfun/project/project',
entryPoints: ['../core', '../cli']
})The config reads nothing of the process. Your config file builds the platform, Node's here, and
passes it in: --gitRevision is read from the platform's argv, git runs by its spawn, paths
resolve by its path, and a relative docs folder is of its working folder. The config is async,
and TypeDoc awaits it.
Each source links to its file at --gitRevision <ref>, when you pass one to typedoc, and at the
commit of HEAD otherwise. Pass a plugin of TypeDoc of your own in plugins, a function of the
application or a module by its name: it runs after the preset's own, and before
typedoc-plugin-llms-txt and typedoc-plugin-markdown. See the
presets guide.
From the wtf configuration
The config reads no file of its own. Keep its options in the typedoc section of the repo's wtf
configuration, load it with @wtf/project-config, and spread the
section in, checked by typedocSchema. TypeDoc imports typedoc.config.mjs and awaits it, so the
config may await the load, and a wtf.config.ts is read too:
// packages/docs/typedoc.config.mjs
import { nodeStorage } from '@wtf/platform-fs-node/storage'
import { nodePlatform } from '@wtf/platform-node/platform'
import { loadConfig } from '@wtf/project-config/load'
import { sectionOf } from '@wtf/project-config/section'
import { typedocConfig } from '@wtf/project-typedoc/config'
import { typedocSchema } from '@wtf/project-typedoc/schema'
const platform = nodePlatform({ fetch, storage: nodeStorage() })
const config = await loadConfig({ platform })
export default typedocConfig({
platform,
docs: import.meta.url,
repository: 'https://gitlab.com/wetryfun/project/project',
entryPoints: ['../core', '../cli'],
...(await sectionOf(config, 'typedoc', typedocSchema))
})Any option of TypeDoc goes in the section too, as { "typedoc": { "treatWarningsAsErrors": false } }.
A key that starts with // is a comment, as "//": "why": typedocSchema takes it, at the top of
the section, and leaves it out of the options it gives.
