[Openmcl-devel] Lisp DOC

Alexander Repenning ralex at cs.colorado.edu
Thu Nov 13 15:57:33 PST 2008

It is simple to write little code producing a LOT of documentation  
with Lisp. The trivial little hack below produces documentation for  
the entire CL class tree. Especially when classes  
include :documentation even the code below is somewhat useful.  
However, my real question is this. Is anybody aware of some Java DOC- 
like tool for Lisp? That is, something like that thing below but with  
formated output (e.g., HTML with style sheet)? It would seem to be  
such an obvious and simple thing to do in Lisp that I would assume it  
already exists?


;; ---- lisp-doc.lisp -------

(in-package :ccl)

(defparameter *Classes-Documented* (make-hash-table))

(defun RENDER-CLASS-DOC (Classes &optional (Level 0))
   (when (not (listp Classes))
     (render-class-doc (list Classes) Level)
     (return-from render-class-doc))
   (when (= Level 0) (setf *Classes-Documented* (make-hash-table)))
   (dolist (Class Classes)
     (when (symbolp Class) (setf Class (find-class Class)))
     (unless (gethash (slot-value Class 'name) *Classes-Documented*)
       (setf (gethash (slot-value Class 'name) *Classes-Documented*)  
       (dotimes (I (* 2 Level)) (princ #\space))
       (princ (slot-value Class 'name))
       (let ((Documentation (documentation (slot-value Class 'name)  
         (when Documentation
           (format t ": ~A" Documentation)))
       (let ((Slot-Names (mapcar #'slot-definition-name (class-direct- 
slots Class))))
         (when Slot-Names
           (dotimes (I (* 2 (+ Level 2))) (princ #\space))
           (format t "slots: ")
           (dolist (Slot-Name (butlast Slot-Names))
             (format t "~:(~A~), " Slot-Name))
           (format t "~:(~A~)" (first (last Slot-Names)))
       (render-class-doc (slot-value Class 'direct-subclasses) (1+  

#| Examples:

(render-class-doc 'number)  ;; no much :documentation here in CCL

(render-class-doc 't) ;; same here


More information about the Openmcl-devel mailing list