summaryrefslogtreecommitdiff
path: root/scheme/chez
diff options
context:
space:
mode:
authorPeter <craven@gmx.net>2016-05-02 11:03:30 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2016-05-02 21:15:49 +0200
commit2e335695fc1a4a0b520b50deb761b958194cbec4 (patch)
tree500e7d8380a5230b15fdfdce9afdb4f0b5223d65 /scheme/chez
parentddf6ce8db51ab270faee5edb723f91c827e62a57 (diff)
downloadgeiser-guile-2e335695fc1a4a0b520b50deb761b958194cbec4.tar.gz
geiser-guile-2e335695fc1a4a0b520b50deb761b958194cbec4.tar.bz2
Chez: add rudimentary autodoc support
Diffstat (limited to 'scheme/chez')
-rw-r--r--scheme/chez/geiser/geiser.ss49
1 files changed, 48 insertions, 1 deletions
diff --git a/scheme/chez/geiser/geiser.ss b/scheme/chez/geiser/geiser.ss
index 3dbed7f..2fa648c 100644
--- a/scheme/chez/geiser/geiser.ss
+++ b/scheme/chez/geiser/geiser.ss
@@ -52,8 +52,55 @@
(substring? prefix el))
(map write-to-string (library-list))))
+ (define (procedure-parameter-list p)
+ ;; same as (inspect object), then hitting c
+ (let ((s (((inspect/object p) 'code) 'source)))
+ (if s
+ (let ((form (s 'value)))
+ (if (and (list? form)
+ (> (length form) 2)
+ (eq? (car form) 'lambda))
+ (cadr form)
+ #f))
+ #f)))
+
+ (define (operator-arglist operator)
+ (let ((binding (eval operator)))
+ (if binding
+ (let ((arglist (procedure-parameter-list binding)))
+ (let loop ((arglist arglist)
+ (optionals? #f)
+ (required '())
+ (optional '()))
+ (cond ((null? arglist)
+ `(,operator ("args" (("required" ,@(reverse required))
+ ("optional" ,@(reverse optional))
+ ("key")
+ ;; ("module" ,module)
+ ))))
+ ((symbol? arglist)
+ (loop '()
+ #t
+ required
+ (cons "..." (cons arglist optional))))
+ (else
+ (loop
+ (cdr arglist)
+ optionals?
+ (if optionals? required (cons (car arglist) required))
+ (if optionals? (cons (car arglist) optional) optional))))))
+ '())))
+
(define (geiser:autodoc ids . rest)
- '())
+ (cond ((null? ids) '())
+ ((not (list? ids))
+ (geiser:autodoc (list ids)))
+ ((not (symbol? (car ids)))
+ (geiser:autodoc (cdr ids)))
+ (else
+ (map (lambda (id)
+ (operator-arglist id))
+ ids))))
(define (geiser:no-values)
#f)