Automated JSDoc documentation generator for DotEvolve projects and dot-cOS services.
This tool analyzes JavaScript/TypeScript code and generates comprehensive JSDoc comments following the project's documentation standards. It supports multiple service types including API Gateway, Workflow Service, Rule Engine, Frontend applications, and Chrome extensions.
- Automatic JSDoc Generation: Analyzes code structure and generates complete JSDoc comments
- Smart Documentation: Creates meaningful descriptions based on function names and context
- Service-Specific Handlers: Specialized documentation for different service types
- Validation: Ensures generated documentation follows JSDoc standards
- Conflict Detection: Avoids overwriting existing documentation
- CLI Interface: Easy-to-use command-line tool
- Configuration Support: Customize behavior with
.docrc.json
npm install
npm run buildnode dist/cli.js file <path-to-file>Example:
node dist/cli.js file src/utils/helper.tsnode dist/cli.js directory <path-to-directory>Example:
node dist/cli.js directory src/Preview changes without writing to files:
node dist/cli.js file src/utils/helper.ts --dry-runCheck existing JSDoc comments for syntax errors:
node dist/cli.js validate src/utils/helper.tsCreate a .docrc.json file in your project root:
{
"excludePatterns": ["node_modules", "dist", "build", "__tests__"],
"style": {
"lineLength": 80,
"indentation": " "
},
"glossary": {
"Customer": "Tenant",
"User": "Account"
}
}- excludePatterns: Array of directory/file patterns to exclude
- style.lineLength: Maximum line length for comments (default: 80)
- style.indentation: Indentation string (default: " ")
- glossary: Map of incorrect terms to correct terms for terminology validation
documentation-tool/
├── src/
│ ├── analyzers/ # Code analysis and AST parsing
│ ├── generators/ # JSDoc comment generation
│ ├── validators/ # Documentation quality validation
│ ├── handlers/ # Service-specific documentation handlers
│ ├── cli.ts # Command-line interface
│ ├── DocumentationInserter.ts # Insert docs into files
│ └── index.ts # Main entry point
├── __tests__/
│ ├── unit/ # Unit tests for specific scenarios
│ ├── property/ # Property-based tests for universal properties
│ └── integration/ # Integration tests
├── dist/ # Compiled JavaScript output
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── jest.config.js # Test configuration
# Build the project
npm run build
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Type check
npx tsc --noEmitThe tool consists of several key components:
Parses JavaScript/TypeScript files using Babel and extracts code elements (functions, classes, routes, etc.)
Generates JSDoc comments from code elements with:
- Meaningful descriptions based on function names
- Parameter documentation with types
- Return type documentation
- Error/exception documentation
Validates JSDoc comments for:
- Syntax correctness
- Completeness (all params documented)
- Non-redundancy (meaningful descriptions)
- Terminology consistency
Inserts generated JSDoc comments into source files while:
- Preserving existing code structure
- Detecting and avoiding conflicts with existing docs
- Maintaining proper indentation
Specialized documentation for:
- API Gateway: Authentication middleware, proxy routing
- Workflow Service: Prisma models, business logic
- Rule Engine: RabbitMQ integration, webhooks
- Frontend: React components, hooks, routing
- Extension: Chrome APIs, message passing
The project uses a dual testing approach:
- Unit tests: Verify specific examples, edge cases, and error conditions
- Property tests: Verify universal properties across all inputs (minimum 100 iterations)
Both approaches are complementary and necessary for comprehensive coverage.
- Line coverage: 80% minimum
- Branch coverage: 75% minimum
- Function coverage: 90% minimum
- @babel/parser: Parse JavaScript/TypeScript code into AST
- @babel/traverse: Traverse and analyze AST nodes
- commander: CLI framework
- fast-check: Property-based testing library
- jest: Testing framework
- typescript: TypeScript compiler and type checking
MIT