scalatra/scalatra — pull request #151 by robb1e (2011-12-23 18:20:12+00:00)
Title: Feature/docs

Hello chaps!

Please find my new extension for making documentation of routes easier. There is one change to the core project where I've renamed methodRoutes in RouteRegistry to _methodRoutes and made this available to classes extending the Kernel. In exposing this, I clone this so no-one can mess with this collection. There is an existing entryPoints function but this gives a list of strings of the routes and doesn't allow any extending classes access to the new metadata in the Route class.

The extension itself is a new project (docs) and has a couple of case classes for documentation of the route and of a parameter. There is a convenience case class for a list of Param to make the toHtml function call neater in the Documentation case class.

To use documentation (see the DocumentationExample also) you mixin DocumentationSupport which provides an implicit def of a documentation to RouteTransformer so this sets up the route and meta data for documentation appropriately. It also allows a way to get a list of all Documentation classes along with some default HTML implementations.

My intention is that a project could use the default HTML, but they would just as likely pull the documentation classes into their own filter/servlet and render in a more pleasing way for their project. I did consider but later removed having an 'id' field so the document could be keyed and used in a URI.

Hope it all looks good for you, but am happy to make any changes you suggest.

Cheers

Robbie