or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build.mdcli-commands.mdindex.mdinput-processing.mdlint.mdoutput-formats.mdutilities.md
tile.json

tessl/npm-documentation

A comprehensive JavaScript documentation generator that transforms JSDoc-annotated source code into human-readable documentation in multiple formats

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/documentation@14.0.x

To install, run

npx @tessl/cli install tessl/npm-documentation@14.0.0

index.mddocs/

Documentation.js

Documentation.js is a comprehensive JavaScript documentation generator that transforms JSDoc-annotated source code into human-readable documentation in multiple formats. It supports modern JavaScript features including ES5, ES2017, JSX, Vue components, and Flow type annotations, with intelligent inference of parameters, types, and code relationships to minimize manual documentation effort.

Package Information

  • Package Name: documentation
  • Package Type: npm
  • Language: JavaScript (ES modules)
  • Installation: npm install -g documentation or npm install documentation
  • CLI Command: documentation

Core Imports

import { build, lint, expandInputs, formats, util } from "documentation";

For CommonJS:

const { build, lint, expandInputs, formats, util } = require("documentation");

Basic Usage

Building Documentation

import { build, formats } from "documentation";

// Build documentation from source files
const comments = await build(['index.js'], {
  access: ['public', 'protected'],
  shallow: false
});

// Generate HTML documentation
const htmlDocs = await formats.html(comments, {
  theme: 'default',
  name: 'My Project',
  version: '1.0.0'
});

// Generate Markdown documentation
const markdownDocs = await formats.md(comments, {});

// Generate JSON documentation
const jsonDocs = await formats.json(comments);

CLI Usage

# Generate markdown docs
documentation build index.js -f md

# Generate HTML docs with GitHub links
documentation build src/** -f html --github -o docs

# Lint JSDoc syntax
documentation lint util.js

# Update README with API docs
documentation readme index.js --section=API

Architecture

Documentation.js is built around several key components:

  • Core API: Main functions (build, lint, expandInputs) for documentation generation and validation
  • Input Processing: Dependency resolution and shallow file processing
  • Parsing Pipeline: JavaScript/JSDoc parsing with Babel AST analysis
  • Inference Engine: Automatic detection of names, types, parameters, and relationships
  • Output Formats: Multiple format generators (HTML, Markdown, JSON, Remark AST)
  • CLI Interface: Command-line tools for build, lint, and readme operations
  • Theme System: Customizable HTML output with theming support

Capabilities

Core Documentation Generation

Primary API for building documentation from source code with comprehensive configuration options and intelligent inference.

function build(
  indexes: string[] | string,
  args: BuildOptions
): Promise<Comment[]>;

interface BuildOptions {
  external?: string[];
  shallow?: boolean;
  order?: (string | object)[];
  access?: string[];
  hljs?: HljsOptions;
  inferPrivate?: string;
  extension?: string | string[];
  theme?: string;
  name?: string;
  version?: string;
  description?: string;
  homepage?: string;
  favicon?: string;
  github?: boolean;
  documentExported?: boolean;
  config?: string;
  markdownToc?: boolean;
  markdownTocMaxDepth?: number;
  parseExtension?: string[];
  requireExtension?: string[];
  babel?: string;
  noPackage?: boolean;
  resolve?: string;
  watch?: boolean;
  output?: string;
  format?: string;
}

interface HljsOptions {
  highlightAuto?: boolean;
  languages?: string[];
}

Documentation Generation

Documentation Linting

Validation system for JSDoc syntax and structure with detailed error reporting.

function lint(
  indexes: string[] | string, 
  args: LintOptions
): Promise<string>;

interface LintOptions {
  external?: string[];
  shallow?: boolean;
  inferPrivate?: string;
  extension?: string | string[];
}

Documentation Linting

Input Processing

File dependency resolution and input expansion for comprehensive documentation coverage.

function expandInputs(
  indexes: string[] | string,
  config: Config
): Promise<string[]>;

Input Processing

Output Formats

Multiple output format generators for different documentation needs and platforms.

interface Formats {
  html(comments: Comment[], config: HtmlConfig): Promise<string | void>;
  md(comments: Comment[], config: MarkdownConfig): Promise<string>;
  remark(comments: Comment[], config: RemarkConfig): Promise<string>;
  json(comments: Comment[]): Promise<string>;
}

interface HtmlConfig {
  theme?: string;
  name?: string;
  version?: string;
  github?: boolean;
}

interface MarkdownConfig {
  markdownToc?: boolean;
  documentExported?: boolean;
}

interface RemarkConfig {
  markdownToc?: boolean;
  documentExported?: boolean;
}

Output Formats

Utility Classes and Functions

Helper utilities for custom documentation processing and theme development.

interface Util {
  createFormatters(getHref: (href: string) => string): Formatters;
  LinkerStack: typeof LinkerStack;
}

interface Formatters {
  parameter(param: Parameter, short?: boolean): string;
  markdown(ast: object): string;
  type(type: Type): string;
  autolink(text: string): string;
  parameters(section: Comment, short?: boolean): string;
}

class LinkerStack {
  constructor(config: Config);
  namespaceResolver(comments: Comment[], resolver: Function): LinkerStack;
  link(namepath: string): string | undefined;
}

Utilities

CLI Commands

Command-line interface for documentation generation, linting, and README integration.

# Build documentation
documentation build [input..] [options]

# Lint documentation
documentation lint [input..] [options]  

# Update README
documentation readme [input..] [options]

CLI Commands

Types

interface Comment {
  description?: Description;
  tags?: Tag[];
  loc?: Location;
  context?: Context;
  augments?: Augment[];
  implements?: Implement[];
  params?: Parameter[];
  properties?: Property[];
  returns?: Return[];
  throws?: Throw[];
  examples?: Example[];
  members?: Members;
  path?: Path[];
  namespace?: string;
  name?: string;
  kind?: string;
  memberof?: string;
  scope?: string;
  access?: string;
  type?: Type;
}

interface Description {
  type: string;
  children: DescriptionChild[];
}

interface Tag {
  title: string;
  description?: Description;
  type?: Type;
  name?: string;
}

interface Type {
  type: string;
  name?: string;
  expression?: Type;
  applications?: Type[];
  elements?: Type[];
  fields?: Field[];
}

interface Parameter {
  title: string;
  name: string;
  description?: Description;
  type?: Type;
  default?: any;
  optional?: boolean;
  variable?: boolean;
}

interface Property {
  title: string;
  name: string;
  description?: Description;
  type?: Type;
  optional?: boolean;
}

interface Return {
  title: string;
  description?: Description;
  type?: Type;
}

interface Example {
  description?: Description;
  caption?: string;
}

interface Location {
  start: Position;
  end: Position;
}

interface Position {
  line: number;
  column: number;
}

interface Context {
  sortKey: string;
  file: string;
  ast: object;
  code: string;
  loc: Location;
}