bx-docbox
bx-docbox: API Documentation Generator
Installation
install-bx-module bx-docbox
# CommandBox
box install bx-docbox
CLI Usage
# Basic usage
boxlang module:docbox \
--source=/path/to/source \
--mapping=myapp \
--output-dir=/path/to/docs
# With all options
boxlang module:docbox \
--source=/path/to/source \
--mapping=myapp \
--output-dir=/path/to/docs \
--project-title="My Application API Docs" \
--theme=default \
--excludes=tests,build
# CommandBox (when bx-docbox is installed as a box module)
box docbox generate \
source=./src \
mapping=myapp \
outputDir=./docs/api \
projectTitle="My API"
Output Formats
| Format | Strategy Name | Description |
|---|---|---|
| HTML (default SPA) | "HTML" |
Single-page app layout, modern theme |
| HTML (frames) | "HTML" with theme:"frames" |
Traditional frames layout |
| JSON | "JSON" |
Raw JSON metadata export |
| UML / XMI | "UML" |
StarUML-compatible XMI output |
Programmatic Usage: HTML Documentation
// Minimal HTML docs
new docbox.DocBox()
.addStrategy( "HTML", {
outputDir : expandPath( "/app/docs/api" ),
projectTitle : "My Application API"
})
.generate(
source : expandPath( "/app/models" ),
mapping : "app.models"
)
Multiple Strategies (HTML + JSON)
new docbox.DocBox()
.addStrategy( "HTML", {
outputDir : expandPath( "/app/docs/api" ),
projectTitle : "My Application API",
theme : "default" // "default" or "frames"
})
.addStrategy( "JSON", {
outputDir : expandPath( "/app/docs/json" ),
projectTitle : "My Application API"
})
.generate(
source : expandPath( "/app" ),
mapping : "app",
excludes : "tests,build,node_modules"
)
Frames Layout Theme
// Traditional JavaDoc-style frames layout
new docbox.DocBox()
.addStrategy( "HTML", {
outputDir : expandPath( "/app/docs" ),
projectTitle : "My Application API",
theme : "frames"
})
.generate(
source : expandPath( "/app" ),
mapping : "app"
)
UML / XMI Output
// Generate StarUML-compatible XMI
new docbox.DocBox()
.addStrategy( "UML", {
outputDir : expandPath( "/app/docs/uml" ),
projectTitle : "My Application UML"
})
.generate(
source : expandPath( "/app/models" ),
mapping : "app.models"
)
Excluding Directories or Packages
new docbox.DocBox()
.addStrategy( "HTML", {
outputDir : expandPath( "/app/docs/api" ),
projectTitle : "My Application API"
})
.generate(
source : expandPath( "/app" ),
mapping : "app",
// Comma-separated paths/packages to exclude
excludes : "tests,build,app.helpers.internal,app.legacy"
)
Build Task Integration (Gradle / CommandBox)
// build/DocTask.bx (CommandBox task runner)
component {
function run() {
print.line( "Generating API documentation..." )
new docbox.DocBox()
.addStrategy( "HTML", {
outputDir : expandPath( "../docs/api" ),
projectTitle : "My Framework API"
})
.generate(
source : expandPath( "../src" ),
mapping : "myframework",
excludes : "tests"
)
print.greenLine( "Documentation generated successfully." )
}
}
Using Annotations in Source Code
DocBox extracts JavaDoc-style annotations from your BoxLang files:
/**
* User service for managing application users.
*
* @author John Doe
* @since 1.0.0
*/
class UserService {
/**
* Find a user by their ID.
*
* @id The user's unique identifier
* @return The user struct or empty struct if not found
*/
function findById( required numeric id ) {
// ...
}
}
Common Pitfalls
- ✅ The
mappingmust match the dot-notation mapping from your web root to the source directory - ❌ Don't use absolute OS paths for
mapping— use logical component paths (e.g.,app.models) - ✅ Use
expandPath()to resolve source and output directories to absolute OS paths - ❌ Nested
addStrategy()calls are fluent — they return the DocBox instance; always call.generate()last - ✅ The
excludesparameter accepts comma-separated path fragments, not regex patterns - ✅ The HTML "default" theme gives a modern SPA look; "frames" gives a classic JavaDoc layout
More from ortus-boxlang/skills
boxlang-functional-programming
Use this skill when working with BoxLang lambdas, closures, arrow functions, higher-order functions, functional array/struct pipelines (map, filter, reduce, flatMap, groupBy, etc.), destructuring, or spread syntax.
10boxlang-code-reviewer
Use this skill when reviewing BoxLang code for quality, correctness, security vulnerabilities, performance issues, style violations, or when providing structured code review feedback following BoxLang best practices and security guidelines.
9boxlang-best-practices
Use this skill when writing, reviewing, or improving BoxLang code to ensure it follows community best practices for naming, structure, scoping, error handling, performance, and maintainability.
9boxlang-classes-and-oop
Use this skill when writing BoxLang classes, components, interfaces, inheritance hierarchies, annotations, properties, constructors, or applying object-oriented design patterns in BoxLang.
9boxlang-web-development
Use this skill when building BoxLang web applications: Application.bx lifecycle, request/response handling, sessions, forms, REST APIs, HTTP clients, routing, CSRF protection, Server-Sent Events, or configuring CommandBox/MiniServer.
8boxlang-configuration
Use this skill when configuring BoxLang runtime settings via boxlang.json, setting environment variables for config overrides, configuring datasources, caches, executors, modules, logging, security, or schedulers — or when helping someone understand the BoxLang configuration system.
8