Only this pageAll pages
Powered by GitBook
1 of 21

DocBox

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Getting Started

Loading...

Loading...

Loading...

Loading...

Loading...

Output Formats

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Advanced

Loading...

Release History

A brief history in time of our major releases

In this section, you will find the release notes for each version we release under this major version. If you are looking for the release notes of previous major versions, use the version switcher at the top left of this documentation book. Here is a breakdown of our major version releases.

Version 5.0

Major release adding full BoxLang support, modern HTML themes with dark mode, enhanced UI/UX with real-time search, complete relationship documentation, and comprehensive developer experience improvements.

Version 4.0

This major bump was to deprecate some CFML engines

Version 3.0

Added a JSON strategy in preparation for multiple output strategies we will support. Updated build processes and a new outlook for the future of the project.

Version 2.0

The migration from ColdDoc into DocBox.

What's New With 4.1.0

Added

  • Adobe 2023 Testing and Support

  • New Github Actions

New supporting files

  • New build/Docs.cfc task for building the documentation using itself, before we where getting away with it because there was a previous DocBox version. Now we need to build the docs with the current version of DocBox.

  • Fixed

    • Build Versions and changelog

    • Removal of box.zip in root from old scripts

    What's New With 4.0.0

    BREAKING

    • Dropped support for Adobe 2016. Adobe doesn't support ACF 16 anymore, so neither do we.

    NEW

    • Added support for Adobe 2021

    • Added support for @myCustomTag custom docblock tags on methods. (Already supported on components and properties, but missing on methods).

    • Added GitHub Actions CI for automated testing, format checking, releases and more

    FIX

    • Fixes support for Adobe 2018. (Mainly in the CommandBox strategy.)

    Contributing

    Learn how to contribute to the DocBox project by submitting pull requests, reporting issues, and writing tests.

    🤝 There are several ways you can help in the development of DocBox!

    • 🔧

    • 🐛 Submit a bug or feature request to our

    ✅ Write a test

    🔧 Send a Pull Request

    • Fork DocBox or the DocBox documentation repo

    • Clone the repository fork to your machine - git clone [email protected]:ME/DocBox.git

    • Create a feature/ or patch/ branch: git checkout -b patch/syntax-error-in-html-output

    • Make your changes, commit as normal, and use git push to sync your commits to Github.

    • Please target all PRs at the development branch.

    ✅ Testing DocBox

    DocBox has a suite of Testbox specs validating that it works as expected. New features and bug fix PRs should (ideally) contain accompanying tests. Here's how to do that via CommandBox:

    1. After cloning the repo, run box install to install development dependencies

    2. Run box start to boot a test server

    3. Run box testbox run to run the suite of DocBox tests.

    4. Edit test specs in tests/specs as necessary, and run box testbox run again to validate tests pass.

    Send a pull request
    Jira issue tracker

    Introduction

    DocBox is a JavaDoc-style documentation generator for your BoxLang and CFML Applications.

    📚 DocBox reads class metadata and structured comments and outputs documentation in an HTML, JSON, or UML (diagram) format. You can see our live docs here:

    💻 System Requirements

    Installation

    Get started with installing DocBox in your BoxLang or CFML application.

    DocBox can be installed and used in multiple ways, depending on your needs. The recommended method for most users is to install DocBox as a BoxLang module, which provides access to the powerful CLI tool for generating documentation. However, you can also use it as a CommandBox module or a standalone CFML application.

    🦤 BoxLang Module Installation (Recommended for CLI)

    DocBox 5.0+ can be installed as a native BoxLang core module, providing access to the powerful CLI tool.

    CommandBox Web Runtimes

    BoxLang OS Runtime

    Once installed, you can use the boxlang module:docbox CLI command to generate documentation. See the BoxLang CLI Tool page for complete usage details and examples.

    BoxLang CLI Tool Examples

    DocBox includes a native BoxLang CLI module for generating documentation:

    CommandBox Module

    We also have a CommandBox module called DocBox Commands, which enables generating documentation from the CLI as a CommandBox command.

    1. Run box install commandbox-docbox to install the docbox command namespace

    2. Run docbox help to get a list of commands

    3. Run docbox generate help to show help for the docbox generate command

    Please see the DocBox Commands README for more info.

    Using DocBox in a CFML Application

    Installing and using DocBox consists of three main steps:

    Download

    For best results, use CommandBox to run box install docbox --saveDev in your app root.

    Alternatively, you can download the DocBox source code and drop it into a docbox folder in your application.

    Mapping

    If DocBox is not installed in the root of your application, you will need to create a docbox mapping that points to the DocBox source code location:

    Then you can access DocBox via the mapping you created.

    box install bx-docbox
    install-bx-module bx-docbox
    # Basic usage
    boxlang module:docbox --source=/path/to/code --mapping=myapp --output-dir=/docs
    
    # With project title and excludes
    boxlang module:docbox --source=/src --mapping=myapp \
                           --excludes="(tests|build)" \
                           --output-dir=/docs \
                           --project-title="My API"
    
    # Multiple source mappings
    boxlang module:docbox --mappings:v1=/src/v1/models \
                           --mappings:v2=/src/v2/models \
                           --output-dir=/docs
    
    # Using frames theme
    boxlang module:docbox --source=/src --mapping=app \
                           --output-dir=/docs \
                           --theme=frames
    
    # Show help
    boxlang module:docbox --help
    
    # Show version
    boxlang module:docbox --version
    this.mappings[ "docbox" ] = expandPath( "./libraries/doctorBox" );
    <cfscript>
    new docbox.DocBox().generate(
        source = expandPath( "./src" ),
        mapping = "myapp",
        outputDir = expandPath( "./docs" )
    )
    </cfscript>
    BoxLang 1.8+
  • Lucee 5+ / Adobe ColdFusion 2023+ (CFML Support)

  • 🔢 Versioning

    DocBox is maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered in the following format:

    And constructed with the following guidelines:

    • Breaking backward compatibility bumps the major (and resets the minor and patch)

    • New additions without breaking backward compatibility bumps the minor (and resets the patch)

    • Bug fixes and misc changes bumps the patch

    📄 License

    Apache 2 License: http://www.apache.org/licenses/LICENSE-2.0​

    🔗 Important Links

    • 💻 Code: https://github.com/ortus-solutions/docbox​

    • 🐛 Issues: https://ortussolutions.atlassian.net/jira/software/c/projects/DOCBOX/issues/

    • 💬 Community: https://community.ortussolutions.com/

    💼 Professional Open Source

    Ortus Solutions, Corp

    DocBox is professional open source software backed by Ortus Solutions, Corp offering services like:

    • 🛠️ Custom Development

    • 🎯 Professional Support & Mentoring

    • 📖 Training

    • ⚡ Server Tuning

    • 🔒 Security Hardening

    • 👀 Code Reviews

    • 🚀

    HONOR GOES TO GOD ABOVE ALL

    Because of His grace, this project exists. If you don't like this, don't read it; it's not for you.

    "Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God." Romans 5:5

    https://s3.amazonaws.com/apidocs.ortussolutions.com/docbox/5.0.0/index.html
    <major>.<minor>.<patch>

    JSON Output

    Generate JSON output for easy documentation imports into other documentation tools and platforms.

    📋 Generate machine-readable JSON documentation for easy imports into other documentation tools and platforms.

    🚀 Instantiate DocBox

    Begin by creating an instance of DocBox:

    docbox = new DocBox();

    ⚙️ Properties

    The following are the properties for this strategy:

    • projectTitle : Used in the top-level overview-summary.json file

    • outputDir : The output directory absolute path

    Just pass them in the docbox.addStrategy() call:

    📝 Generate Documentation

    Now that you have an instance of DocBox configured with your strategy and its properties, just execute the generate() method with its appropriate arguments:

    Custom Output

    Create your own custom output format by extending DocBox's strategy system.

    🛠️ In addition to the mainstream output formats, you can extend DocBox's AbstractTemplateStrategy class to generate your own which implements the IStrategy class.

    /**
     * Strategy Interface for DocBox Documentation Generation
     * <br>
     * This interface defines the contract that all DocBox documentation strategies must implement.
     * Strategies are responsible for generating documentation output in various formats (HTML, JSON, XMI, etc.)
     * from the component metadata collected by DocBox.
     * <br>
     * <small><em>Copyright 2015 Ortus Solutions, Corp <a href="www.ortussolutions.com">www.ortussolutions.com</a></em></small>
     */
    interface {
    
    	/**
    	 * Execute the documentation generation strategy
    	 *
    	 * This method receives the complete metadata query from DocBox and is responsible for:
    	 * - Processing the component metadata
    	 * - Generating the appropriate output format
    	 * - Writing files to the configured output location
    	 *
    	 * @metadata Query object containing all component metadata with columns:
    	 *            - package: The package name
    	 *            - name: The component name
    	 *            - metadata: The complete component metadata structure
    	 *            - type: The component type (component, interface, etc.)
    	 *            - extends: The extended component name (if any)
    	 *            - implements: The implemented interfaces (if any)
    	 *
    	 * @return The strategy instance for method chaining
    	 */
    	IStrategy function run( required query metadata );
    
    }
    docbox = new DocBox();
    docbox.addStrategy( "JSON",
      {
          projectTitle = "DocBox API",
          outputDir = expandPath( "/resources/tmp" )
      } );
    docbox.generate(
        source  = "#expandPath( '/docbox' )",
        mapping = "coldbox",
        excludes = "tests"
    );
    Much More

    What's New With 5.0.0

    🎉 Major Release - BoxLang Support & Modern UI Overhaul

    BREAKING CHANGES

    • Minimum CFML engine requirements updated:

      • Lucee 5.x minimum (dropped Lucee 4.x)

      • Adobe ColdFusion 2023+ (dropped ACF 2016, 2018, 2021)

    • HTML output now uses Bootstrap 5 (previously Bootstrap 3)

    • Default theme structure reorganized with new Alpine.js-based SPA architecture

    NEW - BoxLang Support 🚀

    • Full BoxLang 1.0+ Runtime Support - DocBox now runs natively on BoxLang

    • BoxLang CLI Module - New boxlang module:docbox command for generating docs from BoxLang CLI

      • boxlang module:docbox --source=/path --mapping=app --output-dir=/docs

    NEW - Modern HTML Theme System 🎨

    • Two Professional Themes:

      • Default Theme - Modern Alpine.js SPA with client-side routing and dynamic filtering

      • Frames Theme - Traditional frameset-based layout with Bootstrap 5

    NEW - Enhanced UI/UX Features 💎

    • Modern Color Scheme - Purple gradient accents (#5e72e4), softer colors, reduced blue overload

    • Visual Indicators - Emoji badges throughout:

      • 📚 Packages, 📁 Folders, 🔌 Interfaces, 📦 Classes

    NEW - Complete Relationship Documentation 📊

    • All Known Implementing Classes - Interfaces now show all classes that implement them

    • All Known Subclasses/Subinterfaces - Display complete inheritance hierarchy

    • Fixed Inheritance Queries - Properly handles both current class and ancestor interfaces

    NEW - Developer Experience Improvements 🛠️

    • Enhanced JavaDoc Support - Comprehensive documentation with <br> tags for BoxLang compatibility

    • 50+ Updated Code Examples - All strategy files updated with proper line breaks

    • Improved Error Messages - Better validation and user-friendly CLI output

    NEW - Strategy Enhancements 📝

    • CommandBox Strategy - Enhanced CLI command documentation with namespace support

    • JSON Strategy - Machine-readable JSON with hierarchical package structure

    • XMI/UML Strategy - Enhanced property inference and generic type support

    IMPROVED

    • Build System - Updated build process with BoxLang support

    • Testing - Multi-engine testing (Lucee 5/6, Adobe 2023/2025, BoxLang 1.0/BE)

    • Documentation - Comprehensive updates for all new features

    FIXED

    • Metadata Format Handling - getImplements() now properly handles both array and struct formats

    • Interface Implementation Display - Fixed empty queries for implementing classes

    • Package Navigation - Improved CSS styling for better UX

    TECHNICAL DETAILS

    • Bootstrap 5.3.2 - Modern component syntax and data-bs-* attributes

    • Bootstrap Icons 1.11.2 - Comprehensive icon set for UI elements

    • Alpine.js - Lightweight reactive framework for SPA theme

    MIGRATION NOTES

    From 4.x to 5.0

    1. Minimum Requirements: Ensure you're running Lucee 5+, Adobe 2018+, or BoxLang 1.0+

    2. HTML Output: The default theme now uses Bootstrap 5. If you have custom CSS, review for compatibility

    3. Theme Selection: Explicitly set theme="frames" if you prefer the traditional frameset layout

    Updating HTML Customizations

    If you extended the HTML strategy:

    • Update Bootstrap 3 classes to Bootstrap 5 equivalents

    • Review custom CSS for CSS custom property compatibility

    • Test dark mode if you have custom themes

    UPGRADE INSTRUCTIONS

    COMMUNITY

    • GitHub Issues: https://github.com/Ortus-Solutions/DocBox/issues

    • Documentation: https://docbox.ortusbooks.com

    • Community Forum: https://community.ortussolutions.com

    Configuration

    Configure DocBox output formats and generation options

    📊 Supported Output Formats

    DocBox offers several built-in output formats as well as enabling you to :

    • 🌐 - Modern HTML documentation with two theme options

    Support for multiple source mappings

  • JSON array format support for complex project structures

  • Built-in help system with --help and --version flags

  • Dual Format Metadata Handling - Automatically detects and handles both BoxLang array format and CFML struct format for implements metadata

  • ModuleConfig.bx - Native BoxLang module configuration for seamless integration

  • Theme Selection - Choose themes via theme property:
  • Dark Mode Support - Full dark/light theme toggle with localStorage persistence

  • Responsive Design - Mobile-friendly layouts with proper breakpoints

  • 🟢 Public, 🔒 Private, ⚡ Static, 📝 Abstract
  • Real-time Method Search - Live filtering with keyboard navigation

    • Search methods by name or signature

    • Navigate results with Enter/Shift+Enter

    • Visual highlighting and auto-scroll

    • Clear with Escape key

  • Method Tabs - Tabbed interface for filtering methods (All/Public/Private/Static/Abstract)

  • Bootstrap Tooltips - Contextual help on visibility badges and deprecated methods

  • Smooth Scrolling - Enhanced navigation with smooth scroll behavior

  • Auto-expanding Navigation - jstree automatically expands first 2 levels for better UX

  • Improved Package Highlighting - Subtle left border instead of full background

    Modern JavaScript - ES6+ features with proper spacing conventions

  • CSS Custom Properties - Comprehensive theming system with CSS variables

  • Abstract Template Strategy - Improved helper methods for all strategies
    Code Formatting - Consistent CFFormat rules across entire codebase
  • Performance - Optimized query operations and template rendering

  • Line Break Handling - Workaround for BoxLang metadata line break stripping

  • Inheritance Detection - Properly checks current class before ancestors

  • CSS Architecture - CSS custom properties for theming with light/dark mode
  • JavaScript Conventions - Proper spacing in all control structures and function calls

  • BoxLang Users: Use the new boxlang module:docbox CLI command for native BoxLang integration

    📋 JSON - Machine-readable JSON format

  • 📐 UML - XMI/UML diagram generation

  • Each format is configured by its alias name, such as "JSON", "HTML", or "XMI".

    ⚙️ Basic Configuration

    🎯 Single Strategy

    🔄 Multiple Strategies

    You can call the .addStrategy() method multiple times to generate multiple output formats:

    🎨 HTML Strategy Options (New in 5.0)

    The HTML strategy now supports theme selection:

    ✨ Theme Features

    Default Theme:

    • ⚡ Alpine.js SPA architecture

    • 🌓 Dark mode toggle with persistence

    • 🔍 Real-time method search

    • 📑 Tabbed method summaries

    • 💜 Modern purple gradient design

    • 🎯 Bootstrap 5 components

    Frames Theme:

    • 📱 Traditional three-panel frameset

    • 🗂️ Left sidebar navigation

    • 🎨 Bootstrap 5 styling

    • 🌓 Dark mode support

    • 📚 Classic documentation UX

    🔧 Generate Method Parameters

    The generate() method accepts the following parameters:

    • source : A path to the source location or an array of structs of locations that must have a dir and mapping key

    • mapping : The base mapping for the folder source (used only if source is a path)

    • excludes : A regular expression that will be evaluated against all classes. If the regex matches the class name and path, the class will be excluded

    📁 Single Source

    📂 Multiple Sources

    🥊 BoxLang CLI Usage (New in 5.0)

    DocBox 5.0 includes a native BoxLang CLI module:

    See boxlang module:docbox --help for complete CLI documentation.

    ♻️ Backwards Compatibility

    For backwards compatibility, specifying the full class path is still supported, as is specifying a single strategy when initializing DocBox:

    create your own
    HTML
    # CommandBox users
    box update docbox
    
    # BoxLang users
    boxlang install docbox
    
    # Verify installation
    box package show version
    new docbox.DocBox()
        .addStrategy( "HTML", {
            outputDir : "/docs",
            theme     : "default" // or "frames"
        } )
    var docbox = new docbox.DocBox();
    docbox.addStrategy( "UML", { outputFile : "./tmp/docs/app-diagram.uml" })
    new docbox.DocBox()
        .addStrategy( "HTML", {
            projectTitle : "My API Documentation",
            outputDir    : expandPath( './docs' ),
            theme        : "default"  // or "frames"
        } )
        .generate(
            source   = expandPath( "/app" ),
            mapping  = "app",
            excludes = "(tests|build)"
        );
    new docbox.DocBox()
        .addStrategy( "HTML", {
            projectTitle : "My Docs",
            outputDir    : expandPath( '/docs/html' ),
            theme        : "default"
        } )
        .addStrategy( "JSON", {
            projectTitle : "My Docs",
            outputDir    : expandPath( '/docs/json' )
        } )
        .addStrategy( "XMI", {
            outputFile : expandPath( '/docs/diagram.uml' )
        } )
        .generate(
            source   = expandPath( "/app" ),
            mapping  = "app",
            excludes = "(tests|build)"
        );
    // Use the modern SPA theme (default)
    docbox.addStrategy( "HTML", {
        projectTitle : "My API",
        outputDir    : expandPath( './docs' ),
        theme        : "default"
    } );
    
    // Use the traditional frames theme
    docbox.addStrategy( "HTML", {
        projectTitle : "My API",
        outputDir    : expandPath( './docs' ),
        theme        : "frames"
    } );
    docbox.generate(
        source   = expandPath( '/myapp' ),
        mapping  = 'myapp',
        excludes = '(tests|build)'
    );
    docbox.generate(
        source = [
            { dir: expandPath( '/app/models' ), mapping: 'app.models' },
            { dir: expandPath( '/app/handlers' ), mapping: 'app.handlers' },
            { dir: expandPath( '/plugins' ), mapping: 'plugins' }
        ],
        excludes = '(tests|specs)'
    );
    # Basic usage
    boxlang module:docbox --source=/path/to/code \
                           --mapping=myapp \
                           --output-dir=/docs
    
    # With options
    boxlang module:docbox --source=/app \
                           --mapping=myapp \
                           --output-dir=/docs \
                           --project-title="My API" \
                           --theme=frames \
                           --excludes="(tests|build)"
    
    # Multiple sources
    boxlang module:docbox --mappings:models=/app/models \
                           --mappings:handlers=/app/handlers \
                           --output-dir=/docs
    variables.docbox = new docbox.DocBox(
        strategy   = "docbox.strategy.uml2tools.XMIStrategy",
        properties = {
            projectTitle : "DocBox Tests",
            outputFile   : variables.testOutputFile
        }
    );

    HTML Output

    Generate browsable HTML documentation for your application Classes

    🌐 The HTML API Strategy is used to create class documentation based on Javadoc.

    🎨 Modern Themes (New in 5.0)

    DocBox 5.0 introduces a completely redesigned HTML output with two professional themes:

    ⚡ Default Theme - Modern SPA

    The default theme features:

    • Alpine.js-based SPA - Client-side routing and dynamic filtering

    • 🌓 Dark Mode Support - Toggle between light and dark themes with persistence

    • 🔍 Real-time Search - Live method filtering with keyboard navigation (Enter/Shift+Enter)

    📚 Frames Theme - Traditional Layout

    The frames theme provides:

    • Frameset-based Layout - Classic three-panel documentation view

    • Bootstrap 5 Styling - Modern component design

    • Package Navigation - Left sidebar with hierarchical tree

    🚀 Instantiate DocBox

    Begin by creating an instance of DocBox:

    ⚙️ Properties

    The following are the properties for this strategy:

    • projectTitle : The HTML title used in the documentation

    • projectDescription : The HTML project description

    • outputDir : The output directory absolute path

    Just pass them in the docbox.addStrategy() call:

    🖄️ Using the Frames Theme

    To use the traditional frameset layout:

    📝 Generate Documentation

    Now that you have an instance of DocBox configured with your strategy and its properties, just execute the generate() method with its appropriate arguments:

    UML Output

    Generate an XML file for graphing your application via Eclipse UML2Tools

    📐 Generate an XML file for graphing your application via Eclipse UML2Tools

    UML2 Tools hasn't been developed for Eclipse since 2008. This strategy is now more for reference than anything else.

    This is a documentation strategy that ultimately lets you generate UML diagrams from the CFCs that you have written. That being said, it does not actually generate diagrams.

    What this template startegy does is generate the XML file the Eclipse UML2 Tools that stores the information about your domain - the classes, the associations, the inheritence hierarchy, etc. From there it is very easy with UML2 Tools to generate UML diagrams like Class Diagrams, Sequence Diagrams, etc.

    To get started, you need to download and install the Eclipe plugin UML2 Tools in your Eclipse install.

    1. Go to:

    2. We are actually going to use the 0.9.1 Integration Builds plugin, simply because it is more stable, and has several key bug fixes.

    3. Download the All-In-One Update Site and save the .zip file

    4. In Eclipse, go to Help > Install New Software

    5. Click Add

    6. Enter the name UML2 Tools in Name

    7. Click Archive and select the .zip file you downloaded.

      1 . Click OK, and continue through the installation process

    Once that process is complete, the Eclipse UML2 Tools plugin should now be installed and working.

    To get DocBox to generate the .uml file that UML2Tools needs, we use the UMLstrategy. For example:

    This will generate the .uml (in this case docbox.uml) file which we can then use.

    To view and edit the UML diagrams from here:

    1. Browse to the .uml file that you generated in the Navigator Pane

    2. Right click on the .uml file

    3. Select Initialise Class Diagram

    You will now be presented with a UML Class diagram of your CFC model.

    There are other types of UML2 diagrams that can be created. Have a look at the UML2 Tools documentation for more options.

    Strategy Assumptions

    There are some assumptions that are made by this strategy, when converting from CFCs to UML diagrams, as some meta data on CFCS are not provided and/or cannot be specified.

    • A property/field is determined for a class when a get and set function exist with the same name (or set and is for boolean values) and the argument type of the set function matches the return type of the get/is function.

    • The scope for the property/field is selected by highest level of exposure between the get and set functions. I.e. if getFoo() is public, and setFoo() is private, then the property foo is marked as public.

    🎨 Modern UI - Bootstrap 5, purple gradient accents, emoji indicators
  • 📱 Responsive Design - Mobile-friendly layouts

  • 📑 Method Tabs - Filter by All/Public/Private/Static/Abstract

  • ✨ Smooth Scrolling - Enhanced navigation experience

  • Dark Mode Support - Consistent theming across all panels
  • Traditional UX - Familiar navigation pattern

  • theme : (Optional) Theme name - "default" or "frames" (defaults to "default")

  • docbox = new DocBox();
    docbox = new DocBox();
    docbox.addStrategy( "HTML", {
        projectTitle : "My Docs",
        outputDir    : expandPath( "/mydocs" ),
        theme        : "default"  // or "frames"
    } );
    docbox = new DocBox();
    docbox.addStrategy( "HTML", {
        projectTitle : "My API Docs",
        outputDir    : expandPath( "/mydocs" ),
        theme        : "frames"
    } );
    docbox.generate(
        source  = "#expandPath( '/docbox' )",
        mapping = "coldbox",
        excludes = "tests"
    );
    Select the root package that you wish to model
  • Click OK

  • All associations are of type aggregation, rather than composition

    docBox = new DocBox();
    docBox.addStrategy( "UML", { projectFile = expandPath( "./uml/docbox.uml" ) });
    docbox.generate( expandPath("/docbox"), "docbox" );
    http://www.eclipse.org/modeling/mdt/downloads/?showAll=1&hlbuild=I200907241018&project=uml2tools

    BoxLang CLI Tool

    Get started with the BoxLang CLI tool for generating documentation

    🦤 DocBox 5.0+ includes a native BoxLang module with a powerful CLI tool for generating documentation directly from the command line.

    📦 Installation

    DocBox can be installed as a BoxLang core module using the bx-docbox slug:

    CommandBox Web Runtimes

    BoxLang OS Runtime

    Once installed, the boxlang module:docbox command becomes available for generating documentation.


    🎯 Usage

    ⚙️ Required Options

    Option
    Short
    Description

    📂 Source Options

    Option
    Description

    ⚙️ Additional Options

    Option
    Short
    Description

    💡 Examples

    📌 Basic Usage

    Generate documentation for a single source directory:

    📌 With Project Title and Excludes

    📌 Short Form Output Directory

    📌 Multiple Source Mappings

    Document multiple source directories with different mappings:

    📌 Using Frames Theme

    Generate documentation with the traditional frameset layout:

    📌 JSON Array Format

    Specify multiple sources using JSON array notation:

    📌 Real-World Example: ColdBox Framework


    🔧 Command Output

    When you run the CLI tool, you'll see output like this:


    🆘 Getting Help

    Show Help

    This displays comprehensive usage information including:

    • Command syntax

    • All available options

    • Multiple examples

    • Links to documentation

    Show Version

    Displays:

    • DocBox version

    • Author information

    • Website URL


    ⚠️ Common Issues

    Missing Source Mappings

    Error:

    Solution: Ensure you provide either:

    • --source and --mapping together

    • One or more --mappings:<name>=<path> options

    • JSON array via --source

    Missing Output Directory

    Error:

    Solution: Always specify where to generate documentation:

    Source Directory Not Found

    Warning:

    Solution: Verify the source path exists and is accessible. Use absolute paths or paths relative to your current working directory.


    🎨 Theme Selection

    DocBox 5.0+ includes two modern themes:

    Default Theme (Alpine.js SPA)

    Features:

    • ⚡ Alpine.js-based SPA

    • 🌓 Dark mode support

    • 🔍 Real-time search

    • 📑 Method tabs

    Frames Theme (Traditional)

    Features:

    • 🗂️ Traditional frameset layout

    • 📚 jstree navigation

    • 📱 Left sidebar for packages

    • 🎯 Bootstrap 5 styling


    🔗 Integration with Build Scripts

    CommandBox Task Runner

    Create a task.cfc to generate documentation:

    Run with: box task run

    CI/CD Pipeline

    Add to your GitHub Actions, GitLab CI, or other CI/CD pipeline:


    📚 Next Steps

    • - Learn about strategy properties and advanced configuration

    • - Explore HTML theme features

    • - Write effective JavaDoc comments

    CommandBox Output

    Generate CommandBox CLI command documentation with namespace organization

    🎯 The CommandBox Strategy is a specialized output format designed specifically for documenting CommandBox CLI commands and namespaces. It extends the HTML API Strategy with CLI-focused terminology and navigation.

    🚀 Overview

    The CommandBox Strategy transforms CommandBox command components into searchable, navigable HTML documentation with command-specific features:

    • Command-Centric Navigation - Organizes by command namespaces (not packages)

    • CLI Terminology - Uses "commands" and "namespaces" instead of "classes" and "packages"

    • Qualified Names - Displays full command paths (e.g., server start, package show)

    • Namespace Hierarchy - Visualizes command organization and nesting

    • Frames Theme - Uses traditional frameset layout for CLI documentation

    📦 Properties

    The CommandBox Strategy accepts the following configuration properties:

    Property
    Type
    Required
    Description

    🎯 Basic Usage

    Using Strategy Alias

    Using Full Class Path

    📂 Generated Structure

    The CommandBox Strategy generates the following file structure:

    🎨 Features

    Command Path Display

    Unlike standard class documentation, CommandBox Strategy shows the full command path:

    Namespace Organization

    Commands are grouped by their namespace hierarchy:

    • server namespace

      • start command

      • stop command

    CLI-Focused Templates

    The strategy uses specialized templates that:

    • Display command syntax and usage

    • Show command examples in CLI format

    • Highlight command parameters and flags

    • Use CLI-appropriate terminology

    📋 Real-World Examples

    Documenting CommandBox Core

    Generate documentation for CommandBox's built-in commands:

    Custom CommandBox Module

    Document your own CommandBox module commands:

    Multiple Command Modules

    Document multiple CommandBox modules together:

    🔧 Technical Details

    Strategy Implementation

    The CommandBox Strategy:

    • Extends: docbox.strategy.api.HTMLAPIStrategy

    • Template Path: /docbox/strategy/CommandBox/resources/templates

    • Assets Path: /docbox/strategy/api/themes/frames/resources/static

    Metadata Augmentation

    The strategy augments the standard metadata query with additional columns:

    • command - The command name extracted from the component

    • namespace - The namespace path for the command

    Template Overrides

    CommandBox Strategy overrides specific templates:

    • class.cfm - Modified to show command syntax

    • package-summary.cfm - Shows namespace commands

    • overview-summary.cfm - Lists all namespaces

    ⚠️ Important Notes

    1. Theme Locked: CommandBox Strategy always uses the frames theme for consistency

    2. Command Components: Expects CommandBox command component structure

    3. Namespace Detection: Automatically extracts namespace from component metadata

    🔗 Related Documentation

    • - Parent strategy documentation

    • - Creating your own strategies

    • - Strategy configuration options

    💡 Tips

    • Use consistent naming conventions for command components

    • Add comprehensive JavaDoc comments to commands

    • Document command parameters with @hint attributes

    JSON Schema

    Understanding the output format of the DocBox JSON strategy

    The JSON strategy outputs three types of files:

    Regex pattern to exclude files/folders

    --project-title=<title>

    📖 Project title for documentation

    --theme=<name>

    🎨 Theme name (default or frames)

    --strategy=<class>

    Documentation strategy class (default: docbox.strategy.api.HTMLAPIStrategy)

    💜 Modern purple design

    --output-dir=<path>

    -o=<path>

    📁 Output directory for generated docs

    --source=<path>

    Source directory to document

    --mapping=<name>

    Base mapping for the source folder

    --mappings:<name>=<path>

    Define multiple source mappings

    --help

    -h

    Show help information

    --version

    -v

    Show version information

    Configuration Options
    HTML Output
    Annotating Your Code

    --excludes=<regex>

    HTML title for documentation (default: "Untitled")

    restart command

  • package namespace

    • show command

    • set command

    • install command

  • Asset Sharing: Reuses frames theme assets for stability
    Include usage examples in command descriptions
  • Group related commands under the same namespace

  • outputDir

    string

    Yes

    Output directory absolute path

    projectTitle

    string

    HTML Output
    Custom Output Strategy
    Configuration

    No

    Class Documentation

    Overview Summary

    DocBox's JSON strategy outputs a single overview-summary.json file in the root of the configured outputDir directory that documents all packages (component directories) and classes in the configured source.

    This overview-summary.json file will match the following schema:

    See an example at JSONSchemaValidator.net

    Package Summary

    DocBox's JSON strategy outputs a package-summary.json file for every directory found in the configured source directory that contains at least one ColdFusion component.

    • source/autos/autoBuilder.cfc will generate a docs/source/autos/package-summary.json

    This package-summary.json file will match the following schema:

    See an example at JSONSchemaValidator.net

    Class Documentation

    DocBox's JSON strategy outputs a single class.json file for every .cfc component found in the configured source directory.

    The name of the file will reflect the component name, and the location will match the source directory hierarchy:

    • source/app/autos/autoBuilder.cfc becomes docs/source/app/autos/autoBuilder.json

    • source/main.cfc becomes docs/source/main.json

    Each component documentation file will match the following schema:

    See an example at JSONSchemaValidator.net

    Overview Summary
    Package Summary
    box install bx-docbox
    install-bx-module bx-docbox
    boxlang module:docbox [options]
    boxlang module:docbox --source=/src/models \
                           --mapping=models \
                           --output-dir=/docs
    boxlang module:docbox --source=/src \
                           --mapping=myapp \
                           --excludes="(tests|build)" \
                           --output-dir=/docs \
                           --project-title="My API"
    boxlang module:docbox --source=/src \
                           --mapping=app \
                           -o=/docs
    boxlang module:docbox --mappings:v1=/src/v1/models \
                           --mappings:v2=/src/v2/models \
                           --output-dir=/docs \
                           --project-title="API Docs"
    boxlang module:docbox --source=/src \
                           --mapping=app \
                           --output-dir=/docs \
                           --theme=frames
    boxlang module:docbox --source="[{'dir':'/src/models', 'mapping':'models'}, {'dir':'/src/services', 'mapping':'services'}]" \
                           --output-dir=/docs \
                           --project-title="My API"
    boxlang module:docbox --source=tests/resources/coldbox \
                           --mapping=coldbox \
                           --excludes="(tests|build)" \
                           --output-dir=tests/apidocs \
                           --project-title="ColdBox Framework" \
                           --theme=default
    ═══════════════════════════════════════════════════════════════════
      📚 DocBox Documentation Generator
    ═══════════════════════════════════════════════════════════════════
    
    📂 Source:  /Users/myapp/src/models
    🔗 Mapping: models
    📁 Output:  /Users/myapp/docs
    
    ⏳ Starting generation, please wait...
    
    🥊 Generation complete!
    Documentation available at: /Users/myapp/docs
    boxlang module:docbox --help
    boxlang module:docbox --version
    ❌ ERROR: No valid source mappings found.
    ❌ ERROR: --output-dir is required
    boxlang module:docbox --source=/src --mapping=app --output-dir=/docs
    ⚠️  Warning: '/path/to/source' does not exist.
    boxlang module:docbox --source=/src --mapping=app \
                           --output-dir=/docs \
                           --theme=default
    boxlang module:docbox --source=/src --mapping=app \
                           --output-dir=/docs \
                           --theme=frames
    component {
        function run() {
            command( "boxlang" )
                .params(
                    "module:docbox",
                    "--source=#getCWD()#/models",
                    "--mapping=models",
                    "--output-dir=#getCWD()#/docs",
                    "--project-title=My Project",
                    "--theme=default"
                )
                .run();
        }
    }
    - name: Generate API Documentation
      run: |
        boxlang module:docbox \
          --source=./src \
          --mapping=myapp \
          --output-dir=./build/docs \
          --project-title="My Application" \
          --theme=default
    new docbox.DocBox()
        .addStrategy( "CommandBox", {
            projectTitle : "My CommandBox Commands",
            outputDir    : expandPath( "/docs/commands" )
        } )
        .generate(
            source  = expandPath( "/modules/my-commands/commands/" ),
            mapping = "my-commands"
        );
    new docbox.DocBox()
        .addStrategy(
            new docbox.strategy.CommandBox.CommandBoxStrategy(
                outputDir    = expandPath( "/docs/commandbox" ),
                projectTitle = "CommandBox CLI Reference"
            )
        )
        .generate(
            source  = "/commandbox/cfml/system/modules_app/",
            mapping = "commandbox.commands"
        );
    outputDir/
    ├── index.html                  - Main entry point (frameset)
    ├── overview-summary.html       - Namespace overview
    ├── overview-frame.html         - Navigation sidebar
    ├── css/                        - CSS stylesheets
    ├── js/                         - JavaScript files
    ├── bootstrap/                  - Bootstrap assets
    └── {namespace}/
        ├── package-summary.html    - Namespace detail page
        └── {command}.html          - Individual command documentation
    server start
    server stop
    package show
    package set
    new docbox.DocBox()
        .addStrategy( "CommandBox", {
            projectTitle : "CommandBox CLI Reference",
            outputDir    : expandPath( "/docs/commandbox-core" )
        } )
        .generate(
            source  = "/commandbox/cfml/system/modules_app/",
            mapping = "commandbox.commands",
            excludes = "(tests|build)"
        );
    new docbox.DocBox()
        .addStrategy( "CommandBox", {
            projectTitle : "My CLI Module",
            outputDir    : expandPath( "/docs/my-module" )
        } )
        .generate(
            source  = expandPath( "/modules/my-module/commands/" ),
            mapping = "my-module.commands"
        );
    var docbox = new docbox.DocBox()
        .addStrategy( "CommandBox", {
            projectTitle : "All Command Modules",
            outputDir    : expandPath( "/docs/all-commands" )
        } );
    
    docbox.generate(
        source = [
            { dir: expandPath( "/modules/module1/commands/" ), mapping: "module1" },
            { dir: expandPath( "/modules/module2/commands/" ), mapping: "module2" }
        ]
    );
    {
        "$id": "point-to-public-json-schema.json",
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "Package documentation index",
        "description": "This class index links to each generated class documentation JSON file.",
        "required": [],
        "type": "object",
        "properties": {
            "title": {
                "type": "string"
            },
            "classes": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "path": {
                            "type": "string"
                        }
                    }
                }
            },
            "packages": {
                "type": "object",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "path": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
    {
        "$id": "point-to-public-json-schema.json",
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "Package documentation index",
        "description": "Index file documenting each coldfusion component inside a package level - i.e. per directory.",
        "required": [],
        "type": "object",
        "properties": {
            "title": {
                "type": "string"
            },
            "classes": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "path": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
    {
        "$id": "point-to-public-json-schema.json",
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "Class documentation",
        "description": "Documents a single class in a ColdFusion package.",
        "required": [],
        "definitions": {
            "function" : {
                "type" : "object",
                "properties": {
                    "name" : { "type" : "string" },
                    "hint" : { "type" : "string" },
                    "description" : { "type" : "string" },
                    "access" : { "type" : "string" },
                    "parameters" : {
                        "type" : "array",
                        "items": { "$ref" : "#/definitions/parameter" }
                    },
                    "returnType" : { "type" : "string" },
                    "returnFormat" : { "type" : "string" },
                    "position" : {
                        "type" : "object",
                        "properties" : {
                            "start" : { "type" : "integer" },
                            "end" : { "type" : "integer" }
                        }
                    }
                }
            },
            "parameter" : {
                "type" : "object",
                "properties": {
                    "type" : { "type" : "string" },
                    "name" : { "type" : "string" },
                    "required" : { "type" : "boolean" },
                    "default" : { "type" : "string" }
                }
            }
        },
        "type": "object",
        "properties": {
            "name" : { "type": "string" },
            "package" : { "type": "string" },
            "type" : { "type": "string" },
            "extends" : { "type" : "string" },
            "implements" : { "type" : "string" },
            "hint" : { "type" : "string" },
            "description" : { "type" : "string" },
            "properties" : {
                "description" : "Literally the component properties set via `property` or `cfproperty`.",
                "type" : "object",
                "properties": {
                    "type" : { "type" : "string" },
                    "name" : { "type" : "string" },
                    "access" : { "type" : "string" },
                    "hint" : { "type" : "string" },
                    "default" : { "type" : "string" },
                    "required" : { "type" : "boolean" }
                }
            },
            "constructor" : { "$ref": "#/definitions/function" },
            "functions" : {
                "type" : "array",
                "items" : { "$ref": "#/definitions/function" }
            }
        }
      }

    Troubleshooting

    Common issues and solutions when using DocBox

    This guide covers common issues you might encounter when using DocBox and their solutions.

    🚨 Common Errors

    "Output directory does not exist"

    Error Message:

    Cause: The specified output directory doesn't exist on the filesystem.

    Solution: Create the output directory before running DocBox, or ensure that the path is correct. You can create it manually or programmatically:

    Missing Source Mappings (CLI)

    Error Message:

    Cause: The BoxLang CLI command wasn't provided with source directory information.

    Solution: Ensure you provide either:

    • --source and --mapping together

    • One or more --mappings:<name>=<path> options

    • JSON array via --source

    "Cannot read properties of undefined (reading 'toLowerCase')"

    Cause: JavaScript error in HTML templates when filtering methods with missing properties.

    Solution: This was fixed in DocBox 5.0. Update to the latest version:

    Class Not Found

    Error Message:

    Cause: The mapping specified doesn't match the actual package structure.

    Solution: Ensure your mapping matches your component path structure:

    Exclusion Pattern Not Working

    Problem: Files are still being documented despite exclusion pattern.

    Cause: Exclusion patterns are applied to relative file paths, not absolute paths.

    Solution: Use patterns that match the relative path structure:

    🔍 Metadata Issues

    Empty Documentation Pages

    Problem: Generated docs show components but no methods/properties.

    Cause: Components lack JavaDoc comments or metadata.

    Solution: Add proper documentation to your components:

    Generic Types Not Showing

    Problem: Generic type annotations like Array<User> not appearing in docs.

    Cause: Using standard @returntype instead of @doc.type.

    Solution: Use the @doc.type annotation:

    Implements Not Detected

    Problem: Interface implementations not showing in documentation.

    Cause: Engine-specific metadata format differences.

    Solution: DocBox 5.0+ handles both formats automatically. If using older versions, update:

    🎨 HTML/UI Issues

    Dark Mode Not Persisting

    Problem: Dark mode preference resets on page reload.

    Cause: Browser localStorage might be disabled or cleared.

    Solution:

    1. Check browser console for localStorage errors

    2. Enable localStorage in browser settings

    3. Clear site data and try again

    Search Not Working

    Problem: Method search doesn't filter results.

    Cause: JavaScript not loading or Alpine.js initialization issue.

    Solution:

    1. Check browser console for errors

    2. Ensure you're using a modern browser (Chrome, Firefox, Edge, Safari)

    3. Clear browser cache and reload

    4. Check network tab for failed asset loads

    Theme Not Loading

    Problem: Documentation appears unstyled or broken.

    Cause: Asset paths incorrect or theme not specified properly.

    Solution:

    🛠️ Build Issues

    CLI Command Not Found

    Error Message:

    Cause: bx-docbox module not installed.

    Solution:

    Memory Issues with Large Codebases

    Problem: DocBox runs out of memory when processing large projects.

    Solution:

    1. Increase JVM heap size

    1. Process in smaller chunks:

    1. Use more aggressive exclusion patterns:

    Build Hangs or Takes Too Long

    Problem: Documentation generation appears to hang.

    Cause: Processing too many files or infinite recursion in inheritance.

    Solution:

    1. Add verbose logging to see progress

    2. Check for circular dependencies in your code

    3. Exclude unnecessary directories

    4. Run in smaller batches

    🦤 BoxLang-Specific Issues

    BoxLang Module Not Loading

    Problem: Module loads but CLI command errors out.

    Cause: Module registration issue or conflicts.

    Solution:

    Metadata Format Differences

    Problem: Documentation differs between CFML and BoxLang engines.

    Cause: BoxLang uses different metadata structure for some properties.

    Solution: DocBox 5.0+ automatically handles both formats. If you're on an older version:

    📊 Strategy-Specific Issues

    JSON Output Empty

    Problem: JSON files generated but contain no data.

    Cause: Source directory or mapping incorrect.

    Solution: Verify your paths and mappings:

    XMI/UML Strategy Fails

    Problem: XMI strategy throws errors.

    Cause: Missing or invalid output file path.

    Solution:

    🔧 Debug Tips

    Enable Verbose Logging

    Add debugging output to your generation script:

    Check Component Metadata

    Verify your component metadata is readable:

    Validate Output Directory Permissions

    Ensure DocBox can write to the output directory:

    📞 Getting Help

    If you're still experiencing issues:

    1. Check Documentation:

    2. Search Issues:

    3. Community Forums:

    📝 Reporting Bugs

    When reporting issues, please include:

    • DocBox version (box info docbox or boxlang module:docbox --version)

    • CFML engine and version

    • Operating system

    Annotating Your Code

    Learn how to annotate your BoxLang or CFML code for DocBox documentation generation

    📝 DocBox reads your classes and creates documentation according to your objects, inheritance, implementations, functions, arguments, comments and metadata. We try to follow the style of annotations even though it is not 100% compatible yet.

    💬 DocBox Comments

    DocBox comments may be placed above any class declaration, property, function, or argument which we want to document.

    These comments are commonly made up of two sections:

    CFML Slack: #box-products channel at cfml-slack.herokuapp.com
  • Professional Support: Ortus Solutions

  • Complete error message and stack trace

  • Minimal code example to reproduce

  • Expected vs actual behavior

  • docbox.ortusbooks.com
    Jira Issue Tracker
    Ortus Community
    The output directory [/path/to/docs] does not exist
    // Option 1: Create the directory first
    directoryCreate( expandPath( "/docs" ), true );
    
    // Option 2: Use an existing directory
    new docbox.DocBox()
        .addStrategy( "HTML", {
            outputDir: expandPath( "/existing/path" )
        } )
        .generate( source: "/src", mapping: "app" );
    ❌ ERROR: No valid source mappings found.
    # Correct usage
    boxlang module:docbox --source=/src --mapping=app --output-dir=/docs
    
    # Or with mappings
    boxlang module:docbox --mappings:app=/src --output-dir=/docs
    box update docbox
    Class [myapp.MyClass] not found
    // If your component is at: /src/models/User.cfc
    // And its component declaration is: component { }
    // And you access it via: new models.User()
    
    new docbox.DocBox()
        .addStrategy( "HTML", { outputDir: "/docs" } )
        .generate(
            source  = expandPath( "/src" ),      // Source directory
            mapping = "models"                    // Base mapping
        );
    // Correct - matches relative paths
    excludes = "(tests|build|\.git)"
    
    // Incorrect - won't match absolute paths
    excludes = "/full/path/to/tests"
    /**
     * User management service
     *
     * @author Your Name
     */
    component {
    
        /**
         * Gets a user by ID
         *
         * @id The user ID
         * @return User object or null
         */
        public function getUser( required numeric id ) {
            // implementation
        }
    }
    /**
     * Gets all active users
     *
     * @return Array of User objects
     * @doc.type Array<User>
     */
    public array function getUsers() {
        return [];
    }
    box update docbox
    // Explicitly specify theme
    new docbox.DocBox()
        .addStrategy( "HTML", {
            outputDir: "/docs",
            theme: "default"  // or "frames"
        } )
        .generate( source: "/src", mapping: "app" );
    Command [module:docbox] not found
    # For CommandBox web runtimes
    box install bx-docbox
    
    # For BoxLang OS runtime
    install-bx-module bx-docbox
    
    # Verify installation
    boxlang module:docbox --version
    box config set server.jvm.heapSize=1024
    // Document modules separately
    new docbox.DocBox()
        .addStrategy( "HTML", { outputDir: "/docs/module1" } )
        .generate( source: "/src/module1", mapping: "module1" );
    
    new docbox.DocBox()
        .addStrategy( "HTML", { outputDir: "/docs/module2" } )
        .generate( source: "/src/module2", mapping: "module2" );
    excludes = "(tests|specs|build|node_modules|\.git|vendor)"
    # Reinstall the module
    box uninstall bx-docbox
    box install bx-docbox
    
    # Or force module reload
    box reload
    box update docbox
    new docbox.DocBox()
        .addStrategy( "JSON", {
            projectTitle: "My API",
            outputDir: expandPath( "/docs/json" )
        } )
        .generate(
            source: expandPath( "/src" ),  // Use expandPath()
            mapping: "app"
        );
    new docbox.DocBox()
        .addStrategy( "XMI", {
            outputFile: expandPath( "/docs/diagram.uml" )  // Not outputDir!
        } )
        .generate( source: "/src", mapping: "app" );
    try {
        var docbox = new docbox.DocBox()
            .addStrategy( "HTML", {
                outputDir: expandPath( "/docs" )
            } );
    
        writeDump( "Starting documentation generation..." );
    
        docbox.generate(
            source: expandPath( "/src" ),
            mapping: "app"
        );
    
        writeDump( "Generation complete!" );
    } catch ( any e ) {
        writeDump( var=e, label="DocBox Error" );
        rethrow;
    }
    component = createObject( "component", "myapp.MyClass" );
    metadata = getComponentMetadata( component );
    writeDump( metadata );
    testFile = expandPath( "/docs/test.txt" );
    fileWrite( testFile, "test" );
    fileDelete( testFile );
    writeDump( "Output directory is writable" );
  • The description of what we're commenting on

  • The standalone block tags (marked with the @ symbol) which describe specific meta-data

  • Also all core engine attributes to components, properties, functions and arguments will be documented automatically for you.

  • For the full JavaDoc spec click here: https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html

    📚 Class Annotating

    Please note that BoxLang allows you to use both documentation annotation and code annotation styles.

    /**
    * Hero is the main entity we'll be using to create awesome stuff
    *
    * @author
    
    /**
    * Hero is the main entity we'll be using to create awesome stuff
    *
    * @author Captain America
    

    This is a simple component declaration where we define the hint for the component and add block tags like @author . All attributes to the component will be documented for you as name-value pairs on the final output.

    🎯 Property Annotating

    /**
    * Hero is the main entity we'll be using to create awesome stuff
    *
    * @author Captain America
    *
    */
    @name( "SuperHero" )
    @transient
    class{
    
        /**
         * A collection of aliases this superhero is known as
         */
        property name="alias" type="array";
    
        /**
         * Internal alias name
         *
         * @deprecated true
         */
        @propertyCodeAnnotation
        @serialize( false )
        property name="_alias" type="array";
    }
    /**
    * Hero is the main entity we'll be using to create awesome stuff
    *
    * @author Captain America
    *
    */
    component name="SuperHero" accessors="true" transient{
    
        /**
         * A collection of aliases this superhero is known as
         */
        property name="alias" type="array";
    
        /**
         * Internal alias name
         * @deprecated true
         */
        property name="_alias" type="array";
    }

    Properties also have comments and you can add @ blocks as well.

    Function Annotations

    Functions can have a variety of block tags alongside the main description of the function. Also notice that each argument can also be documented via the @argName block tag.

    Argument Annotations

    Arguments can also have multiple annotations for documentation or semantic usage purposes.

    This is done by using a . period delimiter and then adding another block name or semantic name to use.

    Core Blocks

    Here are some of the core blocks that can be used in DocBox:

    Tag
    Explanation

    @author

    Provides information about the author, typically the author’s name, e-mail address, website information, and so on.

    @version

    Indicates the version number.

    @since

    Used to indicate the version with which this class, field, or method was added.

    Custom DocBox Blocks

    Here are some blocks that ONLY DocBox can read:

    Tag
    Explanation

    @doc.type

    This is an annotation that can be placed on either a function or argument declaration. This annotation is used to specify what generic type is being used, which is particularly useful when a return or argument type is an array or a struct or any. The value can be a single type or a list.

    🏷️ Custom Annotations

    DocBox supports standard JavaDoc tags and recognizes custom annotations for enhanced documentation.

    @doc.type

    The @doc.type annotation allows you to specify generic types for complex return types and arguments. This is especially useful for documenting collections and typed data structures.

    Syntax:

    Examples:

    Return Type Generics

    Document arrays with specific element types:

    Document structs with key/value types:

    Parameter Type Generics

    Document typed parameters:

    Document complex struct parameters:

    Inline Generic Annotations

    BoxLang also supports inline doc.type attributes:

    Complex Generic Types

    For nested or complex types:

    Best Practices for @doc.type

    1. Be Specific: Use concrete types instead of generic "Any" when possible

    2. Consistency: Use the same naming convention throughout your codebase

    3. Documentation: Combine with @return or parameter hints for full context

    4. Complex Types: Break down complex nested types into multiple lines for clarity

    /**
     * This is a Javadoc compliant comment for DocBox
     */
    JavaDoc
    /**
     * get Java FileInputStream for resource bundle
     *
     * @rbFilePath path + filename for resource, including locale + .properties
     *
     * @return java.io.FileInputStream
     *
     * @throws ResourceBundle.InvalidBundlePath
     */
    public function getResourceFileInputStream( required string rbFilePath ){
    }
    /**
     * get Java FileInputStream for resource bundle
     *
     * @rbFilePath path + filename for resource, including locale + .properties
     * @rbFilePath.deprecated true
     *
     * @return java.io.FileInputStream
     * @throws ResourceBundle.InvalidBundlePath
     */
    public function getResourceFileInputStream( required string rbFilePath ){
    }
    /**
     * Get foo array
     *
     * @doc.type com.Foo
     */
    private array function getFooArray(){
      return variables.foo;
    }
    
    // Inline
    private array function getFooArray() doc.type="com.Foo"{
      return variables.foo;
    }
    
    /**
     * Set my struct
     *
     * @myStruct.doc.type uuid,string
     */
    private void function setMyStruct( required struct myStruct ){
      instance.myStruct = arguments.myStruct;
    }
    
    // Inline
    private void function setMyStruct(
      required struct myStruct doc.type="uuid,string"
    ){
      instance.myStruct = arguments.myStruct;
    }
    @doc.type TypeName
    @doc.type KeyType,ValueType
    /**
     * Gets all active users from the database
     *
     * @return Array of User objects
     * @doc.type Array<User>
     */
    public array function getActiveUsers() {
        return queryExecute( "SELECT * FROM users WHERE active = 1" )
            .map( function( row ) {
                return new User( row );
            } );
    }
    /**
     * Gets user preferences as a configuration map
     *
     * @return Struct mapping setting names to values
     * @doc.type Struct<String,Any>
     */
    public struct function getUserPreferences() {
        return {
            "theme": "dark",
            "fontSize": 14,
            "autoSave": true
        };
    }
    /**
     * Processes a batch of user records
     *
     * @users Array of User objects to process
     * @users.doc.type Array<User>
     */
    public void function processBatch( required array users ) {
        for ( var user in arguments.users ) {
            user.process();
        }
    }
    /**
     * Updates user settings with validation
     *
     * @settings Map of setting names to their values
     * @settings.doc.type Struct<String,Any>
     */
    public void function updateSettings( required struct settings ) {
        validateSettings( arguments.settings );
        saveSettings( arguments.settings );
    }
    // Return type with inline generic
    public array function getUsers() doc.type="Array<User>" {
        return entityLoad( "User" );
    }
    
    // Parameter with inline generic
    public void function setCache(
        required struct cache doc.type="String,Any"
    ) {
        variables.cache = arguments.cache;
    }
    /**
     * Gets a map of user IDs to their roles
     *
     * @return Map of numeric user IDs to arrays of role names
     * @doc.type Struct<Numeric,Array<String>>
     */
    public struct function getUserRoles() {
        return {
            1: [ "admin", "editor" ],
            2: [ "viewer" ],
            3: [ "editor", "contributor" ]
        };
    }
    /**
     * Gets a complex data structure for reporting
     *
     * @return Nested structure containing report data
     * - Outer struct: Department name -> Department data
     * - Department data: Struct with "users" (Array<User>) and "metrics" (Struct<String,Numeric>)
     * @doc.type Struct<String,Struct>
     */

    API Reference

    Complete API reference for DocBox classes and methods

    This page provides detailed API documentation for DocBox's core classes and methods.

    📚 DocBox.cfc

    The main entry point for DocBox documentation generation.

    Captain America
    */
    @name( "SuperHero" )
    @transient
    class {
    // properties and functions
    }
    *
    */
    component name="SuperHero" accessors="true" transient{
    // properties and functions
    }

    @return

    Provides a description of a method’s return value.

    @throws

    Indicates exceptions that are thrown by a method or constructor. You can add multiple @throws in a function declaration.

    @deprecated

    Indicates that the class, field, or method is deprecated and shouldn’t be used.

    @{anything}

    Anything you like. That's right, DocBox will document any block pairs for you in a simple output manner.

    @see

    Not implemented yet

    Constructor

    Creates a new DocBox instance with optional initial strategy.

    Parameters:

    • strategy - (Optional) Strategy name ("HTML", "JSON", "XMI", "CommandBox") or instance

    • properties - (Optional) Strategy configuration properties

    Returns: DocBox instance

    Examples:

    addStrategy()

    Adds a documentation generation strategy to the collection.

    Parameters:

    • strategy - Strategy alias ("HTML", "JSON", "XMI", "CommandBox") or instance

    • properties - Strategy configuration properties (if using alias)

    Returns: DocBox instance (for chaining)

    Examples:

    setStrategy()

    Deprecated: Use addStrategy() instead. Kept for backward compatibility.

    generate()

    Generates documentation for the specified source code.

    Parameters:

    • source - Source directory path(s). Can be:

      • String: Single directory path

      • Array: Multiple source definitions

    • mapping - Base mapping for the source code

    • excludes - Regex pattern to exclude files/folders (applied to relative paths)

    • throwOnError - Whether to throw exceptions for invalid components

    Returns: DocBox instance

    Examples:

    getStrategies()

    Returns the array of registered strategies.

    Returns: Array


    🎨 AbstractTemplateStrategy.cfc

    Base class for all documentation strategies. Provides common functionality for HTML, JSON, XMI, and custom strategies.

    Properties

    run()

    Executes the documentation generation strategy. Must be implemented by child classes.

    Parameters:

    • qMetaData - Query object containing component metadata

    Returns: Strategy instance

    Helper Methods

    getPackageQuery()

    Returns components for a specific package.

    Parameters:

    • qMetaData - Full metadata query

    • package - Package name

    Returns: Filtered query

    getFunctionQuery()

    Returns methods from component metadata.

    Parameters:

    • metadata - Component metadata structure

    • access - Filter by access level ("public", "private", "remote", "package")

    Returns: Query of methods

    getPropertyQuery()

    Returns properties from component metadata.

    Parameters:

    • metadata - Component metadata structure

    Returns: Query of properties

    buildPackageTree()

    Converts flat package list into hierarchical tree structure.

    Parameters:

    • packageNames - Array of package names

    Returns: Nested struct representing package hierarchy

    Example:

    visitPackageTree()

    Traverses package tree and calls visitor function for each node.

    Parameters:

    • tree - Package tree structure

    • visitor - Function to call for each package

    • prefix - Current package prefix (used in recursion)


    🌐 HTMLAPIStrategy.cfc

    Generates HTML documentation with modern themes.

    Constructor

    Parameters:

    • outputDir - Output directory for HTML files

    • projectTitle - Title for documentation

    • theme - Theme name ("default" or "frames")

    Example:

    Properties

    Methods

    run()

    Generates HTML documentation using the selected theme.


    📋 JSONAPIStrategy.cfc

    Generates machine-readable JSON documentation.

    Constructor

    Parameters:

    • outputDir - Output directory for JSON files

    • projectTitle - Project title

    Properties


    📐 XMIStrategy.cfc

    Generates UML/XMI diagrams.

    Constructor

    Parameters:

    • outputFile - Output file path for XMI file (not a directory!)

    Example:

    Properties


    🎯 CommandBoxStrategy.cfc

    Specialized strategy for CommandBox CLI commands.

    Constructor

    Parameters:

    • outputDir - Output directory for HTML files

    • projectTitle - Title for documentation

    Example:


    🔌 IStrategy.cfc

    Interface that all strategies must implement.

    run()

    Executes the documentation generation strategy.

    Parameters:

    • metadata - Query object containing component metadata with columns:

      • package - Package name

      • name - Component name

      • metadata - Complete component metadata structure

      • type - Component type (component, interface, etc.)

      • extends - Extended component name

      • implements - Implemented interfaces

      • fullextends - Full inheritance chain

      • currentMapping - Base mapping

    Returns: Strategy instance


    📊 Common Metadata Query Structure

    All strategies receive a query object with the following columns:

    Column Descriptions:

    • package - Package name (e.g., "coldbox.system.web")

    • name - Component name (e.g., "Controller")

    • extends - Direct parent component

    • metadata - Full component metadata structure

    • type - Component type ("component" or "interface")

    • implements - Comma-separated list of interfaces

    • fullextends - Full inheritance chain

    • currentMapping - Base mapping used for generation


    🛠️ Creating Custom Strategies

    To create a custom strategy:

    1. Extend AbstractTemplateStrategy

    1. Implement the run() method

    Process the metadata query and generate your output format.

    1. Use helper methods

    Leverage AbstractTemplateStrategy's helper methods:

    • getPackageQuery() - Filter by package

    • getFunctionQuery() - Get methods

    • getPropertyQuery() - Get properties

    • buildPackageTree() - Create package hierarchy

    1. Register your strategy


    💡 Usage Patterns

    Method Chaining

    DocBox supports fluent method chaining:

    Multiple Strategies

    Generate multiple output formats in one pass:

    Error Handling


    🔗 See Also

    • Configuration

    • Custom Output Strategy

    • Troubleshooting

    DocBox function init(
        any strategy,
        struct properties = {}
    )
    // No initial strategy
    docbox = new docbox.DocBox();
    
    // With strategy alias
    docbox = new docbox.DocBox( strategy: "HTML", properties: {
        outputDir: "/docs",
        projectTitle: "My API"
    } );
    
    // With strategy instance
    docbox = new docbox.DocBox(
        strategy: new docbox.strategy.api.HTMLAPIStrategy(
            outputDir: "/docs",
            projectTitle: "My API"
        )
    );
    DocBox function addStrategy(
        required any strategy,
        struct properties = {}
    )
    // Single strategy
    docbox.addStrategy( "HTML", {
        outputDir: "/docs",
        projectTitle: "My Docs"
    } );
    
    // Multiple strategies
    docbox
        .addStrategy( "HTML", { outputDir: "/docs/html" } )
        .addStrategy( "JSON", { outputDir: "/docs/json" } );
    
    // Strategy instance
    docbox.addStrategy(
        new docbox.strategy.api.HTMLAPIStrategy(
            outputDir: "/docs"
        )
    );
    DocBox function setStrategy(
        required any strategy,
        struct properties = {}
    )
    DocBox function generate(
        required any source,
        required string mapping,
        string excludes = "",
        boolean throwOnError = false
    )
    // Basic usage
    docbox.generate(
        source: expandPath( "/src" ),
        mapping: "myapp"
    );
    
    // With exclusions
    docbox.generate(
        source: expandPath( "/src" ),
        mapping: "myapp",
        excludes: "(tests|build|\.git)"
    );
    
    // Multiple sources
    docbox.generate(
        source: [
            { dir: expandPath( "/src/models" ), mapping: "models" },
            { dir: expandPath( "/src/services" ), mapping: "services" }
        ]
    );
    array function getStrategies()
    property name="outputDir" type="string";
    property name="projectTitle" type="string" default="Untitled";
    IStrategy function run( required query qMetaData )
    query function getPackageQuery( required query qMetaData, required string package )
    query function getFunctionQuery(
        required struct metadata,
        string access = ""
    )
    query function getPropertyQuery( required struct metadata )
    struct function buildPackageTree( required array packageNames )
    // Input: [ "coldbox.system.web", "coldbox.system.cache" ]
    // Output: { coldbox: { system: { web: {}, cache: {} } } }
    void function visitPackageTree(
        required struct tree,
        required any visitor,
        string prefix = ""
    )
    HTMLAPIStrategy function init(
        required string outputDir,
        string projectTitle = "Untitled",
        string theme = "default"
    )
    strategy = new docbox.strategy.api.HTMLAPIStrategy(
        outputDir: expandPath( "/docs" ),
        projectTitle: "My API",
        theme: "default"
    );
    property name="outputDir" type="string";
    property name="projectTitle" type="string" default="Untitled";
    property name="theme" type="string" default="default";
    IStrategy function run( required query qMetaData )
    JSONAPIStrategy function init(
        required string outputDir,
        string projectTitle = "Untitled"
    )
    property name="outputDir" type="string";
    property name="projectTitle" type="string" default="Untitled";
    XMIStrategy function init( required string outputFile )
    strategy = new docbox.strategy.uml2tools.XMIStrategy(
        outputFile: expandPath( "/docs/diagram.uml" )
    );
    property name="outputFile" type="string";
    CommandBoxStrategy function init(
        required string outputDir,
        string projectTitle = "Untitled"
    )
    strategy = new docbox.strategy.CommandBox.CommandBoxStrategy(
        outputDir: expandPath( "/docs/commands" ),
        projectTitle: "My CLI Commands"
    );
    IStrategy function run( required query metadata )
    qMetaData = queryNew(
        "package,name,extends,metadata,type,implements,fullextends,currentMapping",
        "varchar,varchar,varchar,any,varchar,varchar,varchar,varchar"
    );
    component extends="docbox.strategy.AbstractTemplateStrategy" {
    
        property name="outputDir" type="string";
    
        function init( required string outputDir ) {
            variables.outputDir = arguments.outputDir;
            return this;
        }
    
        function run( required query qMetaData ) {
            // Your implementation here
            return this;
        }
    }
    new docbox.DocBox()
        .addStrategy( new path.to.MyCustomStrategy(
            outputDir: "/docs"
        ) )
        .generate( source: "/src", mapping: "app" );
    new docbox.DocBox()
        .addStrategy( "HTML", { outputDir: "/docs/html" } )
        .addStrategy( "JSON", { outputDir: "/docs/json" } )
        .generate( source: "/src", mapping: "app" );
    var docbox = new docbox.DocBox();
    
    docbox.addStrategy( "HTML", {
        outputDir: "/docs/html",
        projectTitle: "My API",
        theme: "default"
    } );
    
    docbox.addStrategy( "JSON", {
        outputDir: "/docs/json",
        projectTitle: "My API"
    } );
    
    docbox.addStrategy( "XMI", {
        outputFile: "/docs/diagram.uml"
    } );
    
    docbox.generate(
        source: expandPath( "/src" ),
        mapping: "myapp",
        excludes: "(tests|build)"
    );
    try {
        new docbox.DocBox()
            .addStrategy( "HTML", { outputDir: "/docs" } )
            .generate(
                source: "/src",
                mapping: "app",
                throwOnError: true  // Throw on invalid components
            );
    } catch ( any e ) {
        // Handle errors
        writeLog( e.message );
        rethrow;
    }