commit 43168b31dda33b18b7d1ec8fbda93c380a405bc3
parent 194dfd7362099a009a07585ae463321a6b3e2e0d
Author: Robby Findler <robby@racket-lang.org>
Date: Sat, 21 Feb 2009 03:16:11 +0000
moved the newly literate program scribbled docs for the chat noir into the actual docs for the games collection
svn: r13761
original commit: 7cc03cb42fff7ec2281e448bec8122f27a22e74e
Diffstat:
2 files changed, 55 insertions(+), 57 deletions(-)
diff --git a/collects/games/chat-noir/literate-doc-wrapper.ss b/collects/games/chat-noir/literate-doc-wrapper.ss
@@ -1,57 +0,0 @@
-#lang scheme/base
-
-;; 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 chunkref
- (all-from-out scribble/manual))
-
-(require scribble/manual scribble/decode scribble/struct 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-numbers (make-free-identifier-mapping))
- (define (get-chunk-number id)
- (let ([n (add1 (free-identifier-mapping-get chunk-numbers id
- (lambda () 0)))])
- (free-identifier-mapping-put! chunk-numbers id n)
- n)))
-
-;; 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 ...)
- ;; no need for more error checking, using chunk for the code will do that
- (identifier? #'name)
- (let ([n (get-chunk-number #'name)]
- [str (symbol->string (syntax-e #'name))])
- (with-syntax ([tag (if (n . > . 1) (format "~a:~a" str n) str)]
- [(more ...) (if (n . > . 1)
- #`((subscript (smaller #,(format "~a" n))))
- #`())]
- [str str])
- #`(make-splice
- (list (make-toc-element
- #f
- (list (elemtag '(chunk tag)
- (bold (italic (scheme name)) " ::=")))
- (list (smaller (elemref '(chunk tag) #:underline? #f
- str more ...))))
- (schemeblock expr ...)))))]))
-
-(define-syntax (chunkref stx)
- (syntax-case stx ()
- [(_ id)
- (identifier? #'id)
- (with-syntax ([str (format "~a" (syntax-e #'id))])
- #'(elemref '(chunk str) #:underline? #f str))]))
-
-;; HACK: provide a fake `module', which makes it possible to include a module
-;; and get only its code in.
-(provide module)
-(define-syntax-rule (module name base body ...)
- (begin body ...))
diff --git a/collects/scribble/lp-include.ss b/collects/scribble/lp-include.ss
@@ -0,0 +1,55 @@
+#lang scheme/base
+
+;; Use this module to create literate doc wrappers -- files that require the
+;; literate code in a way that makes it a scribble file.
+
+(provide chunk (all-from-out scribble/manual))
+
+(require scribble/manual scribble/decode scribble/struct
+ scribble/scheme
+ (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-numbers (make-free-identifier-mapping))
+ (define (get-chunk-number id)
+ (let ([n (add1 (free-identifier-mapping-get chunk-numbers id
+ (lambda () 0)))])
+ (free-identifier-mapping-put! chunk-numbers id n)
+ n)))
+
+;; 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 ...)
+ ;; no need for more error checking, using chunk for the code will do that
+ (identifier? #'name)
+ (let ([n (get-chunk-number #'name)]
+ [str (symbol->string (syntax-e #'name))])
+ (if (n . > . 1)
+ #'(void)
+ (with-syntax ([tag str]
+ [str str])
+ #`(begin
+ ;; ---- This is the new part --------
+ (define-syntax name (make-element-id-transformer
+ (lambda (stx) #'(chunkref name))))
+ ;; ----------------------------------
+ (make-splice
+ (list (make-toc-element
+ #f
+ (list (elemtag '(chunk tag)
+ (bold (italic (scheme name)) " ::=")))
+ (list (smaller (elemref '(chunk tag) #:underline? #f
+ str))))
+ (schemeblock expr ...)))))))]))
+
+(define-syntax (chunkref stx)
+ (syntax-case stx ()
+ [(_ id)
+ (identifier? #'id)
+ (with-syntax ([str (format "~a" (syntax-e #'id))])
+ #'(elemref '(chunk str) #:underline? #f str))]))