or run

npx @tessl/cli init
Log in

Version

Files

docs

cli.mdindex.mdprogrammatic-api.md
tile.json

task.mdevals/scenario-8/

Documentation Generator CLI

Build a command-line tool that generates API documentation from JavaScript source files in markdown format.

Requirements

The CLI should accept multiple input methods and generate formatted documentation:

Input Handling

The tool must support three different input modes:

  1. File path mode: Accept a single file path or multiple file paths
  2. Pattern mode: Accept glob patterns to match multiple files (e.g., lib/*.js, src/**/*.js)
  3. Direct code mode: Accept JavaScript source code directly as a string

Output Generation

For each input mode, the tool should:

  • Parse JSDoc comments from the JavaScript source
  • Generate markdown documentation
  • Write the output to a specified output file

Command-Line Interface

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 file
  • doc-gen --pattern --output api.md "lib/**/*.js" - Document files matching pattern
  • doc-gen --code --output api.md "function add(a, b) { return a + b; }" - Document inline code

Capabilities

Processes single file input

  • Given the path test-input/sample.js, the tool generates documentation in the output file @test

Processes multiple file inputs

  • Given multiple paths test-input/module1.js test-input/module2.js, the tool generates combined documentation @test

Processes glob patterns

  • Given the pattern test-input/*.js with the --pattern flag, the tool documents all matching files @test

Processes raw source code

  • Given JavaScript code as a string with the --code flag, the tool generates documentation from that code @test

Implementation

@generates

API

#!/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 };

Dependencies { .dependencies }

jsdoc-to-markdown { .dependency }

Provides markdown documentation generation from JSDoc annotations.

@satisfied-by