1 ;;; documentation.lisp --- Accessing DOCUMENTATION
4 (defun documentation (x type)
5 "Return the documentation of X. TYPE must be the symbol VARIABLE or FUNCTION."
8 (let ((func (fdefinition x)))
9 (oget func "docstring")))
12 (error "The type of documentation `~S' is not a symbol." type))
16 ;;; APROPOS and friends
18 (defun map-apropos-symbols (function string package external-only)
19 (flet ((handle-symbol (symbol)
20 (when (search string (symbol-name symbol) :test #'char-equal)
21 (funcall function symbol))))
24 (do-external-symbols (symbol package) (handle-symbol symbol))
25 (do-symbols (symbol package) (handle-symbol symbol)))
27 (do-all-external-symbols (symbol) (handle-symbol symbol))
28 (do-all-symbols (symbol) (handle-symbol symbol))))))
30 (defun apropos-list (string &optional package external-only)
34 (pushnew symbol symbols :test #'eq))
35 string package external-only)
38 (defun apropos (string &optional package external-only)
41 (format t "~S" symbol)
43 (format t " (bound)"))
44 (when (fboundp symbol)
45 (format t " (fbound)"))
47 (string string) package external-only))
51 ;; TODO: this needs DESCRIBE-OBJECT as generic method
52 ;; TODO: indentation for nested paragraphs
53 (defun describe (object &optional stream)
54 (declare (ignore stream))
57 (format t "~S~% [cons]~%" object))
59 (format t "~S~% [integer]~%" object))
61 (format t "~S~% [symbol]~%" object)
63 (format t "~%~A names a special variable:~% Value: ~A~%"
64 object (symbol-value object))
65 (let ((documentation (documentation object 'variable)))
67 (format t " Documentation:~%~A~%" documentation))))
68 (when (fboundp object)
69 (format t "~%~A names a function:~%" object)
70 (let ((documentation (documentation object 'function)))
72 (format t " Documentation:~%~A~%" documentation)))))
74 (format t "~S~% [string]~%~%Length: ~D~%"
75 object (length object)))
77 (format t "~S~% [float]~%" object))
79 (format t "~S~% [array]~%" object))
81 (format t "~S~% [function]~%" object)
82 (let ((documentation (documentation object 'function)))
84 (format t " Documentation:~%~A~%" documentation))))
86 (warn "~A not implemented yet for ~A" 'describe object)))