Auto-importing the module being documented with chibi-doc.

Keeping environment separate from the interaction-environment.
This commit is contained in:
Alex Shinn 2012-11-12 22:47:45 +09:00
parent 89dc912444
commit b6ba47c2e3
2 changed files with 11 additions and 7 deletions

View file

@ -141,7 +141,7 @@
;;> if the value isn't a pair. ;;> if the value isn't a pair.
;;> @example{(match '(1 . 2) ((= car x) x))} ;;> @example{(match '(1 . 2) ((= car x) x))}
;;> @example{(match 4 ((= sqrt x) x))} ;;> @example{(match 4 ((= square x) x))}
;;> The record operator @scheme{$} is used as a concise way to match ;;> The record operator @scheme{$} is used as a concise way to match
;;> records defined by SRFI-9 (or SRFI-99). The usage is ;;> records defined by SRFI-9 (or SRFI-99). The usage is

View file

@ -3,7 +3,7 @@
(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 scribble) (chibi highlight)
(chibi type-inference)) (chibi type-inference) (scheme eval))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -103,7 +103,7 @@
(else (set-car! env (cons (cons name value) (car env)))))) (else (set-car! env (cons (cons name value) (car env))))))
(define (env-extend env vars vals) (define (env-extend env vars vals)
(append (map cons vars vals) env)) (list (append (map cons vars vals) (car env))))
(define (make-default-env) (define (make-default-env)
`(((section . ,(expand-section 'h1)) `(((section . ,(expand-section 'h1))
@ -630,9 +630,10 @@ div#footer {padding-bottom: 50px}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (output doc) (define (output doc . o)
(sxml-display-as-html (let ((env (if (pair? o) (car o) (make-default-env))))
(fix-header (fix-paragraphs (fix-begins (expand doc (make-default-env))))))) (sxml-display-as-html
(fix-header (fix-paragraphs (fix-begins (expand doc env)))))))
(define (convert in) (define (convert in)
(output (scribble-parse in))) (output (scribble-parse in)))
@ -664,7 +665,10 @@ div#footer {padding-bottom: 50px}
,@(reverse (append-map (lambda (x) (extract-docs x defs exports)) ,@(reverse (append-map (lambda (x) (extract-docs x defs exports))
(module-includes mod))) (module-includes mod)))
,@(reverse (append-map (lambda (x) (extract-docs x defs exports 'ffi)) ,@(reverse (append-map (lambda (x) (extract-docs x defs exports 'ffi))
(module-shared-includes mod))))))) (module-shared-includes mod))))
(env-extend (make-default-env)
'(example-env)
(list (environment '(scheme base) mod-name))))))
(let ((args (command-line))) (let ((args (command-line)))
(case (length args) (case (length args)