Overview
emmylua_doc is a documentation generator that extracts EmmyLua annotations and code structure from your Lua projects to create comprehensive, formatted API documentation. It supports multiple output formats including Markdown and JSON.
Installation
Basic Usage
Command-Line Options
Positional Arguments
One or more paths to workspace directories containing Lua source files to document.
Example Usage
Example Usage
Configuration Options
Comma-separated list of configuration file paths.If not provided, searches for
.emmyrc.json or .luarc.json in the workspace directory.Example Usage
Example Usage
File Filtering Options
Comma-separated list of glob patterns to exclude from documentation generation.Takes precedence over include patterns. Also available as
--ignore.Example Usage
Example Usage
Comma-separated list of glob patterns to include in documentation generation.
Example Usage
Example Usage
Output Options
Specify the output format for generated documentation.Available values:
markdown- Markdown documentation (default)json- Structured JSON output
Example Usage
Example Usage
Specify the output destination.
- For Markdown format: Directory where documentation files will be created
- For JSON format: File path or
stdout
Example Usage
Example Usage
Customization Options
Path to a custom template directory for overriding default documentation templates.
Template structure:
Example Usage
Example Usage
Name of the documentation site, used in generated titles and metadata.
Example Usage
Example Usage
Directory containing additional content to merge with generated documentation.Files in the mixin directory override generated files with the same path.
Example structure:Override behavior:
Example Usage
Example Usage
- If
output/index.mdis generated andmixin/index.mdexists, the mixin version is used - Additional files in mixin are copied to output
- Useful for adding guides, tutorials, and custom content
Other Options
Enable verbose output with detailed progress information.
Verbose output includes:
Example Usage
Example Usage
- File-by-file processing status
- Template application details
- Workspace loading information
- Output file creation details
Deprecated Options
Deprecated: Use
WORKSPACE positional argument instead.Migration Example
Migration Example
Deprecated: Use
--output-format instead.Migration Example
Migration Example
Documentation Generation Process
Step 1: Preparation
Ensure your Lua code includes EmmyLua annotations:Step 2: Generate Documentation
Step 3: Review Generated Files
For Markdown output, the structure typically includes:Output Formats
Markdown Format (Default)
Generates organized Markdown documentation:- Organized by modules, classes, and functions
- Includes type information and parameter details
- Cross-references between documented items
- Supports custom templates via
--override-template - Can be used with static site generators (MkDocs, Docusaurus, etc.)
- Custom documentation site builders
- API documentation aggregation
- IDE integration
- Automated documentation testing
Workflow Examples
Static Site Generation with MkDocs
- Generate Markdown documentation:
- Configure
mkdocs.yml:
- Build and serve:
Docusaurus Integration
Custom Processing with JSON
CI/CD Documentation Pipeline
npm Script Integration
Advanced Usage
Custom Templates
Create a template directory structure:Mixin for Additional Content
Create a mixin directory:- Generated API docs in
./docs - Custom pages from mixin included
- Generated files overridden by mixin files if they exist
Multi-workspace Documentation
Document multiple related projects:Filtered API Documentation
Generate docs only for public API:Troubleshooting
Empty or incomplete documentation
Empty or incomplete documentation
Ensure annotations are present:Check file filtering:Verify workspace path:
Template errors
Template errors
Check template syntax:Fallback to defaults:
- Templates use Handlebars syntax
- Verify bracket matching:
{{,}},{{#each}},{{/each}}
Mixin files not appearing
Mixin files not appearing
Check mixin directory structure:Verify paths:
- Mixin files use relative paths from mixin root
- Example:
mixin/index.md→output/index.md
Configuration not detected
Configuration not detected
Check config file location:Explicitly specify config:Validate JSON:
Best Practices
Write Comprehensive Annotations
Organize Documentation Structure
Automate Documentation Updates
Add to your build process:Version Your Documentation
See Also
- emmylua_ls - Language server for editor integration
- emmylua_check - Static analysis tool
- EmmyLua Annotations Guide - Complete annotation reference
- Configuration Reference - Workspace configuration options
