Using extra CFC attributes for documentation

November 12, 2009 · Chris Peters

Using some extra CFC attributes and CFML's GetMetaData() function, we wrote a pretty cool documentation parser for CFWheels.

For the CFWheels API documentation, we chose to do something a little unconventional (but pretty cool). Using some extra CFC attributes and CFML’s GetMetaData() function, we wrote a pretty cool documentation parser for CFWheels.

Look at this example for the autoLink() view helper:

view raw autolink.cfm hosted with ❤ by GitHub

It makes the function declarations a little beefier, but the documentation is right there with the code. As you can see, we added examples, categories, and functions attributes to the <cffunction> declaration.

Writing a parser took a little over a week, but it was fairly simple with CFML’s GetMetaData() function and some extra business rules.

See the autoLink() documentation on CFWheels.org so you can see what the output looks like. Everything on that page is generated based on the code above.

About Chris Peters

With over 20 years of experience, I help plan, execute, and optimize digital experiences.

Leave a comment