From 1e91a62f72d5403dc2651ab3f2156c446cbeed41 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 14 Oct 2022 04:33:59 +0100 Subject: fix: multiple arities in chez-docs signatures --- src/geiser/geiser-data.ss | 13 ++++++++----- src/geiser/geiser.ss | 10 +++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/geiser/geiser-data.ss b/src/geiser/geiser-data.ss index f9fc81e..0176e59 100644 --- a/src/geiser/geiser-data.ss +++ b/src/geiser/geiser-data.ss @@ -17,20 +17,23 @@ (library (geiser-data) - (export symbol-signature symbol-labels) + (export symbol-signatures symbol-labels) (import (chezscheme)) (define (make-hash d) (let ((h (make-hashtable symbol-hash eq?))) (for-each (lambda (x) (let ((id (car x)) - (sg (let ((a (with-input-from-string (cadr x) read))) - (if (list? a) (cdr a) a)))) - (symbol-hashtable-set! h id (cons id (cons sg (cddr 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)))))) + (symbol-hashtable-set! h id (cons id (cons sgs (cddr x)))))) d) h)) - (define (symbol-signature s) + (define (symbol-signatures s) (let ((x (or (symbol-hashtable-ref csug-data s #f) (symbol-hashtable-ref tspl-data s #f)))) (and x (list? (cadr x)) (cadr x)))) diff --git a/src/geiser/geiser.ss b/src/geiser/geiser.ss index 806f593..9ec73e8 100644 --- a/src/geiser/geiser.ss +++ b/src/geiser/geiser.ss @@ -187,15 +187,11 @@ (l (string-length s))) (if (<= l max-len) s (string-append (substring s 0 sub-len) sub-str)))) - (define (docs->parameter-list id) - (let ((s (symbol-signature id))) - (and s (list s)))) - (define (operator-arglist operator) (define (procedure-parameter-list id p) (and (procedure? p) (or (source->parameter-list p) - (docs->parameter-list id) + (symbol-signatures id) (arity->parameter-list p)))) (define (autodoc-arglist* args req) (cond ((null? args) (list (list* "required" (reverse req)))) @@ -210,8 +206,8 @@ (arglists `(,operator ("args" ,@(map autodoc-arglist arglists)))) (else `(,operator ("value" . ,(value->string binding)))))) - (let ((s (symbol-signature operator))) - (if s `(,operator ("args" (("required" ,@s)))) '()))))) + (let ((s (symbol-signatures operator))) + (if s `(,operator ("args" ,@(map autodoc-arglist s))) '()))))) (define (geiser:autodoc ids) (cond ((null? ids) '()) -- cgit v1.2.3