Adds a #:part option to `chunk', to control how it's displayed.
svn: r13654 original commit: 6c7a0aae5168005ffcd2dbbed22e79cdb64e5ffd
This commit is contained in:
parent
e581f8ceb7
commit
db690297b7
|
@ -13,10 +13,15 @@
|
||||||
;; of the same name
|
;; of the same name
|
||||||
(define chunk-number (make-free-identifier-mapping)))
|
(define chunk-number (make-free-identifier-mapping)))
|
||||||
|
|
||||||
;; define `chunk' as a macro that typesets the code
|
;; This is the doc-view implementation of `chunk', see "literate-lang.ss" for
|
||||||
|
;; the cide-view implementation. Defines `chunk' as a macro that typesets the
|
||||||
|
;; contained code.
|
||||||
(define-syntax (chunk stx)
|
(define-syntax (chunk stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ name expr ...)
|
[(_ #:part #f name expr ...)
|
||||||
|
#'(make-splice (list (bold (scheme name) " ::=")
|
||||||
|
(schemeblock expr ...)))]
|
||||||
|
[(_ #:part part-function name expr ...)
|
||||||
(let ([n (add1 (free-identifier-mapping-get
|
(let ([n (add1 (free-identifier-mapping-get
|
||||||
chunk-number #'name (lambda () 0)))])
|
chunk-number #'name (lambda () 0)))])
|
||||||
(free-identifier-mapping-put! chunk-number #'name n)
|
(free-identifier-mapping-put! chunk-number #'name n)
|
||||||
|
@ -25,8 +30,9 @@
|
||||||
[(more ...) (if (n . > . 1)
|
[(more ...) (if (n . > . 1)
|
||||||
#`((subscript #,(format "~a" n)))
|
#`((subscript #,(format "~a" n)))
|
||||||
#`())])
|
#`())])
|
||||||
#'(make-splice (list (subsection #:tag tag (scheme name) more ...)
|
#'(make-splice (list (part-function #:tag tag (scheme name) more ...)
|
||||||
(schemeblock expr ...)))))]))
|
(schemeblock expr ...)))))]
|
||||||
|
[(_ name expr ...) #'(chunk #:part subsection name expr ...)]))
|
||||||
|
|
||||||
;; HACK: provide a fake `module', which makes it possible to include a module
|
;; HACK: provide a fake `module', which makes it possible to include a module
|
||||||
;; and get only its code in.
|
;; and get only its code in.
|
||||||
|
|
|
@ -25,8 +25,14 @@
|
||||||
chunks id
|
chunks id
|
||||||
`(,@(mapping-get chunks id) ,@(map syntax-local-introduce exprs)))))
|
`(,@(mapping-get chunks id) ,@(map syntax-local-introduce exprs)))))
|
||||||
|
|
||||||
|
;; This is the code-view implementation of `chunk', see
|
||||||
|
;; "literate-doc-wrapper.ss" for the doc-view implementation. Defines
|
||||||
|
;; `chunk' as a macro that collects the code to be later reassembled
|
||||||
|
;; by `tangle'.
|
||||||
(define-syntax (chunk stx)
|
(define-syntax (chunk stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
|
;; no use for the part function here
|
||||||
|
[(_ #:part part-function name expr ...) (chunk name expr ...)]
|
||||||
[(_ name expr ...)
|
[(_ name expr ...)
|
||||||
(cond [(not (identifier? #'name))
|
(cond [(not (identifier? #'name))
|
||||||
(raise-syntax-error #f "expected a chunk name" stx #'name)]
|
(raise-syntax-error #f "expected a chunk name" stx #'name)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user