mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
Better error message for mistaken usage of chibi-doc.
Fixes issue #177.
This commit is contained in:
parent
9ed486dbe3
commit
6659baa6b6
1 changed files with 18 additions and 8 deletions
|
@ -2,11 +2,17 @@
|
||||||
|
|
||||||
(import
|
(import
|
||||||
(chibi) (srfi 1) (chibi modules) (chibi ast) (chibi io) (chibi match)
|
(chibi) (srfi 1) (chibi modules) (chibi ast) (chibi io) (chibi match)
|
||||||
(chibi time) (chibi filesystem) (chibi scribble) (chibi highlight)
|
(chibi time) (chibi filesystem) (chibi process)
|
||||||
|
(chibi scribble) (chibi highlight)
|
||||||
(chibi type-inference) (scheme eval))
|
(chibi type-inference) (scheme eval))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(define (die . args)
|
||||||
|
(for-each display args)
|
||||||
|
(newline)
|
||||||
|
(exit 1))
|
||||||
|
|
||||||
(define (write-to-string x)
|
(define (write-to-string x)
|
||||||
(call-with-output-string (lambda (out) (write x out))))
|
(call-with-output-string (lambda (out) (write x out))))
|
||||||
|
|
||||||
|
@ -665,12 +671,11 @@ div#footer {padding-bottom: 50px}
|
||||||
((macro? x) (macro-source x))
|
((macro? x) (macro-source x))
|
||||||
(else #f)))
|
(else #f)))
|
||||||
|
|
||||||
(define (extract mod-name)
|
(define (extract mod-name mod)
|
||||||
(let* ((mod (load-module mod-name))
|
(let* ((exports (module-exports mod))
|
||||||
(exports (module-exports mod))
|
|
||||||
(defs (map (lambda (x) `(,(car x) ,(cdr x) ,(object-source (cdr x))))
|
(defs (map (lambda (x) `(,(car x) ,(cdr x) ,(object-source (cdr x))))
|
||||||
(filter (lambda (x) (or (procedure? (cdr x)) (macro? (cdr x))))
|
(filter (lambda (x) (or (procedure? (cdr x)) (macro? (cdr x))))
|
||||||
(map (lambda (x) (cons x (module-ref mod-name x)))
|
(map (lambda (x) (cons x (module-ref mod x)))
|
||||||
exports)))))
|
exports)))))
|
||||||
(output
|
(output
|
||||||
`((title ,(write-to-string mod-name))
|
`((title ,(write-to-string mod-name))
|
||||||
|
@ -698,7 +703,12 @@ div#footer {padding-bottom: 50px}
|
||||||
((file-exists? name)
|
((file-exists? name)
|
||||||
(call-with-input-file name convert))
|
(call-with-input-file name convert))
|
||||||
(else
|
(else
|
||||||
(extract (map (lambda (x) (or (string->number x) (string->symbol x)))
|
(let* ((mod-name
|
||||||
(string-split name #\.)))))))
|
(map (lambda (x) (or (string->number x) (string->symbol x)))
|
||||||
|
(string-split name #\.)))
|
||||||
|
(mod (load-module mod-name)))
|
||||||
|
(if mod
|
||||||
|
(extract mod-name mod)
|
||||||
|
(die "ERROR: couldn't find file or module: " name)))))))
|
||||||
(else
|
(else
|
||||||
(error "usage: chibi-doc [<file-or-module-name>]"))))
|
(die "usage: chibi-doc [<file-or-module-name>]"))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue