or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdcomment-tags.mdconfiguration.mdcore-generation.mdindex.mdoutput-generation.mdparsing.mdplugins.md
tile.json

cli.mddocs/

Command Line Interface

ApiDoc provides a comprehensive command-line interface for generating API documentation from source files. The CLI offers extensive configuration options and can be used for both one-time generation and continuous development workflows.

Basic CLI Usage

# Generate documentation from source to output directory
apidoc -i src/ -o doc/

# Generate with verbose output
apidoc -i src/ -o doc/ --verbose

# Generate with custom template
apidoc -i src/ -o doc/ -t ./my-template/

# Generate single HTML file
apidoc -i src/ -o doc/api.html --single

CLI Options

Input/Output Options

-i, --input <input...>              Input/source dirname (default: ["./src"])
-o, --output <output>               Output dirname (default: "doc/")
-c, --config <config>               Path to config file (json or javascript)
-t, --template <template>           Use template for output files

Filtering Options

-f, --file-filters <file-filters...>     RegEx-Filter to select files that should be parsed
-e, --exclude-filters <exclude-filters...> RegEx-Filter to select files/dirs that should not be parsed
--filter-by <tag-filter=value>           Filter documentation by tag

Default include filters:

  • .*\.(clj|cls|coffee|cpp|cs|dart|erl|exs?|go|groovy|ino?|java|js|jsx|kt|litcoffee|lua|p|php?|pl|pm|py|rb|scala|ts|tsx|vue)$

Default exclude filters:

  • apidoc.config.js
  • node_modules

Output Control Options

-n, --dry-run                       Parse source files but do not write any output files
-S, --single                        Output to single file
--write-json                        Will create api-data.json file with parsed API info
-p, --private                       Include private APIs in output

Logging Options

-v, --verbose                       Verbose output
-q, --quiet                         Turn all output off
-d, --debug                         Show debug messages
--no-color                          Turn off log color
--log-format <format>               Change log format (allowed: simple, json)
--warn-error                        Treat warnings as error and exit with error code

Processing Options

--encoding <encoding>               Set the encoding of the source code (default: "utf8")
--line-ending <line-ending>         Turn off autodetect line-ending (allowed: LF, CR, CRLF)
--markdown [markdown]               Turn off default markdown parser or set a file to a custom parser
--definitions                       Include definitions file rather than copying definitions

Plugin Options

--parse-filters <parse-filters...>     Optional user defined filters (format: name=filename)
--parse-languages <parse-languages...> Optional user defined languages (format: name=filename)
--parse-parsers <parse-parsers...>     Optional user defined parsers (format: name=filename)
--parse-workers <parse-workers...>     Optional user defined workers (format: name=filename)

Development Options

-w, --watch                         Watch input files for changes to rebuild the docs

Configuration Files

ApiDoc supports multiple configuration sources:

apidoc.json

{
  "name": "My API",
  "version": "1.0.0",
  "description": "My API Documentation",
  "title": "Custom API Title",
  "url": "https://api.example.com",
  "sampleUrl": "https://api.example.com",
  "input": ["./src"],
  "output": "./docs",
  "template": {
    "showRequiredLabels": true,
    "withCompare": true,
    "withGenerator": true
  },
  "header": {
    "title": "Custom Header",
    "filename": "header.md"
  },
  "footer": {
    "title": "Custom Footer", 
    "filename": "footer.md"
  },
  "order": ["User", "Authentication", "Posts"]
}

apidoc.config.js

module.exports = {
  name: 'My API',
  version: '1.0.0',
  description: 'My API Documentation',
  input: ['./src'],
  output: './docs',
  template: {
    showRequiredLabels: true,
    withCompare: true
  }
};

package.json Configuration

{
  "name": "my-project",
  "version": "1.0.0",
  "apidoc": {
    "name": "My API",
    "version": "1.0.0",
    "description": "My API Documentation"
  }
}

Watch Mode

Watch mode automatically rebuilds documentation when source files change:

apidoc -i src/ -o doc/ --watch

This starts a file watcher that:

  • Monitors all files in the input directories
  • Automatically rebuilds documentation on changes
  • Provides console feedback on rebuild status
  • Can be stopped with Ctrl+C

Usage Examples

Basic Project Setup

# Generate docs for JavaScript project
apidoc -i lib/ -o docs/

# Generate docs with custom config
apidoc -c apidoc.json

# Generate docs with verbose logging
apidoc -i src/ -o docs/ --verbose --debug

Advanced Filtering

# Only process TypeScript files
apidoc -i src/ -o docs/ -f ".*\.ts$"

# Exclude test files and node_modules
apidoc -i src/ -o docs/ -e "test" -e "spec" -e "node_modules"

# Filter by API group
apidoc -i src/ -o docs/ --filter-by "group=User"

Custom Templates and Output

# Use custom template
apidoc -i src/ -o docs/ --template ./my-template/

# Generate single HTML file
apidoc -i src/ -o docs/api.html --single

# Include private APIs
apidoc -i src/ -o docs/ --private

Build Integration

# Generate docs and JSON data file
apidoc -i src/ -o docs/ --write-json

# Dry run to validate source files
apidoc -i src/ -o docs/ --dry-run

# Treat warnings as errors for CI
apidoc -i src/ -o docs/ --warn-error

Error Handling

The CLI exits with different codes based on the result:

  • Exit Code 0: Success
  • Exit Code 1: Error occurred during generation

Common error scenarios:

File Access Errors

# Error: Cannot access input directory
apidoc -i nonexistent/ -o docs/

Configuration Errors

# Error: Invalid config file
apidoc -c invalid-config.json

Template Errors

# Error: Template directory not found  
apidoc -i src/ -o docs/ --template ./nonexistent-template/

Plugin System Integration

The CLI supports custom plugins through command-line options:

# Custom language parser
apidoc -i src/ -o docs/ --parse-languages "myext=./my-language-parser.js"

# Custom API parser
apidoc -i src/ -o docs/ --parse-parsers "myapi=./my-api-parser.js"

# Custom filter
apidoc -i src/ -o docs/ --parse-filters "myfilter=./my-filter.js"

# Custom worker
apidoc -i src/ -o docs/ --parse-workers "myworker=./my-worker.js"

Environment Variables

Some CLI behavior can be controlled via environment variables:

# Disable colors in output
NO_COLOR=1 apidoc -i src/ -o docs/

# Set default encoding
APIDOC_ENCODING=utf16 apidoc -i src/ -o docs/

npm Scripts Integration

Common patterns for package.json scripts:

{
  "scripts": {
    "docs": "apidoc -i lib/ -o docs/",
    "docs:watch": "apidoc -i lib/ -o docs/ --watch",
    "docs:single": "apidoc -i lib/ -o docs/api.html --single",
    "docs:build": "apidoc -i lib/ -o docs/ --write-json",
    "docs:validate": "apidoc -i lib/ -o docs/ --dry-run --warn-error"
  }
}