File size: 1,471 Bytes
d69fc90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | (in-package :cl-user)
(defpackage cl-annot.doc
(:nicknames :annot.doc)
(:use :cl
:annot.util
:annot.helper)
(:export :doc))
(in-package :annot.doc)
(defannotation doc (docstring definition-form)
(:arity 2)
"Add DOCSTRING documentation for DEFINITION-FORM."
(progn-form-replace-last
(lambda (definition-form)
(case (definition-form-type definition-form)
((defvar defparameter defconstant defun defmethod defmacro
deftype define-compiler-macro)
(destructuring-bind (def name arg . body)
definition-form
`(,def ,name ,arg ,docstring ,@body)))
((defstruct)
(destructuring-bind (def name-and-options . slots)
definition-form
`(,def ,name-and-options ,docstring ,@slots)))
((defclass define-condition)
(destructuring-bind (def name supers slots . opts)
definition-form
(pushnew `(:documentation ,docstring)
opts :key #'car)
`(,def ,name ,supers ,slots
,@opts)))
((defgeneric)
(destructuring-bind (def name args . opts)
definition-form
(pushnew `(:documentation ,docstring)
opts :key #'car)
`(,def ,name ,args
,@opts)))
(t (error "Documentation not supported: ~a"
definition-form))))
definition-form))
;; todo:
;; define-compiler-macro define-condition
;; define-method-combination define-modify-macro
;; define-setf-expander define-symbol-macro
|