guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/scripts display-commentary


From: Thien-Thi Nguyen
Subject: guile/guile-core/scripts display-commentary
Date: Sun, 30 Sep 2001 14:24:10 -0400

CVSROOT:        /cvs
Module name:    guile
Changes by:     Thien-Thi Nguyen <address@hidden>       01/09/30 14:24:10

Modified files:
        guile-core/scripts: display-commentary 

Log message:
        (module-name->filename-frag, display-module-commentary): New procs.
        (display-commentary): Also handle refs that look like module names.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/scripts/display-commentary.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: guile/guile-core/scripts/display-commentary
diff -u guile/guile-core/scripts/display-commentary:1.5 
guile/guile-core/scripts/display-commentary:1.6
--- guile/guile-core/scripts/display-commentary:1.5     Wed Aug  1 01:09:30 2001
+++ guile/guile-core/scripts/display-commentary Sun Sep 30 14:24:10 2001
@@ -26,9 +26,11 @@
 
 ;;; 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:
 
@@ -39,8 +41,29 @@
 (define (display-commentary-one file)
   (format #t "~A commentary:\n~A" file (file-commentary file)))
 
-(define (display-commentary . files)
-  (for-each display-commentary-one files))
+(define (module-name->filename-frag ls) ; todo: export or move
+  (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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]