Skip to content

sameer52718/code-comment-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Comment Generator A Node.js package to automatically generate JSDoc and inline comments for JavaScript and TypeScript codebases. Features

Generates JSDoc for functions and inline comments for variables. Supports both JavaScript and TypeScript files. Configurable comment styles via a JSON configuration file. CLI interface for easy integration into workflows. Extensible for linter/IDE integration.

Installation npm install code-comment-generator

Usage CLI npx code-comment [--config ]

Example: npx code-comment ./src/sample.js --config ./code-comment-config.json

Programmatic const { generateComments } = require('code-comment-generator'); generateComments('./src/sample.js', './code-comment-config.json') .then(() => console.log('Comments generated!')) .catch(err => console.error(err));

Configuration Create a code-comment-config.json file: { "commentStyle": "jsdoc", // or "inline" "includeInline": true, // Include inline comments for variables "outputDir": "output" // Output directory for commented files }

Example Input (sample.js): function add(a, b) { return a + b; } const counter = 0;

Output (output/commented_sample.js): /**

  • add - Function to perform its intended operation.
  • @param {any} a - Parameter a
  • @param {any} b - Parameter b
  • @returns {any} Result of the function. */ function add(a, b) { return a + b; } // counter: Stores relevant data for the operation. const counter = 0;

Development To contribute:

Clone the repository. Install dependencies: npm install. Run tests: npm test. Build: npm start.

License MIT

About

Automatically generate descriptive comments (JSDoc-style or inline) for JavaScript and TypeScript code using AST parsing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published