X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fdocumentation.lisp;h=108946e9df4564acc3646b2262aae2dbb76800f6;hb=c482b4547542853e71a3af2870c87ea366069913;hp=7efc1b008e49888ae347a7f99525e7a4b492ca6c;hpb=0d0e9c1798e0b880b2eded19718d082c7ae2c6ef;p=jscl.git diff --git a/src/documentation.lisp b/src/documentation.lisp index 7efc1b0..108946e 100644 --- a/src/documentation.lisp +++ b/src/documentation.lisp @@ -1,26 +1,41 @@ ;;; documentation.lisp --- Accessing DOCUMENTATION +;;; Documentation. +(defun documentation (x type) + "Return the documentation of X. TYPE must be the symbol VARIABLE or FUNCTION." + (ecase type + (function + (let ((func (fdefinition x))) + (oget func "docstring"))) + (variable + (unless (symbolp x) + (error "The type of documentation `~S' is not a symbol." type)) + (oget x "vardoc")))) + + ;;; APROPOS and friends -(defun map-apropos-symbols (function string package) +(defun map-apropos-symbols (function string package external-only) (flet ((handle-symbol (symbol) - ;; TODO: it's implementation-dependent, though CHAR-EQUAL seems - ;; more reasonable nevertheless - (when (search string (symbol-name symbol) :test #'char=) + (when (search string (symbol-name symbol) :test #'char-equal) (funcall function symbol)))) (if package - (do-symbols (symbol package) (handle-symbol symbol)) - (do-all-symbols (symbol) (handle-symbol symbol))))) + (if external-only + (do-external-symbols (symbol package) (handle-symbol symbol)) + (do-symbols (symbol package) (handle-symbol symbol))) + (if external-only + (do-all-external-symbols (symbol) (handle-symbol symbol)) + (do-all-symbols (symbol) (handle-symbol symbol)))))) -(defun apropos-list (string &optional package) +(defun apropos-list (string &optional package external-only) (let (symbols) (map-apropos-symbols (lambda (symbol) (pushnew symbol symbols :test #'eq)) - string package) + string package external-only) symbols)) -(defun apropos (string &optional package) +(defun apropos (string &optional package external-only) (map-apropos-symbols (lambda (symbol) (format t "~S" symbol) @@ -29,7 +44,7 @@ (when (fboundp symbol) (format t " (fbound)")) (terpri)) - string package)) + (string string) package external-only)) ;;; DESCRIBE