fukamachi / caveman

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

Change defroute to allow autogeneration of documentation #108

Closed knobo closed 5 years ago

knobo commented 6 years ago

Documentation can be generated like this:

(defroute doc "/doc" ()
  "This url shows this the documentation"
  (let ((docs (mapcar (lambda (route)
                        (list
                         (myway.rule::rule-url (myway.route:route-rule route))
                         (documentation (ningle.route:route-controller route) 'function)
                         (map-set:ms-map 'list 'identity (myway.rule::rule-methods (myway.route:route-rule route)))
                         (myway.rule::rule-param-keys (myway.route:route-rule route))))
                      (myway:mapper-routes (ningle.app::mapper *web*)))))
    (with-html-output-to-string (s nil :prologue t)
      (:html
       (:head)
       (:body
        (loop for (url docstring methods params) in docs
           do (htm (:h3 (str url) " " (fmt "~a" methods))
                   (if params (htm (:h4 (fmt " Params: ~a" params))))
                   (:div (str docstring)))))))))
knobo commented 5 years ago

The checks fail because prove no longer works together with sbcl.

fukamachi commented 5 years ago

Thanks!