mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 12:20:26 +02:00
* Enhancements to online help presentation.
This commit is contained in:
parent
9d29e9906e
commit
db611983cf
3 changed files with 75 additions and 37 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2000-09-29 Neil Jerram <neil@ossau.uklinux.net>
|
||||||
|
|
||||||
|
* documentation.scm (find-documentation-in-file): Modified
|
||||||
|
according to changed format of guile-procedures.txt caused by my
|
||||||
|
snarfing/makeinfo changes in libguile.
|
||||||
|
|
||||||
|
* session.scm (help-doc): Improvements to (help) output: (i) a
|
||||||
|
friendlier Emacs-style introduction line; (ii) where the help arg
|
||||||
|
matches multiple documented entries, print an initial list of the
|
||||||
|
entries for which documentation is found, before printing the
|
||||||
|
actual documentation entries themselves.
|
||||||
|
|
||||||
2000-09-20 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
|
2000-09-20 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
|
||||||
|
|
||||||
* boot-9.scm: Removed comment. (Thanks to Brad Knotwell.)
|
* boot-9.scm: Removed comment. (Thanks to Brad Knotwell.)
|
||||||
|
|
|
@ -38,28 +38,24 @@
|
||||||
documentation-files))
|
documentation-files))
|
||||||
|
|
||||||
(define entry-delimiter "\f")
|
(define entry-delimiter "\f")
|
||||||
(define entry-start 2)
|
|
||||||
|
|
||||||
(define (find-documentation-in-file name file)
|
(define (find-documentation-in-file name file)
|
||||||
(and (file-exists? file)
|
(and (file-exists? file)
|
||||||
(let ((port (open-input-file file))
|
(let ((port (open-input-file file))
|
||||||
(name (symbol->string name)))
|
(name (symbol->string name)))
|
||||||
(let* ((len (string-length name))
|
(let ((len (string-length name)))
|
||||||
(min-size (+ entry-start len))
|
|
||||||
(end (+ entry-start len)))
|
|
||||||
(read-delimited entry-delimiter port) ;skip to first entry
|
(read-delimited entry-delimiter port) ;skip to first entry
|
||||||
(let loop ((entry (read-delimited entry-delimiter port)))
|
(let loop ((entry (read-delimited entry-delimiter port)))
|
||||||
(cond ((eof-object? entry) #f)
|
(cond ((eof-object? entry) #f)
|
||||||
;; match?
|
;; match?
|
||||||
((and ;; large enough?
|
((and ;; large enough?
|
||||||
(>= (string-length entry) min-size)
|
(>= (string-length entry) len)
|
||||||
;; matching name?
|
;; matching name?
|
||||||
(string=? (substring entry entry-start end)
|
(string=? (substring entry 0 len) name)
|
||||||
name)
|
|
||||||
;; terminated?
|
;; terminated?
|
||||||
(memq (string-ref entry end) '(#\space #\))))
|
(memq (string-ref entry len) '(#\newline)))
|
||||||
;; cut away starting and ending newline
|
;; cut away name tag and extra surrounding newlines
|
||||||
(substring entry 1 (- (string-length entry) 1)))
|
(substring entry (+ len 2) (- (string-length entry) 2)))
|
||||||
(else (loop (read-delimited entry-delimiter port)))))))))
|
(else (loop (read-delimited entry-delimiter port)))))))))
|
||||||
|
|
||||||
;; helper until the procedure documentation property is cleaned up
|
;; helper until the procedure documentation property is cleaned up
|
||||||
|
|
|
@ -63,14 +63,21 @@ You don't seem to have regular expressions installed.\n"))
|
||||||
(let ((entries (apropos-fold (lambda (module name object data)
|
(let ((entries (apropos-fold (lambda (module name object data)
|
||||||
(cons (list module
|
(cons (list module
|
||||||
name
|
name
|
||||||
(object-documentation object))
|
(object-documentation object)
|
||||||
|
(cond ((closure? object)
|
||||||
|
"a procedure")
|
||||||
|
((procedure? object)
|
||||||
|
"a primitive procedure")
|
||||||
|
(else
|
||||||
|
"an object")))
|
||||||
data))
|
data))
|
||||||
'()
|
'()
|
||||||
regexp
|
regexp
|
||||||
apropos-fold-exported))
|
apropos-fold-exported))
|
||||||
(module car)
|
(module car)
|
||||||
(name cadr)
|
(name cadr)
|
||||||
(doc caddr))
|
(doc caddr)
|
||||||
|
(type cadddr))
|
||||||
(if (null? entries)
|
(if (null? entries)
|
||||||
;; no matches
|
;; no matches
|
||||||
(begin
|
(begin
|
||||||
|
@ -80,32 +87,55 @@ You don't seem to have regular expressions installed.\n"))
|
||||||
"named `~A'\n"
|
"named `~A'\n"
|
||||||
"matching regexp \"~A\"\n")
|
"matching regexp \"~A\"\n")
|
||||||
term))
|
term))
|
||||||
(let ((first? #t))
|
(let ((first? #t)
|
||||||
(if (or-map doc entries)
|
(undocumented-entries '())
|
||||||
;; entries with documentation
|
(documented-entries '())
|
||||||
(for-each (lambda (entry)
|
(documentations '()))
|
||||||
;; *fixme*: Use `describe' when we have GOOPS?
|
|
||||||
(if (doc entry)
|
(for-each (lambda (entry)
|
||||||
(begin
|
(let ((entry-summary (simple-format #f
|
||||||
(if first?
|
"~S: ~S\n"
|
||||||
(set! first? #f)
|
(module-name (module entry))
|
||||||
(newline))
|
(name entry))))
|
||||||
(simple-format #t "~S: ~S\n~A\n"
|
(if (doc entry)
|
||||||
(module-name (module entry))
|
(begin
|
||||||
(name entry)
|
(set! documented-entries
|
||||||
(doc entry)))))
|
(cons entry-summary documented-entries))
|
||||||
entries))
|
;; *fixme*: Use `describe' when we have GOOPS?
|
||||||
(if (or-map (lambda (x) (not (doc x))) entries)
|
(set! documentations
|
||||||
;; entries without documentation
|
(cons (simple-format #f
|
||||||
|
"`~S' is ~A in the ~S module.\n\n~A\n"
|
||||||
|
(name entry)
|
||||||
|
(type entry)
|
||||||
|
(module-name (module entry))
|
||||||
|
(doc entry))
|
||||||
|
documentations)))
|
||||||
|
(set! undocumented-entries
|
||||||
|
(cons entry-summary undocumented-entries)))))
|
||||||
|
entries)
|
||||||
|
|
||||||
|
(if (and (not (null? documented-entries))
|
||||||
|
(or (> (length documented-entries) 1)
|
||||||
|
(not (null? undocumented-entries))))
|
||||||
(begin
|
(begin
|
||||||
(if (not first?)
|
(display "Documentation found for:\n")
|
||||||
(display "\nNo documentation found for:\n"))
|
(for-each (lambda (entry) (display entry)) documented-entries)
|
||||||
(for-each (lambda (entry)
|
(set! first? #f)))
|
||||||
(if (not (doc entry))
|
|
||||||
(simple-format #t "~S: ~S\n"
|
(for-each (lambda (entry)
|
||||||
(module-name (module entry))
|
(if first?
|
||||||
(name entry))))
|
(set! first? #f)
|
||||||
entries)))))))
|
(newline))
|
||||||
|
(display entry))
|
||||||
|
documentations)
|
||||||
|
|
||||||
|
(if (not (null? undocumented-entries))
|
||||||
|
(begin
|
||||||
|
(if first?
|
||||||
|
(set! first? #f)
|
||||||
|
(newline))
|
||||||
|
(display "No documentation found for:\n")
|
||||||
|
(for-each (lambda (entry) (display entry)) undocumented-entries)))))))
|
||||||
|
|
||||||
(define (help-usage)
|
(define (help-usage)
|
||||||
(display "Usage: (help NAME) gives documentation about objects named NAME (a symbol)
|
(display "Usage: (help NAME) gives documentation about objects named NAME (a symbol)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue