fukamachi / caveman

Lightweight web application framework for Common Lisp.
http://8arrow.org/caveman/
782 stars 63 forks source link

Autogenerate documentation #107

Closed knobo closed 5 years ago

knobo commented 6 years ago

Hi I was thinking about autogenerating documentation from the srouce code.

I came up with something like this:

(mapcar (lambda (route) (list* (if (myway.route:route-name route)
                                       (documentation (symbol-function (myway.route:route-name route)) 'function))
                                       (myway.route::route-rule route)))
  (myway::mapper-routes (ningle.app::mapper *web*)))

But I only get a docstring if I give the route a name (the first argument to defroute is a symbol).

But if I don't use a route-name, the docstring is hidden inside the lambda inside the controller. Could we do something to improve the situation here? Is there a way to access the docstring, or could we alter the code to expose the docstring?

knobo commented 6 years ago

se pr: #108

knobo commented 6 years ago

I think this is ready now. Is the code ok for you, or do you want me to do something with it first?

(defroute doc "/doc" (&key foo)
   (declare (ignore foo))
     "You can now have both declaration of variables and docstring. Isn't that nice?"
   ...)