diff --git a/collects/games/chat-noir/literate-doc-wrapper.ss b/collects/games/chat-noir/literate-doc-wrapper.ss index c10ebe97..85ab4f3e 100644 --- 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 index 73a1df85..aac26b9d 100644 --- 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)]