Contributing to Documentation
How to Update Documentation
Adding JSDoc Comments
When writing TypeScript/React code, add JSDoc comments:
typescript
/**
* Suggests the best driver for a shipment based on availability and workload.
*
* @param shipments - Array of shipment insights
* @param drivers - Array of driver insights
* @param options - Optional configuration
* @returns Suggestion result with driver ID, score, and reason
*
* @example
* ```ts
* const suggestion = suggestDriver(shipments, drivers, { targetZoneId: 'zone-1' });
* if (suggestion.id) {
* assignDriver(suggestion.id);
* }
* ```
*/
export function suggestDriver(
shipments: ShipmentInsight[],
drivers: DriverInsight[],
options?: { targetZoneId?: string | null }
): SuggestionResult {
// ...
}Documenting Components
Add JSDoc comments to React components:
tsx
/**
* Barcode scanner component using device camera.
*
* @example
* ```tsx
* <BarcodeScanner
* active={isOpen}
* onDetected={(value) => handleScan(value)}
* onError={(error) => console.error(error)}
* />
* ```
*/
export function BarcodeScanner({ active, onDetected, onError }: BarcodeScannerProps) {
// ...
}Documenting Props
Define props interfaces with comments:
tsx
interface BarcodeScannerProps {
/** Toggle the scanner on/off from parent component */
active: boolean;
/** Called every time a barcode is decoded */
onDetected: (value: string) => void;
/** Notified when the user denies the camera or another error occurs */
onError?: (message: string) => void;
}Updating Database Documentation
Database documentation is auto-generated from SQL migrations. To update:
- Add comments in SQL migration files:
sql
-- Creates driver_locations table for GPS tracking
-- Stores real-time driver positions with lat/lng coordinates
CREATE TABLE driver_locations (
driver_id UUID PRIMARY KEY REFERENCES profiles(id),
lat DECIMAL(10, 8) NOT NULL,
lng DECIMAL(11, 8) NOT NULL,
updated_at TIMESTAMPTZ DEFAULT NOW()
);- Run documentation generator:
bash
npm run docs:generate:databaseAdding New Documentation Pages
Create markdown file in appropriate directory:
docs/- Main documentationdocs/api/- API documentationdocs/components/- Component documentationdocs/database/- Database documentation
Add to navigation in
.vitepress/config.ts:
typescript
sidebar: {
'/api/': [
{
text: 'API Reference',
items: [
{ text: 'New Page', link: '/api/new-page' }
]
}
]
}- Commit and push changes
Workflow
Before Committing
Generate documentation:
bashnpm run docs:generatePreview changes:
bashnpm run docs:devVerify formatting:
- Check markdown syntax
- Verify code examples work
- Test links
After Committing
Documentation is automatically:
- Generated on push to
main - Published to GitHub Pages
- Available at
https://your-org.github.io/lager-guru/
Documentation Standards
Markdown Format
- Use proper heading hierarchy (h1 → h2 → h3)
- Include code blocks with language tags
- Add tables for structured data
- Use lists for step-by-step instructions
Code Examples
Always include working code examples:
markdown
```tsx
import { useAuth } from '@/contexts/AuthContext';
function MyComponent() {
const { user } = useAuth();
return <div>Hello {user?.email}</div>;
}
```Links
Use relative links within documentation:
markdown
[Architecture](./architecture.md)
[API Reference](./api/)Images
Place images in docs/public/ and reference:
markdown
Best Practices
- Keep it updated - Documentation should match code
- Be clear - Write for developers who don't know the codebase
- Include examples - Show, don't just tell
- Test examples - Ensure code examples work
- Review regularly - Update docs when code changes
Questions?
- Check existing documentation for examples
- Review VitePress docs
- Ask in GitHub Discussions