[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-racket 1f2bc48 070/191: Racket: more information in
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-racket 1f2bc48 070/191: Racket: more information in symbol documentation |
Date: |
Sun, 1 Aug 2021 18:32:02 -0400 (EDT) |
branch: elpa/geiser-racket
commit 1f2bc487381bed27dfacc8775d1a89b894307dc0
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Racket: more information in symbol documentation
When the symbol is imported and re-exported by a second module, we
display its definition name and original module, besides the name of
the module re-exporting it.
---
geiser/autodoc.rkt | 58 ++++++++++++++++++++++++++++++++++++++++++++----------
geiser/modules.rkt | 7 +++++++
2 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/geiser/autodoc.rkt b/geiser/autodoc.rkt
index 02b4f0f..dea8f43 100644
--- a/geiser/autodoc.rkt
+++ b/geiser/autodoc.rkt
@@ -36,18 +36,20 @@
[else #f])])
(and sym (get-help sym mod)))))
-(define (symbol-documentation id)
- (let* ([val (value id (symbol-module id))]
- [sign (autodoc* id)])
+(define (symbol-documentation sym)
+ (let* ([val (value sym (symbol-module sym))]
+ [sign (autodoc* sym)])
(and sign
- (list (cons 'signature (autodoc* id #f))
- (cons 'docstring (docstring id val sign))))))
+ (list (cons 'signature (autodoc* sym #f))
+ (cons 'docstring (docstring sym val sign))))))
-(define (docstring id val sign)
+(define (docstring sym val sign)
(let* ([mod (assoc 'module (cdr sign))]
- [mod (if mod (cdr mod) "<unknown>")])
+ [mod (if mod (cdr mod) "<unknown>")]
+ [id (namespace-symbol->identifier sym)]
+ [desc (if (identifier? id) (format "~%~%~a" (describe id sym)) "")])
(if val
- (format "A ~a in module ~a.~a~a"
+ (format "A ~a in module ~a.~a~a~a"
(if (procedure? val) "procedure" "variable")
mod
(if (procedure? val)
@@ -56,8 +58,44 @@
(if (has-contract? val)
(format "~%~%Contract:~%~% ~a"
(contract-name (value-contract val)))
- ""))
- (format "A syntax object in module ~a." mod))))
+ "")
+ desc)
+ (format "An identifier in module ~a.~a" mod desc))))
+
+;; Lifted from Eli's interactive.rkt
+(define (describe id s)
+ (define b (identifier-binding id))
+ (cond
+ [(not b) (format "`~s' is a toplevel (or unbound) identifier." s)]
+ [(eq? b 'lexical) (format "`~s' is a lexical identifier." s)]
+ [(or (not (list? b)) (not (= 7 (length b))))
+ "*** internal error, racket changed ***"]
+ [else
+ (let-values ([(source-mod source-id
+ nominal-source-mod nominal-source-id
+ source-phase import-phase
+ nominal-export-phase)
+ (apply values b)])
+ (let ([aliased (not (eq? s source-id))]
+ [for-syn (eqv? source-phase 1)]
+ [amod (not (equal? source-mod nominal-source-mod))]
+ [aid (not (eq? s nominal-source-id))])
+ (if (or aliased for-syn amod aid)
+ (string-append
+ "Defined"
+ (if for-syn " for syntax" "")
+ (if aliased (format " as `~s' " source-id) "")
+ (if amod
+ (format " in module ~a\nand required~a in module ~a"
+ (module-path-index->name source-mod)
+ (if (eqv? import-phase 1) "-for-syntax" "")
+ (module-path-index->name nominal-source-mod))
+ "")
+ (if aid
+ (format ",\nwhere it is defined as `~s'" nominal-source-id)
+ "")
+ ".")
+ "")))]))
(define (value id mod)
(with-handlers ([exn? (const #f)])
diff --git a/geiser/modules.rkt b/geiser/modules.rkt
index eac3a6c..9e6e14c 100644
--- a/geiser/modules.rkt
+++ b/geiser/modules.rkt
@@ -18,6 +18,7 @@
namespace->module-path-name
module-path-name->name
module-spec->path-name
+ module-path-index->name
module-identifiers
module-list
submodules)
@@ -84,6 +85,12 @@
[(symbol? path) (symbol->string path)]
[else ""]))
+(define (module-path-index->name mpi)
+ (let ([rmp (module-path-index-resolve mpi)])
+ (if (resolved-module-path? rmp)
+ (module-path-name->name (resolved-module-path-name rmp))
+ "<unknown module>")))
+
(define namespace->module-name
(compose module-path-name->name namespace->module-path-name))
- [nongnu] elpa/geiser-racket 62e2006 114/191: Indentation for Racket's struct, (continued)
- [nongnu] elpa/geiser-racket 62e2006 114/191: Indentation for Racket's struct, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 0be1797 122/191: A better solution to the funky filename problem, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket e17099e 166/191: Skip expression quote when getting a racket symbol, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 3079c3a 163/191: Racket: displaying graphics in structured objects, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c0a617f 173/191: Begin the summary lines of all elisp libraries with three semicolons, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 99acb21 175/191: Fix indentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 6bc2bc2 176/191: Fix indentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 74a223e 008/191: Racket: autodoc for struct constructors, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 4c3903a 063/191: Better module help, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 1f64738 066/191: Racket: showing submodules in module help, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 1f2bc48 070/191: Racket: more information in symbol documentation,
Philip Kaludercic <=
- [nongnu] elpa/geiser-racket cd7378b 089/191: Racket: indentation for all 'for' forms, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 41f65a1 076/191: Fixes for locals scanning, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket d0d80d8 079/191: Racket: no errors , entering an R5RS module, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket dc63508 081/191: Racket: use the proper interaction port for input (#32844), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 12dc25e 077/191: Racket: ', enter "foo"' as a synonym of ', enter (file "foo")', Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 13dfcf3 075/191: Racket: #lang, require and provide as keywords, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c5e7ea8 100/191: Little cleanups, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 7cefe7f 074/191: No more interning in the scheme reader, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket f9fc642 102/191: Racket: fix for enter!, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 5e2184b 103/191: racket: displaying images also during evaluations, Philip Kaludercic, 2021/08/01