Development Workflow
This guide covers how to work with docsgen during development, including the dev server, watch mode, the concurrency guard that prevents duplicate runs, log levels for debugging, and solutions for common issues.
- Dev server - Understand how docsgen runs during
docusaurus start. - Watch mode - Enable live regeneration when source files change.
- Concurrency guard - Know how the minute-level lock prevents duplicate runs.
- Debugging - Use log levels and output inspection to troubleshoot problems.
- Troubleshooting - Fix common issues with generation and the importer.
Running the Dev Server
When you run docusaurus start, Docusaurus loads all plugins, including @docsgen/docusaurus. The
plugin runs the full generation pipeline on startup:
npm run start
docsgen parses your TypeScript source, generates MDX files, and writes them to your outDir. Docusaurus
then picks up these files and serves them. You can browse the generated API pages immediately.
Watch Mode
By default, docsgen runs once at startup. To regenerate documentation automatically when your source files change, enable watch mode:
[
"@docsgen/docusaurus",
{
id: "api",
outDir: "docs/api",
packages: [/* ... */],
watch: true,
},
],
With watch: true, TypeDoc uses its convertAndWatch mode. When you edit a TypeScript source file,
TypeDoc detects the change, re-parses the project, and docsgen regenerates the affected MDX pages.
Docusaurus's hot-reload then picks up the changed files and refreshes the browser.
Watch mode re-runs the full TypeDoc parse on every source change. For large projects with many entry points, this can be slow. Consider using watch mode only during active API documentation work, and disabling it when working on guides or site styling.
The Concurrency Guard
The Docusaurus plugin includes a concurrency guard that prevents duplicate generation runs. This is important because Docusaurus may reload the plugin multiple times during development (e.g., when configuration files change).
How It Works
The plugin writes a timestamp file (loadingTypedoc[{id}].json) to Docusaurus's generatedFilesDir.
On each load, it compares the current time with the saved timestamp. If they match within the same
minute (ISO string comparison with the last 8 characters stripped), the plugin skips generation.
In practice, this means:
- First load - Always runs generation (no timestamp file exists).
- Subsequent loads within the same minute - Skips generation (reuses existing output).
- Loads after one minute - Runs generation again.
What This Means for Development
If you restart the dev server quickly (within a minute), docsgen will not re-run. This speeds up rapid restart cycles. If you need to force regeneration, either:
- Wait for the next minute boundary, or
- Delete the lock file from Docusaurus's generated files directory, or
- Stop the dev server, run
npm run buildto do a full rebuild, then restart.
Log Levels
docsgen supports configurable log levels to help you understand what is happening during generation:
[
"@docsgen/docusaurus",
{
id: "api",
outDir: "docs/api",
packages: [/* ... */],
logLevel: "trace",
},
],
| Level | What it shows |
|---|---|
error | Only errors that prevent generation |
warning | Errors and warnings (e.g., missing tsconfig) |
success | Errors, warnings, and success messages |
info | General progress information (default) |
trace | Everything, including detailed step-by-step output |
When to Use Each Level
info- Normal development. Shows enough to confirm generation ran successfully.trace- Debugging generation issues. Shows which files are being processed, which reflections are found, and how pages are rendered.error- CI/CD pipelines where you only want to know about failures.
Inspecting Generated Output
When troubleshooting, check the generated files directly:
options.json
Located at the root of your outDir (e.g., docs/api/options.json). Contains the serialized plugin
options. The importer reads this file to resolve @import directives.
ls docs/api/options.json
If this file is missing, the plugin did not run. Check:
- Is
@docsgen/docusaurusin yourpluginsarray? - Did the concurrency guard skip generation?
- Are there errors in the console?
docs.json
Located in each package's subdirectory (e.g., docs/api/core/docs.json). Contains the TypeDoc JSON
reflection output. This is the raw data that drives page generation.
ls docs/api/core/docs.json
If this file is missing or empty, TypeDoc failed to parse the package. Check:
- Does the
entryPathexist? - Does the
tsconfig.jsoncompile without errors? - Are there TypeDoc errors in the console?
package-config.json
Contains metadata about each package (title, paths). Used internally by the importer.
Troubleshooting
Generation does not run
Symptom: No files appear in outDir after starting the dev server.
Possible causes:
- Plugin not configured - Verify
@docsgen/docusaurusis in thepluginsarray of yourdocusaurus.config.ts. - Concurrency guard - The plugin skipped generation because a run happened within the last minute. Wait a minute or delete the lock file.
- Build error - Check the console for errors. Set
logLevel: "trace"for detailed output.
Importer shows raw @import text
Symptom: @import directives appear as plain text instead of rendered content.
Possible causes:
- Importer not configured - Add the
importerremark plugin to your docs preset. See Importer for setup instructions. - Missing options.json - The importer cannot find the generated options file. Verify that
apiDirin the importer config matchesoutDirin the plugin config. - Package name mismatch - The package title in the
@importdirective must match thetitlein your package configuration. - Symbol not found - The symbol name in the
@importdirective must match an exported symbol exactly (case-sensitive).
TypeDoc errors
Symptom: Generation runs but produces errors or incomplete output.
Possible causes:
- TypeScript compilation errors - TypeDoc requires your project to compile. Fix any TypeScript errors first.
- Wrong tsconfig - Verify that
tsconfigDirandtsconfigNamepoint to the correcttsconfig.jsonfile. - Missing entry point - Verify that
entryPathresolves to an existing file relative todir. - Plugin conflicts - Custom
typeDocOptionsmay conflict with docsgen's defaults. Check for conflictingentryPointStrategyorpluginsettings.
Stale output
Symptom: Generated pages do not reflect recent code changes.
Possible causes:
- No rebuild - Run
npm run buildor restart the dev server to trigger generation. - Watch mode disabled - Enable
watch: truefor automatic regeneration during development. - Cached docs.json - The concurrency guard may have skipped generation. Delete the lock file or wait for the next minute.
- Browser cache - Hard-refresh the browser or clear the Docusaurus build cache with
npx docusaurus clear.
Build Optimization
For large projects, generation can take significant time. Here are strategies to speed up development:
Skip Generation During Styling Work
If you are only working on site styling or hand-written guides (without @import directives), you can
temporarily remove the docsgen plugin from your config. The existing generated files in outDir will
still be served by Docusaurus.
Use Selective Entry Points
Instead of pointing to a barrel index.ts that re-exports everything, use specific entry points to
generate docs for only the modules you are working on:
{
entryPath: ["src/client.ts", "src/hooks.ts"],
}
Reduce TypeDoc Scope
Use typeDocOptions to limit what TypeDoc processes:
{
typeDocOptions: {
exclude: ["**/test/**", "**/internal/**", "**/*.spec.ts"],
},
}
This is applied on top of docsgen's defaults, which already exclude common test patterns.
Use docusaurus start with the docsgen plugin for development. Enable watch: true for live
regeneration. The concurrency guard prevents duplicate runs within the same minute. Set
logLevel: "trace" when debugging issues. Inspect options.json and docs.json to verify
generation output. For common issues, check plugin configuration, importer setup, and TypeScript
compilation status. See Setup for the full integration reference.

