| name | coldbox-docbox-annotations |
| description | Use this skill when writing JavaDoc-style DocBox comments on BoxLang or CFML classes, properties, functions, and arguments; adding @author/@version/@since/@return/@throws/@deprecated block tags; using @doc.type for generic array/struct types; or preparing source code for API documentation generation with DocBox. |
DocBox Annotations
When to Use This Skill
Use this skill when:
- Adding documentation comments to BoxLang or CFML components
- Annotating functions with parameter and return type documentation
- Marking deprecated APIs or specifying generic types
- Preparing source code so DocBox can generate API docs
Language Mode Reference
Examples use BoxLang (.bx) syntax by default. Adapt for your target language:
| Concept | BoxLang (.bx) | CFML (.cfc) |
|---|
| Class declaration | class [extends="..."] { | component [extends="..."] { |
| DI annotation | @inject above property name="svc"; | property name="svc" inject="svc"; |
| View templates | .bxm suffix | .cfm / .cfml suffix |
| Tag prefix | <bx:if>, <bx:output>, <bx:set> | <cfif>, <cfoutput>, <cfset> |
CFML Compat Mode: With BoxLang + CFML Compat module, .bx and .cfc files coexist freely. BoxLang-native classes use class {} (.bx files); CFML-compat classes use component {} (.cfc files).
Comment Block Syntax
DocBox parses /** ... */ JavaDoc-style comments placed immediately above the element being documented.
Annotating a Class / Component
BoxLang
class extends="coldbox.system.EventHandler" {
}
CFML
/**
* Manages user authentication and session lifecycle.
*
* @author Luis Majano
* @version 1.5
* @since 1.0
*/
component extends="coldbox.system.EventHandler" {
// ...
}
Annotating Properties
Place the comment block directly above the property declaration.
property name="wirebox" inject="wirebox";
property name="legacyCacheProvider" type="any";
property name="allowedMethods" type="array" default="[]";
Annotating Functions
Place the comment block immediately before the function signature. Arguments are documented with @argName tags; the return value with @return; exceptions with @throws.
User function createUser(
required string email,
required string password,
string displayName = ""
) { ... }
Argument Sub-Annotations (Dot Notation)
Use dot notation to add metadata to a specific argument without affecting others.
any function findById( required numeric id, string format = "entity", string outputFormat = "entity" ) { ... }
Core Block Tags Reference
| Tag | Applies To | Purpose |
|---|
@author | Class | Author name and optional contact |
@version | Class | Current version number |
@since | Class / Function | First version this element appeared |
@return | Function | Description of the return value |
@throws | Function | Exception types the function can throw (one per exception) |
@deprecated | Any | Mark element as deprecated; add migration hint |
@{argName} | Function | Document a specific argument |
@{argName}.{attr} | Function | Sub-annotation for an argument (e.g., .deprecated, .since) |
Using @doc.type for Generic Types
BoxLang/CFML has no generics, but @doc.type tells DocBox what kind of values an array, struct, or any typed element actually contains:
array function getOrders() { ... }
property name="rolePermissions" type="struct";
Inline HTML in Descriptions
DocBox renders descriptions as HTML, so you can use basic markup:
void function index( event, rc, prc ) { ... }
Complete ColdBox Handler Example
class extends="coldbox.system.EventHandler" {
property name="userService" inject="UserService";
function index( event, rc, prc ) {
prc.users = userService.list(
page : rc.page ?: 1,
pageSize : rc.pageSize ?: 25
)
event.setView( "users/index" )
}
function show( event, rc, prc ) {
prc.user = userService.findOrFail( rc.userId )
event.setView( "users/show" )
}
function create( event, rc, prc ) {
prc.user = userService.create( rc )
relocate( "users.show", { userId: prc.user.getId() } )
}
function delete( event, rc, prc ) { ... }
}
Common Mistakes to Avoid
| Mistake | Correct Pattern |
|---|
/* ... */ (single star) | /** ... */ (double star — DocBox only parses /**) |
Skipping @return on non-void functions | Always document the return type and what it contains |
Using @param (Javadoc Java style) | Use @argName matching the actual argument name |
| Placing comment after the declaration | Comment must be immediately above the declaration |
Empty comment blocks /** */ | Add at least a one-sentence description |