Automatically generate beautiful, interactive documentation for your vals by parsing TypeScript AST and extracting functions, classes, interfaces, types, and constants with their JSDoc comments.
@param, @returns, @example, and
@deprecated tagsGenerate documentation JSON for any public val:
GET /api/docs?val=username/valname
Query Parameters:
val (required) - Val identifier in format username/valnamerefresh (optional) - Set to true to bypass cacheExample:
curl "https://docs-gen.val.run/api/docs?val=stevekrouse/example"
Response:
{ "val": "stevekrouse/example", "version": "1", "generatedAt": "2025-11-17T12:00:00.000Z", "exports": { "functions": [...], "classes": [...], "interfaces": [...], "types": [...], "constants": [...] }, "imports": [...], "metadata": {...} }
Visit the root URL with a val query parameter to view interactive documentation:
https://docs-gen.val.run/?val=username/valname
The UI provides:
.
āāā backend/
ā āāā docGenerator.http.ts # Main HTTP entry point
ā āāā routes/
ā ā āāā apiDocs.ts # API route handler
ā ā āāā ui.ts # UI route handler
ā āāā services/
ā āāā docCache.ts # Blob-backed cache with memory front
ā āāā docService.ts # Main orchestration service
ā āāā tsParser.ts # TypeScript AST parser
ā āāā valFetcher.ts # Val Town API client
āāā frontend/
ā āāā index.html # HTML entry point
ā āāā index.tsx # React app entry
ā āāā components/ # React UI components
ā āāā App.tsx
ā āāā Header.tsx
ā āāā Sidebar.tsx
ā āāā MainContent.tsx
ā āāā FunctionDocCard.tsx
ā āāā ClassDocCard.tsx
ā āāā InterfaceDocCard.tsx
ā āāā TypeDocCard.tsx
ā āāā ConstantDocCard.tsx
ā āāā CodeBlock.tsx
ā āāā DocCommentDisplay.tsx
āāā shared/
āāā docTypes.ts # Shared TypeScript types
username/valname@versionUses the TypeScript Compiler API to:
ts.getJSDocTags()See shared/docTypes.ts for complete type definitions:
DocManifest - Main documentation manifestFunctionDoc - Function documentationClassDoc - Class documentationInterfaceDoc - Interface documentationTypeAliasDoc - Type alias documentationConstantDoc - Constant/variable documentationDocComment - Parsed JSDoc commentValMetadata - Val Town metadataMain orchestration service:
// Generate docs with caching
await generateDocs(val: string, opts?: { refresh?: boolean })
// Refresh cache
await refreshDocs(val: string)
// Get cached docs only
await getCachedDocs(val: string)
// Clear cache
await clearValCache(val: string)
await clearAllCaches()
Val Town API client:
// Fetch val bundle
await valFetcher.fetchLatest(val: string): Promise<ValBundle>
TypeScript AST parser:
// Parse val bundle to documentation
parseValBundle(bundle: ValBundle): DocManifest
Documentation cache:
// Create cache instance
const cache = createDocCache({ ttlMs: 3600000, blobPrefix: "doc-cache" })
// Cache operations
await cache.get<T>(key: string)
await cache.set<T>(key: string, data: T, metadata: { version: string })
await cache.has(key: string)
await cache.delete(key: string)
https://docs-gen.val.run/?val=stevekrouse/example
This project is designed to run as a Val Town HTTP val. The entry point is
backend/docGenerator.http.ts.
To deploy:
backend/docGenerator.http.ts as the entry pointThis is a Val Town project. To contribute:
MIT License - see LICENSE file for details
Built with:
Need help? Open an issue or reach out on Val Town Discord.