From afad5af4867280f1eed8a474d797847e1becf746 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Wed, 9 Jul 2008 02:28:20 +0000 Subject: [PATCH] * Added a `teachpack' function to do teachpack titles * Made it add "foo teachpack" as an index entry svn: r10687 --- .../htdp/scribblings/arrow-gui.scrbl | 8 +-- .../teachpack/htdp/scribblings/arrow.scrbl | 6 +-- .../teachpack/htdp/scribblings/convert.scrbl | 8 +-- collects/teachpack/htdp/scribblings/dir.scrbl | 6 +-- .../teachpack/htdp/scribblings/docs.scrbl | 6 +-- .../teachpack/htdp/scribblings/draw.scrbl | 47 +++++++++------- .../teachpack/htdp/scribblings/elevator.scrbl | 6 +-- .../teachpack/htdp/scribblings/graphing.scrbl | 6 +-- .../teachpack/htdp/scribblings/guess.scrbl | 10 ++-- collects/teachpack/htdp/scribblings/gui.scrbl | 8 +-- .../teachpack/htdp/scribblings/hangman.scrbl | 8 +-- .../teachpack/htdp/scribblings/image.scrbl | 54 +++++++++---------- .../teachpack/htdp/scribblings/master.scrbl | 8 +-- collects/teachpack/htdp/scribblings/shared.ss | 10 ++++ .../htdp/scribblings/show-queen.scrbl | 8 +-- .../teachpack/htdp/scribblings/world.scrbl | 42 ++++++++------- 16 files changed, 130 insertions(+), 111 deletions(-) create mode 100644 collects/teachpack/htdp/scribblings/shared.ss diff --git a/collects/teachpack/htdp/scribblings/arrow-gui.scrbl b/collects/teachpack/htdp/scribblings/arrow-gui.scrbl index d80d71c3a5..f2e1ac4739 100644 --- a/collects/teachpack/htdp/scribblings/arrow-gui.scrbl +++ b/collects/teachpack/htdp/scribblings/arrow-gui.scrbl @@ -1,17 +1,17 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/arrow-gui)) + teachpack/htdp/arrow-gui)) -@title[#:tag "arrow-gui"]{An Arrow GUI: arrow-gui.ss} +@teachpack["arrow-gui"]{An Arrow GUI} @declare-exporting[teachpack/htdp/arrow-gui] The teachpack provides operations for creating and manipulating an arrow GUI. We recommend using the @seclink["world"]{world teachpack} instead. -@deftech{modelT} @scheme[(-> button% event% true)] +@deftech{modelT} @scheme[(-> button% event% true)] A @tech{modelT} is a function that accepts and ignores two arguments. diff --git a/collects/teachpack/htdp/scribblings/arrow.scrbl b/collects/teachpack/htdp/scribblings/arrow.scrbl index 56e5d4674b..6f2ceb102b 100644 --- a/collects/teachpack/htdp/scribblings/arrow.scrbl +++ b/collects/teachpack/htdp/scribblings/arrow.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/arrow)) + teachpack/htdp/arrow)) -@title[#:tag "arrow"]{Managing Control Arrows: arrow.ss} +@teachpack["arrow"]{Managing Control Arrows} @declare-exporting[teachpack/htdp/arrow] diff --git a/collects/teachpack/htdp/scribblings/convert.scrbl b/collects/teachpack/htdp/scribblings/convert.scrbl index 8ccd4ba6ed..123dd2e2e0 100644 --- a/collects/teachpack/htdp/scribblings/convert.scrbl +++ b/collects/teachpack/htdp/scribblings/convert.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual - (for-label scheme - teachpack/htdp/convert)) +@(require scribble/manual "shared.ss" + (for-label scheme + teachpack/htdp/convert)) -@title[#:tag "convert"]{Converting Temperatures: convert.ss} +@teachpack["convert"]{Converting Temperatures} @declare-exporting[teachpack/htdp/convert] diff --git a/collects/teachpack/htdp/scribblings/dir.scrbl b/collects/teachpack/htdp/scribblings/dir.scrbl index 172444c581..095434a659 100644 --- a/collects/teachpack/htdp/scribblings/dir.scrbl +++ b/collects/teachpack/htdp/scribblings/dir.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label (except-in scheme/base file-size) - teachpack/htdp/dir)) + teachpack/htdp/dir)) -@title[#:tag "dir"]{Working with Files and Directories: dir.ss} +@teachpack["dir"]{Working with Files and Directories} @declare-exporting[teachpack/htdp/dir] diff --git a/collects/teachpack/htdp/scribblings/docs.scrbl b/collects/teachpack/htdp/scribblings/docs.scrbl index 52d979bbbf..a992d7d12c 100644 --- a/collects/teachpack/htdp/scribblings/docs.scrbl +++ b/collects/teachpack/htdp/scribblings/docs.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/docs)) + teachpack/htdp/docs)) -@title[#:tag "docs"]{Manipulating Simple HTML Documents: docs.ss} +@teachpack["docs"]{Manipulating Simple HTML Documents} @declare-exporting[teachpack/htdp/docs] diff --git a/collects/teachpack/htdp/scribblings/draw.scrbl b/collects/teachpack/htdp/scribblings/draw.scrbl index 428b791f2e..1034779563 100644 --- a/collects/teachpack/htdp/scribblings/draw.scrbl +++ b/collects/teachpack/htdp/scribblings/draw.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/draw)) + teachpack/htdp/draw)) -@title[#:tag "draw"]{Simple Drawing: draw.ss} +@teachpack["draw"]{Simple Drawing} @declare-exporting[teachpack/htdp/draw] @@ -26,29 +26,36 @@ a color, it raises an error. @scheme[width] x @scheme[height] canvas.} @defproc[(start/cartesian-plane [width number?][height number?]) -true]{Opens a @scheme[width] x @scheme[height] canvas and draws a Cartesian -plane.} + true]{ +Opens a @scheme[width] x @scheme[height] canvas and draws a Cartesian +plane.} @defproc[(stop) true]{Closes the canvas.} -@defproc[(draw-circle [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) true]{Draws a -@scheme[c] circle at @scheme[p] with radius @scheme[r].} +@defproc[(draw-circle [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) + true]{ +Draws a @scheme[c] circle at @scheme[p] with radius @scheme[r].} -@defproc[(draw-solid-disk [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) true]{Draws a -@scheme[c] disk at @scheme[p] with radius @scheme[r].} +@defproc[(draw-solid-disk [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) + true]{ +Draws a @scheme[c] disk at @scheme[p] with radius @scheme[r].} -@defproc[(draw-solid-rect [ul posn?] [width number?] [height number?] [c -(unsyntax @tech{DrawColor})]) true]{Draws a @scheme[width] x @scheme[height], @scheme[c] -rectangle with the upper-left corner at @scheme[ul].} +@defproc[(draw-solid-rect [ul posn?] [width number?] [height number?] + [c (unsyntax @tech{DrawColor})]) + true]{ +Draws a @scheme[width] x @scheme[height], @scheme[c] rectangle with the +upper-left corner at @scheme[ul].} -@defproc[(draw-solid-line [strt posn?] [end posn?] [c (unsyntax @tech{DrawColor})]) true]{Draws -a @scheme[c] line from @scheme[strt] to @scheme[end].} +@defproc[(draw-solid-line [strt posn?] [end posn?] + [c (unsyntax @tech{DrawColor})]) + true]{ +Draws a @scheme[c] line from @scheme[strt] to @scheme[end].} -@defproc[(draw-solid-string [p posn?][s string?]) true]{Draws @scheme[s] at -@scheme[p].} +@defproc[(draw-solid-string [p posn?] [s string?]) true]{ +Draws @scheme[s] at @scheme[p].} -@defproc[(sleep-for-a-while [s number?]) true]{Suspends evaluation for -@scheme[s] seconds.} +@defproc[(sleep-for-a-while [s number?]) true]{ +Suspends evaluation for @scheme[s] seconds.} The teachpack also provides @scheme[clear-] operations for each @scheme[draw-] operation. The arguments are the same. Note: use @@ -58,8 +65,8 @@ The color argument for all @scheme[clear-] functions are optional. @;----------------------------------------------------------------------------- @section[#:tag "interaction"]{Interactions with Canvas} -@defproc[(wait-for-mouse-click) posn?]{Waits for the user to click on the -mouse, within the canvas.} +@defproc[(wait-for-mouse-click) posn?]{ +Waits for the user to click on the mouse, within the canvas.} @deftech{DrawKeyEvent}: @scheme[(or/c char? symbol?)] A @tech{DrawKeyEvent} represents keyboard events: diff --git a/collects/teachpack/htdp/scribblings/elevator.scrbl b/collects/teachpack/htdp/scribblings/elevator.scrbl index 3ee614d364..c188d33b42 100644 --- a/collects/teachpack/htdp/scribblings/elevator.scrbl +++ b/collects/teachpack/htdp/scribblings/elevator.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/elevator)) + teachpack/htdp/elevator)) -@title[#:tag "elevator"]{Controlling an Elevator: elevator.ss} +@teachpack["elevator"]{Controlling an Elevator} @declare-exporting[teachpack/htdp/elevator] diff --git a/collects/teachpack/htdp/scribblings/graphing.scrbl b/collects/teachpack/htdp/scribblings/graphing.scrbl index 93112856e8..093a0d2ceb 100644 --- a/collects/teachpack/htdp/scribblings/graphing.scrbl +++ b/collects/teachpack/htdp/scribblings/graphing.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/graphing)) + teachpack/htdp/graphing)) -@title[#:tag "graphing"]{Graphing Functions: graphing.ss} +@teachpack["graphing"]{Graphing Functions} @declare-exporting[teachpack/htdp/graphing] diff --git a/collects/teachpack/htdp/scribblings/guess.scrbl b/collects/teachpack/htdp/scribblings/guess.scrbl index 67a1361d12..e21bbff722 100644 --- a/collects/teachpack/htdp/scribblings/guess.scrbl +++ b/collects/teachpack/htdp/scribblings/guess.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual - (for-label scheme - teachpack/htdp/guess)) +@(require scribble/manual "shared.ss" + (for-label scheme + teachpack/htdp/guess)) -@title[#:tag "guess"]{Guessing Numbers: guess.ss} +@teachpack["guess"]{Guessing Numbers} @declare-exporting[teachpack/htdp/guess] @@ -19,7 +19,7 @@ is the user's guess, and @scheme[target], which is the randomly chosen number-to-be-guessed. The result is a symbol that reflects the relationship of the player's guess to the target.} -@defproc[(guess-with-gui-3 [check-guess (-> digit? digit? digit? number? symbol?)]) true]{ +@defproc[(guess-with-gui-3 [check-guess (-> digit? digit? digit? number? symbol?)]) true]{ The @scheme[check-guess] function consumes three digits (@scheme[digit0], @scheme[digit1], @scheme[digit2]) and one number (@scheme[target]). The latter is the randomly chosen number-to-be-guessed; the three digits are diff --git a/collects/teachpack/htdp/scribblings/gui.scrbl b/collects/teachpack/htdp/scribblings/gui.scrbl index 4506eb10da..c0ed6b0148 100644 --- a/collects/teachpack/htdp/scribblings/gui.scrbl +++ b/collects/teachpack/htdp/scribblings/gui.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual - (for-label scheme - teachpack/htdp/gui)) +@(require scribble/manual "shared.ss" + (for-label scheme + teachpack/htdp/gui)) -@title[#:tag "gui"]{Simple Graphical User Interfaces: gui.ss} +@teachpack["gui"]{Simple Graphical User Interfaces} @declare-exporting[teachpack/htdp/gui] diff --git a/collects/teachpack/htdp/scribblings/hangman.scrbl b/collects/teachpack/htdp/scribblings/hangman.scrbl index 034c13da37..2b5aa85ec8 100644 --- a/collects/teachpack/htdp/scribblings/hangman.scrbl +++ b/collects/teachpack/htdp/scribblings/hangman.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual - (for-label scheme - teachpack/htdp/hangman)) +@(require scribble/manual "shared.ss" + (for-label scheme + teachpack/htdp/hangman)) -@title[#:tag "hangman"]{Hangman : hangman.ss} +@teachpack["hangman"]{Hangman} @declare-exporting[teachpack/htdp/hangman] diff --git a/collects/teachpack/htdp/scribblings/image.scrbl b/collects/teachpack/htdp/scribblings/image.scrbl index b60ddbf126..2569a0b164 100644 --- a/collects/teachpack/htdp/scribblings/image.scrbl +++ b/collects/teachpack/htdp/scribblings/image.scrbl @@ -1,11 +1,11 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/image - lang/private/imageeq)) + teachpack/htdp/image + lang/private/imageeq)) -@title[#:tag "image"]{Manipulating Images: image.ss} +@teachpack["image"]{Manipulating Images} @declare-exporting[teachpack/htdp/image] @@ -30,8 +30,8 @@ A @tech{Mode} is used to specify whether painting a shape fills or outlines the form. @defstruct[color [(red (and/c natural-number/c (<=/c 255))) - (green (and/c natural-number/c (<=/c 255))) - (blue (and/c natural-number/c (<=/c 255)))]] + (green (and/c natural-number/c (<=/c 255))) + (blue (and/c natural-number/c (<=/c 255)))]] @deftech{RGB} @scheme[color?] @@ -71,10 +71,10 @@ shapes with the following functions. @scheme[m] and painted in color @scheme[c]} @defproc[(star [n (and/c number? (>=/c 2))] - [outer (and/c number? (>=/c 1))] - [inner (and/c number? (>=/c 1))] - [m (unsyntax @tech{Mode})] - [c (unsyntax @tech{Color})]) image?]{ + [outer (and/c number? (>=/c 1))] + [inner (and/c number? (>=/c 1))] + [m (unsyntax @tech{Mode})] + [c (unsyntax @tech{Color})]) image?]{ Creates a multi-pointed star with @scheme[n] points, an @scheme[outer] radius for the max distance of the points to the center, and an @scheme[inner] radius for the min distance to the center. } @@ -137,11 +137,11 @@ find out where the pinhole is and place it where convenient. Images can be composed, and images can be found within compositions. @defproc[(add-line [i image?] - [x number?] - [y number?] - [z number?] - [u number?] - [c (unsyntax @tech{Color})]) image?]{ + [x number?] + [y number?] + [z number?] + [u number?] + [c (unsyntax @tech{Color})]) image?]{ Creates an image by adding a line (colored @scheme[c]) from @scheme[(x,y)] to @scheme[(z,u)] to image @scheme[i].} @@ -238,10 +238,10 @@ and converts a list of colors into an image. Converts an image to a list of colors.} @defproc[(color-list->image [l List-of-color] - [width natural-number/c] - [height natural-number/c] - [x natural-number/c] - [y natural-number/c]) image?]{ + [width natural-number/c] + [height natural-number/c] + [x natural-number/c] + [y natural-number/c]) image?]{ Converts a list of colors @scheme[l] to an image with the given @scheme[width] and @scheme[height] and pinhole (@scheme[x],@scheme[y]) coordinates, specified with respect to the top-left of the image.} @@ -252,20 +252,20 @@ indicates fully transparent. @defstruct[alpha-color [(alpha (and/c natural-number/c (<=/c 255))) - (red (and/c natural-number/c (<=/c 255))) - (green (and/c natural-number/c (<=/c 255))) - (blue (and/c natural-number/c (<=/c 255)))]]{ + (red (and/c natural-number/c (<=/c 255))) + (green (and/c natural-number/c (<=/c 255))) + (blue (and/c natural-number/c (<=/c 255)))]]{ A structure representing an alpha color.} @defproc[(image->alpha-color-list [img image?]) (list-of alpha-color?)]{ to convert an image to a list of alpha colors} @defproc[(alpha-color-list->image - [l (list-of alpha-color?)] - [width integer?] - [height integer?] - [x integer?] - [y integer?]) image? ]{ + [l (list-of alpha-color?)] + [width integer?] + [height integer?] + [x integer?] + [y integer?]) image?]{ Converts a list of @scheme[alpha-color]s @scheme[l] to an image with the given @scheme[width] and @scheme[height] and pinhole (@scheme[x],@scheme[y]) coordinates, specified with respect to the top-left of the image.} diff --git a/collects/teachpack/htdp/scribblings/master.scrbl b/collects/teachpack/htdp/scribblings/master.scrbl index 8d7f5a5d52..4a67dceeef 100644 --- a/collects/teachpack/htdp/scribblings/master.scrbl +++ b/collects/teachpack/htdp/scribblings/master.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual - (for-label scheme - teachpack/htdp/master)) +@(require scribble/manual "shared.ss" + (for-label scheme + teachpack/htdp/master)) -@title[#:tag "master"]{MasterMinding : master.ss} +@teachpack["master"]{MasterMinding} @declare-exporting[teachpack/htdp/master] diff --git a/collects/teachpack/htdp/scribblings/shared.ss b/collects/teachpack/htdp/scribblings/shared.ss new file mode 100644 index 0000000000..8bdc62c027 --- /dev/null +++ b/collects/teachpack/htdp/scribblings/shared.ss @@ -0,0 +1,10 @@ +#lang scheme/base + +(require scribble/manual) + +(provide teachpack) + +(define (teachpack tp . name) + (apply title #:tag tp + `(,@name ": " ,(filepath (format "~a.ss" tp)) + ,(index (format "~a teachpack" tp))))) diff --git a/collects/teachpack/htdp/scribblings/show-queen.scrbl b/collects/teachpack/htdp/scribblings/show-queen.scrbl index b0d9a88a02..c6ef0f7314 100644 --- a/collects/teachpack/htdp/scribblings/show-queen.scrbl +++ b/collects/teachpack/htdp/scribblings/show-queen.scrbl @@ -1,10 +1,10 @@ #lang scribble/doc -@(require scribble/manual - (for-label scheme - teachpack/htdp/show-queen)) +@(require scribble/manual "shared.ss" + (for-label scheme + teachpack/htdp/show-queen)) -@title[#:tag "show-queen"]{8 Queens: show-queen.ss} +@teachpack["show-queen"]{Queens} @declare-exporting[teachpack/htdp/show-queen] diff --git a/collects/teachpack/htdp/scribblings/world.scrbl b/collects/teachpack/htdp/scribblings/world.scrbl index 82944b94f5..35730d6d27 100644 --- a/collects/teachpack/htdp/scribblings/world.scrbl +++ b/collects/teachpack/htdp/scribblings/world.scrbl @@ -1,12 +1,12 @@ #lang scribble/doc -@(require scribble/manual +@(require scribble/manual "shared.ss" (for-label scheme - teachpack/htdp/image - teachpack/htdp/world - lang/private/imageeq)) + teachpack/htdp/image + teachpack/htdp/world + lang/private/imageeq)) -@title[#:tag "world"]{Simulations and Animations: world.ss} +@teachpack["world"]{Simulations and Animations} The teachpack provides two sets of tools. The first allows students to @@ -20,20 +20,22 @@ second one generalizes the first by adding interactive GUI features. The teachpack assumes working knowledge of the basic image manipulation primitives and introduces a special kind of image: a scene. -@deftech{Scene}@schemeblock[(and/c image? - (lambda (i) - (and (= (pinhole-x i) 0) (= (pinhole-y i) 0))))] +@deftech{Scene}@; +@schemeblock[(and/c image? + (lambda (i) + (and (= (pinhole-x i) 0) (= (pinhole-y i) 0))))] The teachpack can display only @tech{Scene}s, which are images whose pinholes are at position @scheme[(0,0)]. @defproc[(empty-scene [width natural-number/c] - [height natural-number/c]) - (unsyntax @tech{Scene})] -{Creates a @scheme[width] x @scheme[height] @tech{Scene}.} + [height natural-number/c]) + (unsyntax @tech{Scene})] +{Creates a @scheme[width] x @scheme[height] @tech{Scene}.} -@defproc[(place-image [img image?] [x number?][y number?] - [s (unsyntax @tech{Scene})]) (unsyntax @tech{Scene})] +@defproc[(place-image [img image?] [x number?] [y number?] + [s (unsyntax @tech{Scene})]) + (unsyntax @tech{Scene})] {Creates a scene by placing @scheme[img] at @scheme[(x,y)] into @scheme[s]; @scheme[(x,y)] are comp. graph. coordinates, i.e., they count right and down from the upper-left corner.} @@ -41,12 +43,12 @@ pinholes are at position @scheme[(0,0)]. @section[#:tag "simulations"]{Simple Simulations} @defproc[(run-simulation - [w natural-number/c] - [h natural-number/c] - [r number?] - [create-image (-> natural-number/c scene)] - [gifs? boolean? #f]) - true]{ + [w natural-number/c] + [h natural-number/c] + [r number?] + [create-image (-> natural-number/c scene)] + [gifs? boolean? #f]) + true]{ creates and shows a canvas of width @scheme[w] and height @scheme[h] , starts a clock, making it tick every @scheme[r] (usually fractional) seconds. Every time the clock ticks, drscheme applies @scheme[create-image] to @@ -61,7 +63,7 @@ pinholes are at position @scheme[(0,0)]. for describing students work. } -In addition, +In addition, @schemeblock[ (define (create-UFO-scene height) (place-image UFO 50 height (empty-scene 100 100)))