| applyTo | **/*.md |
|---|
These standards define how all documentation should be written, structured, and formatted across the project.
- Clarity First: Write for developers who are new to the codebase
- Consistency: Follow established patterns throughout all documentation
- Completeness: Include all necessary information without being verbose
- Currency: Keep documentation up-to-date with code changes
Every documentation file MUST include:
- Title (H1): Clear, descriptive name
- Overview: 2-3 sentence summary of what this document covers
- Table of Contents: For documents longer than 3 sections
- Main Content: Organized with proper heading hierarchy
- Examples: Practical code examples where applicable
# Title (H1) - Only one per document
## Major Section (H2)
### Subsection (H3)
#### Detail Section (H4) - Use sparingly- Use active voice: "The function returns a value" not "A value is returned"
- Use second person: "You can configure..." not "Users can configure..."
- Be direct: "Run the command" not "You should run the command"
- Stay professional but approachable
- Define acronyms on first use: "Application Programming Interface (API)"
- Use consistent terminology throughout
- Avoid jargon unless necessary for the audience
- Include context for code references
- Keep sentences under 25 words when possible
- One idea per sentence
- Use bullet points for lists of 3+ items
- Use numbered lists for sequential steps
Always use fenced code blocks with language specification:
// Good: Language specified, includes context
function calculateTotal(items: Item[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}- Runnable: Examples should work when copied
- Complete: Include necessary imports and context
- Commented: Add inline comments for complex logic
- Realistic: Use meaningful variable names and realistic data
❌ Bad Example:
function f(x) {
return x.map(i => i.a + i.b);
}✅ Good Example:
/**
* Calculates the total price for each order line item.
* @param orderItems - Array of order items with unitPrice and quantity
* @returns Array of calculated totals
*/
function calculateLineTotals(orderItems) {
return orderItems.map(item => item.unitPrice * item.quantity);
}/**
* Brief description of what the function does.
*
* @description Longer description if needed, explaining the purpose
* and any important behavior details.
*
* @param paramName - Description of the parameter
* @param optionalParam - Description (optional, defaults to X)
* @returns Description of return value
* @throws {ErrorType} When this error condition occurs
*
* @example
* // Example usage with expected output
* const result = functionName('input');
* console.log(result); // 'expected output'
*//**
* Brief description of the class purpose.
*
* @description Detailed explanation of the class responsibility,
* when to use it, and any important patterns.
*
* @example
* const instance = new ClassName(config);
* instance.doSomething();
*/Every directory should have a README.md with:
- Purpose: What this directory contains
- Contents: Brief description of key files
- Usage: How to use or navigate the contents
- Related: Links to related documentation
- Use kebab-case:
api-reference.md,getting-started.md - Be descriptive:
user-authentication.mdnotauth.md - Group related docs:
api/,guides/,tutorials/
- Use descriptive link text: write
[API Reference]not[click here] - Use relative paths for internal links
- Check links are valid before committing
Use tables for structured data:
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Unique identifier |
name |
string |
No | Display name |
Use blockquotes for important notes:
Note: Important information the reader should know.
Warning: Critical information about potential issues.
Tip: Helpful suggestions for better usage.
Before submitting documentation:
- Spelling and grammar checked
- All code examples tested
- Links verified
- Consistent formatting applied
- Table of contents updated (if applicable)
- Related documents cross-referenced
- Note version-specific behavior
- Mark deprecated features clearly
- Include migration guides for breaking changes