summaryrefslogtreecommitdiff
path: root/scheme
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
commitab13b7ff828f1f510f66f1b5d712e03a42b85ac0 (patch)
tree8898b7f8b7645c288a940370473ec95f6313ea73 /scheme
parent1f1ee00402edcaad21e471e9f378425284ac3d78 (diff)
downloadgeiser-chez-ab13b7ff828f1f510f66f1b5d712e03a42b85ac0.tar.gz
geiser-chez-ab13b7ff828f1f510f66f1b5d712e03a42b85ac0.tar.bz2
Chez: add rudimentary autodoc support
Diffstat (limited to 'scheme')
-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)