diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-17 01:31:26 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-17 01:31:26 +0100 |
commit | 75df3b13501f2ccfc9ec8c7408795e5e8d5d067e (patch) | |
tree | 28c3bc6fa42c199a130ff7e1646f3b1c21674857 | |
parent | 08ba036c3056c3e5611c0fbf630bf7f08c525192 (diff) | |
download | geiser-guile-75df3b13501f2ccfc9ec8c7408795e5e8d5d067e.tar.gz geiser-guile-75df3b13501f2ccfc9ec8c7408795e5e8d5d067e.tar.bz2 |
Better symbol documentation.
-rw-r--r-- | geiser/emacs.scm | 2 | ||||
-rw-r--r-- | geiser/introspection.scm | 54 |
2 files changed, 28 insertions, 28 deletions
diff --git a/geiser/emacs.scm b/geiser/emacs.scm index b5ba284..36428f9 100644 --- a/geiser/emacs.scm +++ b/geiser/emacs.scm @@ -30,7 +30,7 @@ ge:symbol-location ge:compile-file ge:load-file - ge:docstring + ge:symbol-documentation ge:all-modules ge:module-children ge:module-location) diff --git a/geiser/introspection.scm b/geiser/introspection.scm index 2021a32..5d86d62 100644 --- a/geiser/introspection.scm +++ b/geiser/introspection.scm @@ -28,7 +28,7 @@ #:export (arguments completions symbol-location - docstring + symbol-documentation all-modules module-children module-location) @@ -128,34 +128,34 @@ (define module-filename (@@ (ice-9 session) module-filename)) -(define (display-docstring sym) +(define (docstring sym obj) + (with-output-to-string + (lambda () + (let* ((type (cond ((macro? obj) "A macro") + ((procedure? obj) "A procedure") + ((program? obj) "A compiled program") + (else "An object"))) + (modname (symbol-module sym)) + (doc (object-documentation obj))) + (display type) + (if modname + (begin + (display " in module ") + (display modname))) + (newline) + (if doc (display doc)))))) + +(define (obj-signature sym obj) + (let* ((args (obj-args obj)) + (req (and args (car args))) + (opt (and args (cadr args)))) + (and args (if (not opt) `(,sym ,@req) `(,sym ,@req . ,opt)) sym))) + +(define (symbol-documentation sym) (let ((obj (symbol->obj sym))) (if obj - (let* ((args (obj-args obj)) - (req (and args (car args))) - (opt (and args (cadr args))) - (signature (if args - (if (not opt) `(,sym ,@req) `(,sym ,@req . ,opt)) - sym)) - (type (cond ((macro? obj) "A macro") - ((procedure? obj) "A procedure") - ((program? obj) "A compiled program") - (else "An object"))) - (modname (symbol-module sym)) - (doc (object-documentation obj))) - (display signature) - (newline) - (display type) - (if modname - (begin - (display " in module ") - (display modname))) - (newline) - (if doc (display doc)))))) - -(define (docstring sym) - (with-output-to-string - (lambda () (display-docstring sym)))) + `((signature . ,(or (obj-signature sym obj) sym)) + (docstring . ,(docstring sym obj)))))) (define (all-modules) (let ((roots ((@@ (ice-9 session) root-modules)))) |