[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-guile 134606d 102/284: Guile: Support for multiple
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-guile 134606d 102/284: Guile: Support for multiple arities in autodoc. |
Date: |
Sun, 1 Aug 2021 18:29:25 -0400 (EDT) |
branch: elpa/geiser-guile
commit 134606d2d291ac828ccda24d068243851f33ae84
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Guile: Support for multiple arities in autodoc.
---
geiser/doc.scm | 60 ++++++++++++++++++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 27 deletions(-)
diff --git a/geiser/doc.scm b/geiser/doc.scm
index 83bce66..c7ad79d 100644
--- a/geiser/doc.scm
+++ b/geiser/doc.scm
@@ -37,36 +37,40 @@
(let ((args (obj-args obj)))
(and args (signature name args))))
-(define (signature id args)
- (define (arglst kind)
+(define (signature id args-list)
+ (define (arglst args kind)
(let ((args (assq-ref args kind)))
(cond ((or (not args) (null? args)) '())
((list? args) args)
(else (list args)))))
- `(,id
- (args ,@(if (list? args)
- `(((required ,@(arglst 'required))
- (optional ,@(arglst 'optional)
- ,@(let ((rest (assq-ref args 'rest)))
- (if rest (list "...") '())))
- (key ,@(arglst 'keyword))))
- '()))))
+ (define (mkargs as)
+ `((required ,@(arglst as 'required))
+ (optional ,@(arglst as 'optional)
+ ,@(let ((rest (assq-ref as 'rest)))
+ (if rest (list "...") '())))
+ (key ,@(arglst as 'keyword))))
+ (let ((args-list (map mkargs (if (list? args-list) args-list '()))))
+ (list id (cons 'args args-list))))
(define (obj-args obj)
(cond ((not obj) #f)
((or (procedure? obj) (program? obj)) (arguments obj))
- ((macro? obj) '((required ...)))
+ ((macro? obj) '(((required ...))))
(else 'variable)))
(define (arguments proc)
- (cond
- ((is-a? proc <generic>) (generic-args proc))
- ((procedure-property proc 'arglist) => arglist->args)
- ((procedure-source proc) => source->args)
- ((program? proc) ((@ (system vm program) program-arguments) proc))
- ((doc->args proc))
- ((procedure-property proc 'arity) => arity->args)
- (else #f)))
+ (define (p-arguments prog)
+ (map (lambda (a) ((@@ (system vm program) arity->arguments) prog a))
+ (or (program-arities prog) '())))
+ (define (clist f) (lambda (x) (let ((y (f x))) (and y (list y)))))
+ (cond ((is-a? proc <generic>) (generic-args proc))
+ ((procedure-property proc 'arglist) => (clist arglist->args))
+ ((procedure-source proc) => (clist source->args))
+ ((program? proc) (let ((a (p-arguments proc)))
+ (and (not (null? a)) a)))
+ ((doc->args proc) => list)
+ ((procedure-property proc 'arity) => (clist arity->args))
+ (else #f)))
(define (source->args src)
(let ((formals (cadr src)))
@@ -109,7 +113,8 @@
(let* ((match (or (string-match proc-rx doc)
(string-match proc-rx2 doc)))
(args (and match
- (parse-signature-string (match:substring match
1)))))
+ (parse-signature-string
+ (match:substring match 1)))))
(set-procedure-property! proc 'geiser-document-args args)
args)))
(else #f)))
@@ -138,7 +143,10 @@
req
(cons (match:substring m 1) opt)
rest)))
- (else (loop (cdr tokens) (cons (car tokens) req) opt
rest)))))))
+ (else (loop (cdr tokens)
+ (cons (car tokens) req)
+ opt
+ rest)))))))
(define (generic-args gen)
(define (src> src1 src2)
@@ -149,13 +157,11 @@
(lambda (k . a) #f)))
(let* ((methods (generic-function-methods gen))
(srcs (filter identity (map src methods))))
- (cond ((and (null? srcs) (null? methods)) '((rest . rest)))
- ((and (null? srcs)
+ (cond ((and (null? srcs)
(not (null? methods))
- (method-procedure (car methods)))
- => arguments)
- ((not (null? srcs)) (source->args (car (sort! srcs src>))))
- (else '((rest . rest))))))
+ (method-procedure (car methods))) => arguments)
+ ((not (null? srcs)) (list (source->args (car (sort! srcs src>)))))
+ (else '(((rest . rest)))))))
(define (symbol-documentation sym)
(let ((obj (symbol->object sym)))
- [nongnu] elpa/geiser-guile a329773 094/284: BSD relicensing: Guile code., (continued)
- [nongnu] elpa/geiser-guile a329773 094/284: BSD relicensing: Guile code., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 694539c 101/284: Guile: bug fix: a macro-transformer is not a good arity info source., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8f57a6a 034/284: Autodoc system revamped., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile f48e83f 065/284: Accept a list as Guile binary., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 4e1d945 088/284: Simpler, more correct and efficient autodoc implementation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 6d3f98b 085/284: Guile: unbreaking evaluation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 0e5a52b 090/284: Leftover removed., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 58ae3a1 100/284: Cosmetics., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 5807a76 105/284: Guile: adjustment to stack size display., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile a405f22 104/284: Guile: fix for file loading (we always compile them now)., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 134606d 102/284: Guile: Support for multiple arities in autodoc.,
Philip Kaludercic <=
- [nongnu] elpa/geiser-guile c34995d 110/284: Guile: support for the REPL debugger, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 55c37c7 109/284: Guile: Minimal support for the new REPL debug mode., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile a9f26f1 115/284: Guile: slightly better compilation error regexps., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 11c2d58 138/284: Guile: excluding anonymous module names from completion., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 1c9457a 116/284: Guile: heuristically resolving relative paths in REPL errors., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile f1ac35f 140/284: Guile: filtering gensym names in autodoc display., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 6baa7d3 124/284: Guile: better stack trace limits during evaluation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 14c1689 132/284: Guile: no more module loading under the rug., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile e43cfa8 121/284: Guile: evaluation fixes (current git head)., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile d41ac93 123/284: Debugging leftover., Philip Kaludercic, 2021/08/01