Getting Started
Quick start guide for forge-ts
Get up and running with forge-ts in minutes.
Step 1: Install
Install the forge-ts package using your preferred package manager:
npm install -D forge-tsOr with pnpm:
pnpm add -D forge-tsStep 2: Configure
Create a forge-ts.config.ts file in your project root:
import { defineConfig } from "@forge-ts/core";
export default defineConfig({
rootDir: ".",
outDir: "docs/generated",
gen: { enabled: true, formats: ["markdown"] },
});Step 3: Write TSDoc
Add TSDoc comments to your exported functions and types. Good TSDoc includes a summary, @param tags, @returns, @example blocks, and a visibility tag:
/**
* Adds two numbers together.
*
* @param a - The first operand.
* @param b - The second operand.
* @returns The sum of a and b.
* @example
* ```typescript
* add(1, 2); // => 3
* ```
* @public
*/
export function add(a: number, b: number): number {
return a + b;
}Step 4: Generate docs
Run forge-ts check to validate TSDoc coverage, then build your docs:
npx forge-ts checkThen build the documentation site:
npx forge-ts buildYour code examples become live documentation:
import { loadConfig } from "@forge-ts/core";
import { generateApi } from "@forge-ts/api";
const config = await loadConfig();
const result = await generateApi(config);
console.log(result.success); // true if the spec was written successfullyCLI Commands
Quick reference for all forge-ts CLI commands:
| Command | Description |
|---|---|
forge-ts check | Lint TSDoc coverage and report rule violations |
forge-ts build | Generate documentation from source code |
forge-ts docs init --target fumadocs | Scaffold a documentation site for an SSG target |
forge-ts docs dev | Preview the generated documentation site locally |
forge-ts test | Run @example blocks as executable doctests |
What's Next?
- Concepts — Understand how forge-ts works
- API Reference — Full API documentation
- Guides — Practical how-to guides