bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e581f8ceb7d994b869b23a457c9cf31eaba6a81c
parent 0752d0eb5529347ea6c6bd29868b6a558a7160a5
Author: Eli Barzilay <eli@racket-lang.org>
Date:   Mon, 16 Feb 2009 04:33:54 +0000

use a counter to get separate tags and section titles

svn: r13653

original commit: 9d06dd7f579015518ed07994c2c733a3bc74d8bc

Diffstat:
Mcollects/games/chat-noir/literate-doc-wrapper.ss | 28+++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/collects/games/chat-noir/literate-doc-wrapper.ss b/collects/games/chat-noir/literate-doc-wrapper.ss @@ -3,16 +3,30 @@ ;; Use this module to create literate doc wrappers -- files that require the ;; literate code in a way that makes it a scribble file. -(provide include chunk - (all-from-out scribble/manual)) +(provide include chunk (all-from-out scribble/manual)) -(require scribble/manual scribble/decode scheme/include) +(require scribble/manual scribble/decode scheme/include + (for-syntax scheme/base syntax/boundmap)) + +(begin-for-syntax + ;; maps chunk identifiers to a counter, so we can distinguish multiple uses + ;; of the same name + (define chunk-number (make-free-identifier-mapping))) ;; define `chunk' as a macro that typesets the code -(define-syntax-rule (chunk name expr ...) - (make-splice (list (subsection #:tag (format "~a" 'name) - (scheme name)) - (schemeblock expr ...)))) +(define-syntax (chunk stx) + (syntax-case stx () + [(_ name expr ...) + (let ([n (add1 (free-identifier-mapping-get + chunk-number #'name (lambda () 0)))]) + (free-identifier-mapping-put! chunk-number #'name n) + (with-syntax ([tag (format "~a~a" (syntax->datum #'name) + (if (n . > . 1) (format ":~a" n) ""))] + [(more ...) (if (n . > . 1) + #`((subscript #,(format "~a" n))) + #`())]) + #'(make-splice (list (subsection #:tag tag (scheme name) more ...) + (schemeblock expr ...)))))])) ;; HACK: provide a fake `module', which makes it possible to include a module ;; and get only its code in.