From 7cc03cb42fff7ec2281e448bec8122f27a22e74e Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 21 Feb 2009 03:16:11 +0000 Subject: [PATCH] moved the newly literate program scribbled docs for the chat noir into the actual docs for the games collection svn: r13761 --- .../games/{chat-noir => }/3x3-empty-board.png | Bin .../games/{chat-noir => }/7x7-empty-board.png | Bin .../{chat-noir => }/cat-distance-example.png | Bin collects/games/chat-noir/5x5-empty-board.png | Bin 4238 -> 0 bytes collects/games/chat-noir/chat-noir-doc.ss | 7 +- .../games/chat-noir/chat-noir-literate.ss | 8 +- collects/games/scribblings/chat-noir.scrbl | 72 ++---------------- .../lp-include.ss} | 42 +++++----- 8 files changed, 36 insertions(+), 93 deletions(-) rename collects/games/{chat-noir => }/3x3-empty-board.png (100%) rename collects/games/{chat-noir => }/7x7-empty-board.png (100%) rename collects/games/{chat-noir => }/cat-distance-example.png (100%) delete mode 100644 collects/games/chat-noir/5x5-empty-board.png rename collects/{games/chat-noir/literate-doc-wrapper.ss => scribble/lp-include.ss} (55%) diff --git a/collects/games/chat-noir/3x3-empty-board.png b/collects/games/3x3-empty-board.png similarity index 100% rename from collects/games/chat-noir/3x3-empty-board.png rename to collects/games/3x3-empty-board.png diff --git a/collects/games/chat-noir/7x7-empty-board.png b/collects/games/7x7-empty-board.png similarity index 100% rename from collects/games/chat-noir/7x7-empty-board.png rename to collects/games/7x7-empty-board.png diff --git a/collects/games/chat-noir/cat-distance-example.png b/collects/games/cat-distance-example.png similarity index 100% rename from collects/games/chat-noir/cat-distance-example.png rename to collects/games/cat-distance-example.png diff --git a/collects/games/chat-noir/5x5-empty-board.png b/collects/games/chat-noir/5x5-empty-board.png deleted file mode 100644 index 126e4074d8453e927d0f78d9dc5b150991339128..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4238 zcma)9c|4SR`^E@$7!4|>DTBgD7)!=3W1F#$rNl`Q3R$yn$uh<|Wo%3T70&v-R-fbSihy}Qv;k<9Bt>TSC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q>bbLipGq2c*F@ixyq@o$%vKBDUetksYUp1ax)Oz=8y&kcZO9Coi>s#|pgQ zl_5b6JE2(;V8Qc$txf#Sawjt98D;Ehr6}#NT@1y$7<7MD{-c&M*KA|04VgbcNtN6y zi~H7Cd$T(SB?@2m5J5;Wb?2b0N+En9#=;7YSaBSdwYr7+XzmpO{KlUQIXiq=8N*Z} zxVNa}kRaadF@A>Zj1k3d$M!h*cz4d46d(;}ABmk1mIfc6oZdWL)~o->s1fz?*2(3B z9OWAhlUyE_Fzmjg>wlQ#$3+Z=LaicCqmdomotM^*CXvLRMp~3&B$tX(BrFxo%Ukx? Y?iq#&uQB9+zl$6gBTK_tg9|tQ1sII;ZU6uP diff --git a/collects/games/chat-noir/chat-noir-doc.ss b/collects/games/chat-noir/chat-noir-doc.ss index ccbe5ad660..f1d71a3a7d 100644 --- a/collects/games/chat-noir/chat-noir-doc.ss +++ b/collects/games/chat-noir/chat-noir-doc.ss @@ -1,3 +1,8 @@ #lang scribble/doc -@(require "literate-doc-wrapper.ss") +@(require scribble/lp-include scheme/include) +;; HACK: use a fake `module', which makes it possible to include a module +;; and get only its code in. +@(define-syntax-rule (module name base body ...) + (begin body ...)) + @(include "chat-noir-literate.ss") diff --git a/collects/games/chat-noir/chat-noir-literate.ss b/collects/games/chat-noir/chat-noir-literate.ss index 113d9df894..930d24dd3b 100644 --- a/collects/games/chat-noir/chat-noir-literate.ss +++ b/collects/games/chat-noir/chat-noir-literate.ss @@ -10,6 +10,7 @@ mzc chat-noir-doc.ss && rm -rf chat-noir-doc && scribble ++xref-in setup/xref lo } +@;{would like to have [#:style 'toc] in the next line ... } @title{Chat Noir} @author[(link "http://www.eecs.northwestern.edu/~robby" "Robby Findler") @@ -41,7 +42,7 @@ the Chat Noir game in a @section{Overview} Chat Noir is implemented using @link["http://www.htdp.org/"]{HtDP}'s universe -library: @schememodname[teachpack/2htdp/universe] +library: @schememodname[2htdp/universe] (although it only uses the ``world'' portions of that library). The program is divided up into six parts: the world data definition, an implementation of breadth-first search, @@ -64,7 +65,8 @@ and some code that builds an initial world and starts the game. ] Each section also comes with a series of test cases that are collected into the -@chunkref[] chunk at the end of the program. +@scheme[] +chunk at the end of the program. @chunk[ @@ -461,7 +463,7 @@ and returns a @scheme[distance-table]. As you can see, the first thing it does is bind the free variable in @scheme[bfs] to the result of calling the @scheme[neighbors] function (defined in the chunk -@chunkref[]) and then it has the @chunkref[] chunk. In the body +@scheme[]) and then it has the @scheme[] chunk. In the body it calls the @scheme[bfs] function and then transforms the result, using @scheme[hash-map], into a list of @scheme[cell]s. diff --git a/collects/games/scribblings/chat-noir.scrbl b/collects/games/scribblings/chat-noir.scrbl index d5ba2790dc..c3ce04f24c 100644 --- a/collects/games/scribblings/chat-noir.scrbl +++ b/collects/games/scribblings/chat-noir.scrbl @@ -1,69 +1,7 @@ #lang scribble/doc -@(require "common.ss") -@(require scheme/runtime-path (for-syntax scheme/port scheme/base scheme/path)) -@(define-runtime-path cn "../chat-noir/chat-noir.ss") +@(require scribble/lp-include scheme/include) +@;{ HACK: use a fake `module', which makes it possible to include a module and get only its code in.} +@(define-syntax-rule (module name base body ...) + (begin body ...)) -@gametitle["Chat Noir" "chat-noir" "Puzzle Game"] - -The goal of the game is to stop the cat from escaping the board. Each -turn you click on a circle, which prevents the cat from stepping on -that space, and the cat responds by taking a step. If the cat is -completely boxed in and thus unable reach the border, you win. If the -cat does reach the border, you lose. - -To get some insight into the cat's behavior, hold down the ``h'' -key. It will show you the cells that are on the cat's shortest path to -the edge, assuming that the cell underneath the mouse has been -blocked, so you can experiment to see how the shortest paths change -by moving your mouse around. - -The game was inspired by this one the one at -@link["http://www.gamedesign.jp/flash/chatnoir/chatnoir.html"]{Game -Design} and has essentially the same rules. It also inspired the final -project for the introductory programming course at the University of -Chicago in the fall of 2008. - -@;{ - -This is commented out, waiting for the literate programming stuff. - -This game is written in the -@link["http://www.htdp.org/"]{How to Design Programs} -Intermediate language. It is a model solution to the final project for -the introductory programming course at the University of Chicago in -the fall of 2008, as below. - -@(define-syntax (m stx) - (call-with-input-file - (build-path (path-only (syntax-source stx)) - 'up "chat-noir" "chat-noir.ss") - (lambda (port) - (port-count-lines! port) - #`(schemeblock - #,@ - (let loop () - (let* ([p (peeking-input-port port)] - [l (read-line p)]) - (cond - [(eof-object? l) '()] - [(regexp-match #rx"^[ \t]*$" l) - (read-line port) - (loop)] - [(regexp-match #rx"^ *;+" l) - => - (lambda (m) - (let-values ([(line col pos) (port-next-location port)]) - (read-line port) - (let-values ([(line2 col2 pos2) (port-next-location port)]) - (cons (datum->syntax - #f - `(code:comment ,(regexp-replace* #rx" " l "\u00a0")) - (list "chat-noir.ss" line col pos (- pos2 pos))) - (loop)))))] - [else - (cons (read-syntax "chat-noir.ss" port) - (loop))]))))) - #:mode 'text)) - -@m[] -} +@(include "../chat-noir/chat-noir-literate.ss") diff --git a/collects/games/chat-noir/literate-doc-wrapper.ss b/collects/scribble/lp-include.ss similarity index 55% rename from collects/games/chat-noir/literate-doc-wrapper.ss rename to collects/scribble/lp-include.ss index 030b3af629..0dc35fb3b6 100644 --- a/collects/games/chat-noir/literate-doc-wrapper.ss +++ b/collects/scribble/lp-include.ss @@ -3,10 +3,10 @@ ;; 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)) +(provide chunk (all-from-out scribble/manual)) -(require scribble/manual scribble/decode scribble/struct scheme/include +(require scribble/manual scribble/decode scribble/struct + scribble/scheme (for-syntax scheme/base syntax/boundmap)) (begin-for-syntax @@ -29,19 +29,23 @@ (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 ...)))))])) + (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 () @@ -49,9 +53,3 @@ (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 ...))