evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a command-line tool that generates API documentation from JavaScript source files in markdown format.
The CLI should accept multiple input methods and generate formatted documentation:
The tool must support three different input modes:
lib/*.js, src/**/*.js)For each input mode, the tool should:
Implement a CLI with the following behavior:
Usage: doc-gen [options] <input>
Options:
--pattern Treat input as a glob pattern
--code Treat input as raw JavaScript code
--output Output file path (required)Examples:
doc-gen --output api.md src/index.js - Document a single filedoc-gen --pattern --output api.md "lib/**/*.js" - Document files matching patterndoc-gen --code --output api.md "function add(a, b) { return a + b; }" - Document inline codetest-input/sample.js, the tool generates documentation in the output file @testtest-input/module1.js test-input/module2.js, the tool generates combined documentation @testtest-input/*.js with the --pattern flag, the tool documents all matching files @test--code flag, the tool generates documentation from that code @test#!/usr/bin/env node
/**
* Main CLI entry point
* Parses command-line arguments and generates documentation
*/
function main() {
// Implementation
}
/**
* Generates documentation from the given input
* @param {Object} options - Configuration options
* @param {string|string[]} options.input - File path(s), glob pattern, or raw code
* @param {string} options.output - Output file path
* @param {boolean} options.isPattern - Whether input is a glob pattern
* @param {boolean} options.isCode - Whether input is raw JavaScript code
* @returns {Promise<void>}
*/
async function generateDocs(options) {
// Implementation
}
module.exports = { generateDocs };Provides markdown documentation generation from JSDoc annotations.