mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +02:00
(module-name->filename-frag, display-module-commentary): New procs.
(display-commentary): Also handle refs that look like module names.
This commit is contained in:
parent
40f316d0b7
commit
109f654e7f
1 changed files with 27 additions and 4 deletions
|
@ -26,9 +26,11 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; Usage: display-commentary FILE1 FILE2 ...
|
;; Usage: display-commentary REF1 REF2 ...
|
||||||
;;
|
;;
|
||||||
;; Display Commentary section from FILE1, FILE2 and so on.
|
;; Display Commentary section from REF1, REF2 and so on.
|
||||||
|
;; Each REF may be a filename or module name (list of symbols).
|
||||||
|
;; In the latter case, a filename is computed by searching `%load-path'.
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
@ -39,8 +41,29 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
|
||||||
(define (display-commentary-one file)
|
(define (display-commentary-one file)
|
||||||
(format #t "~A commentary:\n~A" file (file-commentary file)))
|
(format #t "~A commentary:\n~A" file (file-commentary file)))
|
||||||
|
|
||||||
(define (display-commentary . files)
|
(define (module-name->filename-frag ls) ; todo: export or move
|
||||||
(for-each display-commentary-one files))
|
(let ((ls (map symbol->string ls)))
|
||||||
|
(let loop ((ls (cdr ls)) (acc (car ls)))
|
||||||
|
(if (null? ls)
|
||||||
|
acc
|
||||||
|
(loop (cdr ls) (string-append acc "/" (car ls)))))))
|
||||||
|
|
||||||
|
(define (display-module-commentary module-name)
|
||||||
|
(cond ((%search-load-path (module-name->filename-frag module-name))
|
||||||
|
=> (lambda (file)
|
||||||
|
(format #t "module ~A\n" module-name)
|
||||||
|
(display-commentary-one file)))))
|
||||||
|
|
||||||
|
(define (display-commentary . refs)
|
||||||
|
(for-each (lambda (ref)
|
||||||
|
(cond ((string? ref)
|
||||||
|
(if (equal? 0 (string-index ref #\())
|
||||||
|
(display-module-commentary
|
||||||
|
(with-input-from-string ref read))
|
||||||
|
(display-commentary-one ref)))
|
||||||
|
((list? ref)
|
||||||
|
(display-module-commentary ref))))
|
||||||
|
refs))
|
||||||
|
|
||||||
(define main display-commentary)
|
(define main display-commentary)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue