commit db690297b78766cc4c3ef1cadee66cde9e153dee
parent e581f8ceb7d994b869b23a457c9cf31eaba6a81c
Author: Eli Barzilay <eli@racket-lang.org>
Date: Mon, 16 Feb 2009 06:30:41 +0000
Adds a #:part option to `chunk', to control how it's displayed.
svn: r13654
original commit: 6c7a0aae5168005ffcd2dbbed22e79cdb64e5ffd
Diffstat:
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/collects/games/chat-noir/literate-doc-wrapper.ss b/collects/games/chat-noir/literate-doc-wrapper.ss
@@ -13,10 +13,15 @@
;; of the same name
(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)
(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
chunk-number #'name (lambda () 0)))])
(free-identifier-mapping-put! chunk-number #'name n)
@@ -25,8 +30,9 @@
[(more ...) (if (n . > . 1)
#`((subscript #,(format "~a" n)))
#`())])
- #'(make-splice (list (subsection #:tag tag (scheme name) more ...)
- (schemeblock expr ...)))))]))
+ #'(make-splice (list (part-function #:tag tag (scheme name) more ...)
+ (schemeblock expr ...)))))]
+ [(_ name expr ...) #'(chunk #:part subsection name expr ...)]))
;; HACK: provide a fake `module', which makes it possible to include a module
;; and get only its code in.
diff --git a/collects/games/chat-noir/literate-lang.ss b/collects/games/chat-noir/literate-lang.ss
@@ -25,8 +25,14 @@
chunks id
`(,@(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)
(syntax-case stx ()
+ ;; no use for the part function here
+ [(_ #:part part-function name expr ...) (chunk name expr ...)]
[(_ name expr ...)
(cond [(not (identifier? #'name))
(raise-syntax-error #f "expected a chunk name" stx #'name)]