From ca9223e0b2cac5a2cab6d967b7cd8b94082bba29 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 14 Oct 2022 04:53:51 +0100 Subject: wee refactorings --- src/geiser/geiser-data.ss | 4 +--- src/geiser/geiser.ss | 18 ++++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/geiser/geiser-data.ss b/src/geiser/geiser-data.ss index 0176e59..e4aeba7 100644 --- a/src/geiser/geiser-data.ss +++ b/src/geiser/geiser-data.ss @@ -26,9 +26,7 @@ (let ((id (car x)) (sgs (let* ((s (format "(~a)" (cadr x))) (as (with-input-from-string s read))) - (and (list? as) - (list? (car as)) - (map cdr (remove '~ as)))))) + (and (list? (car as)) (map cdr (remove '~ as)))))) (symbol-hashtable-set! h id (cons id (cons sgs (cddr x)))))) d) h)) diff --git a/src/geiser/geiser.ss b/src/geiser/geiser.ss index 9ec73e8..62cd6ad 100644 --- a/src/geiser/geiser.ss +++ b/src/geiser/geiser.ss @@ -187,7 +187,7 @@ (l (string-length s))) (if (<= l max-len) s (string-append (substring s 0 sub-len) sub-str)))) - (define (operator-arglist operator) + (define (id-autodoc id) (define (procedure-parameter-list id p) (and (procedure? p) (or (source->parameter-list p) @@ -199,21 +199,19 @@ (else `(("required" . ,(reverse req)) ("optional" ,args))))) (define (autodoc-arglist arglist) (autodoc-arglist* arglist '())) - (let ([binding (try-eval operator)]) + (define (signature as) `(,id ("args" ,@(map autodoc-arglist as)))) + (let ([binding (try-eval id)]) (if (not (eq? binding not-found)) - (let ([arglists (procedure-parameter-list operator binding)]) - (cond ((null? arglists) `(,operator ("args" (("required"))))) - (arglists - `(,operator ("args" ,@(map autodoc-arglist arglists)))) - (else `(,operator ("value" . ,(value->string binding)))))) - (let ((s (symbol-signatures operator))) - (if s `(,operator ("args" ,@(map autodoc-arglist s))) '()))))) + (let ([as (procedure-parameter-list id binding)]) + (if as (signature as) `(,id ("value" . ,(value->string binding))))) + (let ((s (symbol-signatures id))) + (if s (signature s) '()))))) (define (geiser:autodoc ids) (cond ((null? ids) '()) ((not (list? ids)) (geiser:autodoc (list ids))) ((not (symbol? (car ids))) (geiser:autodoc (cdr ids))) - (else (map operator-arglist ids)))) + (else (map id-autodoc ids)))) (define (geiser:symbol-location id . env) (let* ([b (try-eval id (current-environment))] -- cgit v1.2.3