Reify bytevector? in the correct module
[bpt/guile.git] / module / scripts / display-commentary.scm
CommitLineData
28c31342
TTN
1;;; display-commentary --- As advertized
2
a1a2ed53 3;; Copyright (C) 2001, 2006, 2011 Free Software Foundation, Inc.
28c31342
TTN
4;;
5;; This program is free software; you can redistribute it and/or
83ba2d37
NJ
6;; modify it under the terms of the GNU Lesser General Public License
7;; as published by the Free Software Foundation; either version 3, or
28c31342
TTN
8;; (at your option) any later version.
9;;
10;; This program is distributed in the hope that it will be useful,
11;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
83ba2d37 13;; Lesser General Public License for more details.
28c31342 14;;
83ba2d37
NJ
15;; You should have received a copy of the GNU Lesser General Public
16;; License along with this software; see the file COPYING.LESSER. If
17;; not, write to the Free Software Foundation, Inc., 51 Franklin
18;; Street, Fifth Floor, Boston, MA 02110-1301 USA
28c31342 19
61897afe
TTN
20;;; Author: Thien-Thi Nguyen
21
28c31342
TTN
22;;; Commentary:
23
109f654e 24;; Usage: display-commentary REF1 REF2 ...
28c31342 25;;
109f654e
TTN
26;; Display Commentary section from REF1, REF2 and so on.
27;; Each REF may be a filename or module name (list of symbols).
28;; In the latter case, a filename is computed by searching `%load-path'.
28c31342
TTN
29
30;;; Code:
31
32(define-module (scripts display-commentary)
33 :use-module (ice-9 documentation)
34 :export (display-commentary))
35
a1a2ed53
AW
36(define %summary "Display the Commentary section from a file or module.")
37
28c31342
TTN
38(define (display-commentary-one file)
39 (format #t "~A commentary:\n~A" file (file-commentary file)))
40
109f654e
TTN
41(define (module-name->filename-frag ls) ; todo: export or move
42 (let ((ls (map symbol->string ls)))
43 (let loop ((ls (cdr ls)) (acc (car ls)))
44 (if (null? ls)
45 acc
46 (loop (cdr ls) (string-append acc "/" (car ls)))))))
47
48(define (display-module-commentary module-name)
49 (cond ((%search-load-path (module-name->filename-frag module-name))
50 => (lambda (file)
51 (format #t "module ~A\n" module-name)
52 (display-commentary-one file)))))
53
54(define (display-commentary . refs)
55 (for-each (lambda (ref)
56 (cond ((string? ref)
57 (if (equal? 0 (string-index ref #\())
58 (display-module-commentary
59 (with-input-from-string ref read))
60 (display-commentary-one ref)))
61 ((list? ref)
62 (display-module-commentary ref))))
63 refs))
28c31342
TTN
64
65(define main display-commentary)
66
67;;; display-commentary ends here