This page provides detailed API documentation for DocBox's core classes and methods.
The main entry point for DocBox documentation generation.
DocBox function init(
any strategy,
struct properties = {}
)
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:
// 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"
)
);
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:
Deprecated: Use addStrategy() instead. Kept for backward compatibility.
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.
Executes the documentation generation strategy. Must be implemented by child classes.
Parameters:
qMetaData - Query object containing component metadata
Returns: Strategy instance
getPackageQuery()
Returns components for a specific package.
Parameters:
qMetaData - Full metadata query
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.
Parameters:
outputDir - Output directory for HTML files
projectTitle - Title for documentation
theme - Theme name ("default" or "frames")
Example:
Generates HTML documentation using the selected theme.
📋 JSONAPIStrategy.cfc
Generates machine-readable JSON documentation.
Parameters:
outputDir - Output directory for JSON files
projectTitle - Project title
📐 XMIStrategy.cfc
Generates UML/XMI diagrams.
Parameters:
outputFile - Output file path for XMI file (not a directory!)
Example:
🎯 CommandBoxStrategy.cfc
Specialized strategy for CommandBox CLI commands.
Parameters:
outputDir - Output directory for HTML files
projectTitle - Title for documentation
Example:
🔌 IStrategy.cfc
Interface that all strategies must implement.
Executes the documentation generation strategy.
Parameters:
metadata - Query object containing component metadata with columns:
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
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:
Extend AbstractTemplateStrategy
Implement the run() method
Process the metadata query and generate your output format.
Leverage AbstractTemplateStrategy's helper methods:
getPackageQuery() - Filter by package
getFunctionQuery() - Get methods
getPropertyQuery() - Get properties
buildPackageTree() - Create package hierarchy
💡 Usage Patterns
Method Chaining
DocBox supports fluent method chaining:
Multiple Strategies
Generate multiple output formats in one pass: