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.
Constructor
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 instanceproperties- (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"
)
);addStrategy()
Adds a documentation generation strategy to the collection.
Parameters:
strategy- Strategy alias ("HTML", "JSON", "XMI", "CommandBox") or instanceproperties- 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 codeexcludes- 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 querypackage- Package name
Returns: Filtered query
getFunctionQuery()
Returns methods from component metadata.
Parameters:
metadata- Component metadata structureaccess- 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 structurevisitor- Function to call for each packageprefix- Current package prefix (used in recursion)
🌐 HTMLAPIStrategy.cfc
Generates HTML documentation with modern themes.
Constructor
Parameters:
outputDir- Output directory for HTML filesprojectTitle- Title for documentationtheme- 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 filesprojectTitle- 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 filesprojectTitle- 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 namename- Component namemetadata- Complete component metadata structuretype- Component type (component, interface, etc.)extends- Extended component nameimplements- Implemented interfacesfullextends- Full inheritance chaincurrentMapping- 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 componentmetadata- Full component metadata structuretype- Component type ("component" or "interface")implements- Comma-separated list of interfacesfullextends- Full inheritance chaincurrentMapping- 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.
Use helper methods
Leverage AbstractTemplateStrategy's helper methods:
getPackageQuery()- Filter by packagegetFunctionQuery()- Get methodsgetPropertyQuery()- Get propertiesbuildPackageTree()- Create package hierarchy
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
Last updated
Was this helpful?