or run

npx @tessl/cli init
Log in

Version

Files

docs

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

task.mdevals/scenario-5/

API Documentation Builder

A command-line tool that programmatically generates markdown documentation from JSDoc-annotated JavaScript files.

Requirements

Build a Node.js command-line application that:

  1. Accepts source file paths via command-line arguments
  2. Generates markdown documentation from JSDoc annotations in those files
  3. Writes the generated documentation to a specified output file
  4. Handles errors gracefully with informative error messages

Command-Line Interface

The tool should accept the following command-line arguments:

  • Source files: One or more JavaScript file paths (positional arguments)
  • Output file: --output or -o flag followed by the output file path (default: API.md)

Example usage:

node doc-builder.js src/utils.js src/helpers.js --output docs/api.md

Error Handling

The tool should handle the following error scenarios:

  • No source files provided: Display usage information
  • Invalid file paths: Report which files could not be found
  • Documentation generation failures: Display meaningful error messages

Test Cases

  • Generates documentation from a single source file and writes it to the default output file @test
  • Generates documentation from multiple source files and writes it to a custom output file @test
  • Displays usage information when no source files are provided @test
  • Reports an error when an invalid file path is provided @test

Implementation

@generates

API

/**
 * Main entry point for the documentation builder CLI tool.
 * Parses command-line arguments, generates documentation, and writes output.
 */
async function main() {
  // IMPLEMENTATION HERE
}

/**
 * Displays usage information for the CLI tool.
 */
function showUsage() {
  // IMPLEMENTATION HERE
}

// Execute main function if run as a script
if (require.main === module) {
  main().catch(error => {
    console.error('Error:', error.message);
    process.exit(1);
  });
}

module.exports = { main, showUsage };

Dependencies { .dependencies }

jsdoc-to-markdown { .dependency }

Provides markdown documentation generation from JSDoc annotations.

fs/promises { .dependency }

Provides file system operations for reading and writing files.