@compodoc/compodoc, jsdoc, and typedoc are documentation generation tools that parse source code to produce human-readable API documentation. All three extract comments and type information to build navigable documentation sites, but they differ significantly in language support, framework awareness, and output structure. jsdoc is a long-standing standard for JavaScript documentation with extensive plugin support. typedoc is built specifically for TypeScript projects and leverages the compiler's type inference. @compodoc/compodoc focuses on Angular applications and provides deep integration with Angular's architecture patterns.
When building maintainable frontend applications, clear documentation isn't optional β it's essential. These three tools help automate that process by turning your code comments and type annotations into browsable documentation sites. But they approach the problem very differently. Let's break down how they work in practice.
jsdoc relies entirely on explicit JSDoc-style comments. Without them, you get minimal documentation.
// jsdoc: Requires explicit comments
/**
* Calculates the total price including tax
* @param {number} basePrice - The pre-tax price
* @param {number} taxRate - Tax rate as decimal (e.g., 0.08)
* @returns {number} Total price with tax applied
*/
function calculateTotal(basePrice, taxRate) {
return basePrice * (1 + taxRate);
}
typedoc can generate documentation from TypeScript types alone, though comments enhance the output.
// typedoc: Types provide structure, comments add context
/**
* Calculates the total price including tax
*/
function calculateTotal(basePrice: number, taxRate: number): number {
return basePrice * (1 + taxRate);
}
// Even without comments, TypeDoc shows parameter types and return type
@compodoc/compodoc focuses on Angular metadata and requires minimal comments for basic component documentation.
// compodoc: Angular decorators provide most info
@Component({
selector: 'app-product-card',
templateUrl: './product-card.component.html'
})
export class ProductCardComponent {
/** Product to display */
@Input() product!: Product;
/** Emitted when product is added to cart */
@Output() addToCart = new EventEmitter<Product>();
}
// Compodoc automatically documents inputs, outputs, and component metadata
jsdoc uses a JSON or YAML configuration file and supports extensive customization through plugins.
// jsdoc.conf.json
{
"plugins": ["plugins/markdown"],
"templates": {
"default": {
"outputSourceFiles": true
}
},
"opts": {
"destination": "./docs",
"recurse": true
}
}
typedoc integrates directly with your tsconfig.json and can inherit compiler options.
// typedoc.json
{
"entryPoints": ["src/index.ts"],
"out": "docs",
"theme": "default",
"excludePrivate": true,
"excludeProtected": true
}
// Can also use --tsconfig flag to read from existing tsconfig.json
@compodoc/compodoc has Angular-specific defaults and minimal configuration needed for basic usage.
// No config file needed for basic usage
// Run with: npx compodoc -p tsconfig.json -d docs
// Advanced config via .compodocrc.json
{
"tsconfig": "tsconfig.json",
"output": "docs",
"theme": "material",
"hideGenerator": true
}
jsdoc works with any JavaScript codebase and has basic TypeScript support through plugins, but doesn't understand TypeScript's advanced type features natively.
// jsdoc with TypeScript (limited type understanding)
/**
* @param {import('./types').User} user
*/
function greetUser(user) {
return `Hello ${user.name}`;
}
// Must manually reference complex types
typedoc is built specifically for TypeScript and understands generics, interfaces, unions, and other advanced features out of the box.
// typedoc handles complex TypeScript naturally
interface Repository<T> {
findById(id: string): T | null;
save(item: T): Promise<T>;
}
class UserRepository implements Repository<User> {
// TypeDoc shows the concrete implementation
}
@compodoc/compodoc is designed exclusively for Angular applications and understands Angular's specific patterns like modules, services, and dependency injection.
// compodoc understands Angular DI
@Injectable({ providedIn: 'root' })
export class AuthService {
constructor(private http: HttpClient) {}
login(credentials: Credentials): Observable<User> {
return this.http.post<User>('/api/login', credentials);
}
}
// Compodoc shows providedIn metadata and injected dependencies
jsdoc produces traditional hierarchical documentation with separate pages for namespaces, classes, and functions.
# jsdoc output structure
/docs
/classes
UserService.html
/functions
calculateTotal.html
/namespaces
utils.html
index.html
typedoc creates a single-page application with sidebar navigation that mirrors your project's module structure.
# typedoc output structure
/docs
assets/
classes/
interfaces/
modules/
index.html # SPA with client-side routing
@compodoc/compodoc generates Angular-specific views including module graphs, component trees, and route visualizations.
# compodoc output structure
/docs
components/
modules/
injectables/
routes/ # Shows route configuration
graph/ # Dependency graphs
index.html
jsdoc is typically run as a standalone CLI command and integrates easily with any build system.
// package.json
{
"scripts": {
"docs": "jsdoc src -c jsdoc.conf.json"
}
}
typedoc offers both CLI and programmatic APIs, making it easy to integrate into TypeScript workflows.
// Programmatic usage
import { Application } from 'typedoc';
const app = new Application();
app.bootstrap({
entryPoints: ['src/index.ts'],
out: 'docs'
});
app.generateDocs(app.project, 'docs');
@compodoc/compodoc provides Angular CLI integration and watch mode for development.
// angular.json
{
"projects": {
"my-app": {
"architect": {
"compodoc": {
"builder": "@compodoc/compodoc:compodoc",
"options": {
"tsconfig": "tsconfig.json",
"output": "docs"
}
}
}
}
}
}
jsdoc treats types as strings in comments and doesn't validate them against actual code.
/**
* @param {string} name - User name
* @param {number} age - User age
* @returns {Object} User object
*/
function createUser(name, age) {
// JSDoc won't catch if implementation returns string instead of Object
return `${name} is ${age} years old`; // Type mismatch goes unnoticed
}
typedoc uses the TypeScript compiler's type checker, so documentation always matches actual types.
function createUser(name: string, age: number): User {
// TypeDoc will show compilation error if return type doesn't match
return { name, age, id: Date.now() }; // Correctly documented as User
}
@compodoc/compodoc leverages TypeScript types but focuses more on Angular metadata than pure type documentation.
@Component({ /*...*/ })
export class UserProfileComponent {
@Input() user!: User; // Shows as Input property with User type
private formatName(user: User): string {
// Internal methods may not appear in documentation by default
return `${user.firstName} ${user.lastName}`;
}
}
| Feature | jsdoc | typedoc | @compodoc/compodoc |
|---|---|---|---|
| Primary Language | JavaScript | TypeScript | TypeScript (Angular) |
| Annotation Required | β Extensive | β Minimal (types suffice) | β Minimal (Angular metadata) |
| Framework Awareness | β None | β Generic TS | β Angular-specific |
| Type Validation | β String-based | β Compiler-backed | β Compiler-backed |
| Best For | Legacy JS, JSDoc-standard projects | Pure TS libraries/apps | Angular applications |
@compodoc/compodoc gives you framework-aware documentation with minimal setup.typedoc automatically documents your types with zero comment overhead.jsdoc offers the most flexibility and plugin ecosystem.Choose based on your project's language, framework, and how much manual documentation effort you're willing to invest. All three tools solve the same fundamental problem but optimize for different development workflows.
Choose jsdoc if you're maintaining a JavaScript project (with or without TypeScript) that follows established JSDoc conventions, or if you need maximum flexibility through plugins and custom templates. It works well with legacy codebases and offers fine-grained control over documentation output, but requires more manual annotation effort and doesn't leverage TypeScript's type system as deeply as dedicated TS tools.
Choose @compodoc/compodoc if you're working on an Angular application and need documentation that understands Angular-specific constructs like components, modules, directives, and dependency injection. It automatically visualizes module relationships and component hierarchies without requiring extensive JSDoc-style comments. However, it's less suitable for non-Angular TypeScript projects or plain JavaScript codebases.
Choose typedoc if you have a TypeScript project (Angular or otherwise) and want documentation that automatically reflects your type definitions, interfaces, and generics without extensive comment annotations. It integrates seamlessly with the TypeScript compiler and produces clean, type-aware documentation, but provides less framework-specific insight compared to Compodoc for Angular projects.
An API documentation generator for JavaScript.
Want to contribute to JSDoc? Please read CONTRIBUTING.md.
JSDoc supports stable versions of Node.js 12.0.0 and later. You can install
JSDoc globally or in your project's node_modules folder.
To install the latest version on npm globally (might require sudo;
learn how to fix this):
npm install -g jsdoc
To install the latest version on npm locally and save it in your package's
package.json file:
npm install --save-dev jsdoc
To install the latest development version locally, without updating your
project's package.json file:
npm install git+https://github.com/jsdoc/jsdoc.git
If you installed JSDoc locally, the JSDoc command-line tool is available in
./node_modules/.bin. To generate documentation for the file
yourJavaScriptFile.js:
./node_modules/.bin/jsdoc yourJavaScriptFile.js
If you installed JSDoc globally, run the jsdoc command:
jsdoc yourJavaScriptFile.js
By default, the generated documentation is saved in a directory named out. You
can use the --destination (-d) option to specify another directory.
Run jsdoc --help for a complete list of command-line options.
The JSDoc community has created templates and other tools to help you generate and customize your documentation. Here are a few of them:
jsdoc to
Stack Overflow.JSDoc is copyright (c) 2011-present Michael Mathews micmath@gmail.com and the contributors to JSDoc.
JSDoc is free software, licensed under the Apache License, Version 2.0. See the
file LICENSE.md in this distribution for more details.