summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-10-09 22:06:54 +0100
committerjao <jao@gnu.org>2022-10-09 22:06:54 +0100
commite80f797a5c8e3b5ea647fb74194fea161df0550b (patch)
tree0218968f9f532ab5911f19e08e8f0a79fad9a704
parent39b7e9357d0be4ae80268e073c8e077ecd7c1387 (diff)
downloadgeiser-chez-e80f797a5c8e3b5ea647fb74194fea161df0550b.tar.gz
geiser-chez-e80f797a5c8e3b5ea647fb74194fea161df0550b.tar.bz2
autodoc: fix for arity 0 functions
-rw-r--r--src/geiser/geiser.ss23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/geiser/geiser.ss b/src/geiser/geiser.ss
index dae82c0..04fbca8 100644
--- a/src/geiser/geiser.ss
+++ b/src/geiser/geiser.ss
@@ -74,6 +74,14 @@
(map write-to-string
(environment-symbols (interaction-environment))))))
+ (define not-found (gensym))
+
+ (define (try-eval sym . env)
+ (call/cc
+ (lambda (k)
+ (with-exception-handler (lambda (e) (k not-found))
+ (lambda () (if (null? env) (eval sym) (eval sym (car env))))))))
+
(define (geiser:eval module form)
(call-with-result
(lambda () (if module (eval form (environment module)) (eval form)))))
@@ -137,14 +145,6 @@
(l (string-length s)))
(if (<= l max-len) s (string-append (substring s 0 sub-len) sub-str))))
- (define not-found (gensym))
-
- (define (try-eval sym)
- (call/cc
- (lambda (k)
- (with-exception-handler (lambda (e) (k not-found))
- (lambda () (eval sym))))))
-
(define (operator-arglist operator)
(define (procedure-parameter-list p)
(and (procedure? p)
@@ -159,9 +159,10 @@
(let ([binding (try-eval operator)])
(if (not (eq? binding not-found))
(let ([arglists (procedure-parameter-list binding)])
- (if arglists
- `(,operator ("args" ,@(map autodoc-arglist arglists)))
- `(,operator ("value" . ,(value->string binding)))))
+ (cond ((null? arglists) `(,operator ("args" (("required")))))
+ (arglists
+ `(,operator ("args" ,@(map autodoc-arglist arglists))))
+ (else `(,operator ("value" . ,(value->string binding))))))
'())))
(define (geiser:autodoc ids)