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 ;; TODO: it's implementation-dependent, though CHAR-EQUAL seems
21 ;; more reasonable nevertheless
22 (when (search string (symbol-name symbol) :test #'char=)
23 (funcall function symbol))))
26 (do-external-symbols (symbol package) (handle-symbol symbol))
27 (do-symbols (symbol package) (handle-symbol symbol)))
29 (do-all-external-symbols (symbol) (handle-symbol symbol))
30 (do-all-symbols (symbol) (handle-symbol symbol))))))
32 (defun apropos-list (string &optional package external-only)
36 (pushnew symbol symbols :test #'eq))
37 string package external-only)
40 (defun apropos (string &optional package external-only)
43 (format t "~S" symbol)
45 (format t " (bound)"))
46 (when (fboundp symbol)
47 (format t " (fbound)"))
49 string package external-only))
53 ;; TODO: this needs DESCRIBE-OBJECT as generic method
54 ;; TODO: indentation for nested paragraphs
55 (defun describe (object &optional stream)
56 (declare (ignore stream))
59 (format t "~S~% [cons]~%" object))
61 (format t "~S~% [integer]~%" object))
63 (format t "~S~% [symbol]~%" object)
65 (format t "~%~A names a special variable:~% Value: ~A~%"
66 object (symbol-value object))
67 (let ((documentation (documentation object 'variable)))
69 (format t " Documentation:~%~A~%" documentation))))
70 (when (fboundp object)
71 (format t "~%~A names a function:~%" object)
72 (let ((documentation (documentation object 'function)))
74 (format t " Documentation:~%~A~%" documentation)))))
76 (format t "~S~% [string]~%~%Length: ~D~%"
77 object (length object)))
79 (format t "~S~% [float]~%" object))
81 (format t "~S~% [array]~%" object))
83 (format t "~S~% [function]~%" object)
84 (let ((documentation (documentation object 'function)))
86 (format t " Documentation:~%~A~%" documentation))))
88 (warn "~A not implemented yet for ~A" 'describe object)))