addec docs for HtDC teachpacks
svn: r2215
This commit is contained in:
parent
933685e454
commit
2b4921291d
49
teachpack/htdc/Docs/draw.thtml
Normal file
49
teachpack/htdc/Docs/draw.thtml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ (define LIBNAME "A Functional Drawing Library (HtDC)")
|
||||||
|
(include "head.tinc") }
|
||||||
|
|
||||||
|
This `draw' package provides classes and methods for modeling in a visual
|
||||||
|
world. Here is its class diagram of public fields and methods:
|
||||||
|
<pre>
|
||||||
|
<code>
|
||||||
|
+-----------------------------------+
|
||||||
|
| abstract World |
|
||||||
|
+-----------------------------------+ +---------------------------------------+
|
||||||
|
| Canvas theCanvas |------>| Canvas |
|
||||||
|
+-----------------------------------+ +---------------------------------------+
|
||||||
|
| boolean bigBang(int,int,double) | +---------------------------------------+
|
||||||
|
| boolean endOfTime() | | boolean start(int,int) |
|
||||||
|
| boolean endOfWorld() | | boolean stop() |
|
||||||
|
| World lastWorld() | | boolean drawCircle(Posn,int,Color) |
|
||||||
|
| | | boolean drawDisk(Posn,int,Color) |
|
||||||
|
| abstract World onTick() | | boolean drawRect(Posn,int,int,Color) |
|
||||||
|
| abstract World onKeyEvent(String) | | boolean drawLine(Posn,Posn,Color) |
|
||||||
|
| abstract boolean draw() | | boolean drawString(Posn,String) |
|
||||||
|
| abstract boolean erase( | | boolean clearCircle(Posn,int,Color) |
|
||||||
|
+-----------------------------------+ | boolean clearDisk(Posn,int,Color) |
|
||||||
|
| boolean clearRect(Posn,int,int,Color) |
|
||||||
|
| boolean clearLine(Posn,Posn,Color) |
|
||||||
|
+---------------------------------------+
|
||||||
|
|
||||||
|
+----------+
|
||||||
|
| Posn |
|
||||||
|
+----------+
|
||||||
|
| int x |
|
||||||
|
| int y |
|
||||||
|
+----------+
|
||||||
|
|
||||||
|
+-------+
|
||||||
|
| Color |
|
||||||
|
+-------+
|
||||||
|
|
|
||||||
|
/ \
|
||||||
|
---
|
||||||
|
|
|
||||||
|
------------------------------------------
|
||||||
|
| | | | |
|
||||||
|
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||||
|
| Blue | | Green | | Red | | White | | Yellow|
|
||||||
|
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
{(include "foot.tinc")}
|
4
teachpack/htdc/Docs/foot.tinc
Normal file
4
teachpack/htdc/Docs/foot.tinc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
</body>
|
||||||
|
</html>
|
12
teachpack/htdc/Docs/head.tinc
Normal file
12
teachpack/htdc/Docs/head.tinc
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Teachpack : {LIBNAME}</title>
|
||||||
|
</head>
|
||||||
|
<body bgcolor="#ffffff" text="#000000"
|
||||||
|
link="#009900" vlink="#007700" alink="#cc0000">
|
||||||
|
|
||||||
|
<a href="index.html">Teachpacks for How to Design Programs</a>
|
||||||
|
|
||||||
|
<h1>{LIBNAME}</h1>
|
||||||
|
|
||||||
|
<hr> <h3>{(idx ,FILENAME)}</h3> <!-- DOCNOTE="teach={FILENAME}" -->
|
52
teachpack/htdc/Docs/idraw.thtml
Normal file
52
teachpack/htdc/Docs/idraw.thtml
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{ (define LIBNAME "An Imperative Drawing Library (HtDC)")
|
||||||
|
(include "head.tinc") }
|
||||||
|
|
||||||
|
|
||||||
|
This `idraw' package provides classes and imperative methods for modeling
|
||||||
|
in a visual world. Here is its class diagram of public fields and methods:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<code>
|
||||||
|
+---------------------------------+
|
||||||
|
| abstract World |
|
||||||
|
+---------------------------------+ +------------------------------------+
|
||||||
|
| Canvas theCanvas |------>| Canvas |
|
||||||
|
+---------------------------------+ +------------------------------------+
|
||||||
|
| void bigBang(int,int,double) | +------------------------------------+
|
||||||
|
| void endOfTime() | | void start(int,int) |
|
||||||
|
| | | void stop() |
|
||||||
|
| abstract void onTick() | | void drawCircle(Posn,int,Color) |
|
||||||
|
| abstract void onKeyEvent(String)| | void drawDisk(Posn,int,Color) |
|
||||||
|
| abstract void draw() | | void drawRect(Posn,int,int,Color) |
|
||||||
|
| abstract void erase() | | void drawLine(Posn,Posn,Color) |
|
||||||
|
+---------------------------------+ | void drawString(Posn,String) |
|
||||||
|
| void clearCircle(Posn,int,Color) |
|
||||||
|
| void clearDisk(Posn,int,Color) |
|
||||||
|
| void clearRect(Posn,int,int,Color) |
|
||||||
|
| void clearLine(Posn,Posn,Color) |
|
||||||
|
+------------------------------------+
|
||||||
|
|
||||||
|
+----------+
|
||||||
|
| Posn |
|
||||||
|
+----------+
|
||||||
|
| int x |
|
||||||
|
| int y |
|
||||||
|
+----------+
|
||||||
|
|
||||||
|
+-------+
|
||||||
|
| Color |
|
||||||
|
+-------+
|
||||||
|
|
|
||||||
|
/ \
|
||||||
|
---
|
||||||
|
|
|
||||||
|
------------------------------------------
|
||||||
|
| | | | |
|
||||||
|
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||||
|
| Blue | | Green | | Red | | White | | Yellow|
|
||||||
|
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||||
|
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
{(include "foot.tinc")}
|
11
teachpack/htdc/Docs/index.thtml
Normal file
11
teachpack/htdc/Docs/index.thtml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Teachpacks for How to Design Classes</title>
|
||||||
|
</head>
|
||||||
|
<body bgcolor="#ffffff" text="#000000" link="#009900" vlink="#007700" alink="#cc0000">
|
||||||
|
<h1>Teachpacks for "How to Design Classes"</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{ LIBLINKS ; libraries should be set before processing this file }</ul>
|
||||||
|
|
||||||
|
{(include "foot.tinc")}
|
114
teachpack/htdc/Docs/mkdocs
Executable file
114
teachpack/htdc/Docs/mkdocs
Executable file
|
@ -0,0 +1,114 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#|
|
||||||
|
if [ -x "$PLTHOME/bin/mzscheme" ]; then
|
||||||
|
exec "$PLTHOME/bin/mzscheme" -qgr "$0" "$@"
|
||||||
|
else
|
||||||
|
exec "mzscheme" -qgr "$0" "$@"
|
||||||
|
fi
|
||||||
|
|#
|
||||||
|
|
||||||
|
(require (lib "etc.ss") (lib "plthome.ss" "setup"))
|
||||||
|
(current-directory (this-expression-source-directory))
|
||||||
|
|
||||||
|
; for john?
|
||||||
|
|
||||||
|
;; This list determines the order of libraries in the index file:
|
||||||
|
(define libraries*
|
||||||
|
'(#"A Functional Drawing Library (HtDC)"
|
||||||
|
#"An Imperative Drawing Library (HtDC)"
|
||||||
|
))
|
||||||
|
|
||||||
|
(define dest-dir (build-path plthome "collects" "doc" "teachpack-htdc"))
|
||||||
|
(printf "writing docs to ~s\n" (path->string dest-dir))
|
||||||
|
|
||||||
|
(require (lib "list.ss"))
|
||||||
|
|
||||||
|
(define thtml-files
|
||||||
|
(filter (lambda (x) (regexp-match #rx#"[.]thtml$" (path->bytes x)))
|
||||||
|
(directory-list)))
|
||||||
|
|
||||||
|
(unless (directory-exists? dest-dir) (make-directory dest-dir))
|
||||||
|
|
||||||
|
;; Get list of (list name file-basename) for library names
|
||||||
|
;; (assuming that foo.thtml is always the documentation for ../foo.ss)
|
||||||
|
(define lib-names
|
||||||
|
(let ([rx (regexp (string-append "\\(define +LIBNAME +\"(.*?)\"\\)"))])
|
||||||
|
(map (lambda (s)
|
||||||
|
(let* ([m (or (regexp-match rx (open-input-file s))
|
||||||
|
(error 'mkdocs "LIBNAME+FILENAME not found in ~s" s))]
|
||||||
|
[basename (regexp-replace #rx#"[.]thtml$" (path->bytes s) #"")]
|
||||||
|
[ss-name (bytes->path (bytes-append basename #".ss"))])
|
||||||
|
(unless (file-exists? (build-path 'up ss-name))
|
||||||
|
(error 'mkdocs "Found ~s but no ~s teachpack found" s ss-name))
|
||||||
|
(list (cadr m) (bytes->path basename))))
|
||||||
|
(filter (lambda (f) (not (equal? (path->bytes f) #"index.thtml"))) thtml-files))))
|
||||||
|
;; Check that `lib-names' exactly match `libraires':
|
||||||
|
(let ([file-libs (map car lib-names)])
|
||||||
|
(define (test x) (and (pair? x) x))
|
||||||
|
(cond
|
||||||
|
[(test (remove* libraries* lib-names (lambda (x y) (equal? x (car y))))) =>
|
||||||
|
(lambda (libs)
|
||||||
|
(error 'mkdocs "found libraries unlisted in mkdocs: ~s" libs))]
|
||||||
|
[(test (remove* file-libs libraries*)) =>
|
||||||
|
(lambda (libs)
|
||||||
|
(error 'mkdocs "non-existent libraries listed in mkdocs: ~s" libs))])
|
||||||
|
(let loop ([libs lib-names])
|
||||||
|
(cond [(null? libs) 'ok]
|
||||||
|
[(assoc (caar libs) (cdr libs)) =>
|
||||||
|
(lambda (m)
|
||||||
|
(error 'mkdocs "library ~s has two .thtml files: ~s and ~s"
|
||||||
|
(caar libs) (cdar libs) (cdr m)))]
|
||||||
|
[else (loop (cdr libs))])))
|
||||||
|
|
||||||
|
;; Just like lib-names, but ordered according to libraries*
|
||||||
|
(define libraries (map (lambda (l) (assoc l lib-names)) libraries*))
|
||||||
|
|
||||||
|
(define LIBLINKS
|
||||||
|
(map (lambda (lib)
|
||||||
|
(format "<li><a href=~s>~a</a></li>\n"
|
||||||
|
(string-append (bytes->string/utf-8 (path->bytes (cadr lib))) ".html")
|
||||||
|
(car lib)
|
||||||
|
#;(string-append (bytes->string/utf-8 (path->bytes (cadr lib))) ".ss")))
|
||||||
|
libraries))
|
||||||
|
|
||||||
|
;; Stuff for the preprocessed files
|
||||||
|
(require (lib "mzpp.ss" "preprocessor"))
|
||||||
|
(beg-mark "{") (end-mark "}")
|
||||||
|
(define index-entries '())
|
||||||
|
(define FILENAME #f)
|
||||||
|
(define LIBNAME #f)
|
||||||
|
(define HTMLNAME #f)
|
||||||
|
(define-syntax idx
|
||||||
|
(syntax-rules ()
|
||||||
|
[(_ x)
|
||||||
|
(begin (set! index-entries (cons (list FILENAME LIBNAME HTMLNAME `x)
|
||||||
|
index-entries))
|
||||||
|
(list "<a name=\""`x"\">"`x"</a>"))]))
|
||||||
|
|
||||||
|
;; Make html files
|
||||||
|
(for-each (lambda (thtml)
|
||||||
|
(define html (bytes->path (regexp-replace #rx#"[.]thtml" (path->bytes thtml) #".html")))
|
||||||
|
(printf "Processing ~a...\n" thtml)
|
||||||
|
(set! HTMLNAME html)
|
||||||
|
#;(set! FILENAME (bytes->path (regexp-replace #rx#"[.]thtml" (path->bytes thtml) #".ss")))
|
||||||
|
(with-output-to-file (build-path dest-dir html)
|
||||||
|
(lambda () (preprocess thtml))
|
||||||
|
'replace))
|
||||||
|
thtml-files)
|
||||||
|
|
||||||
|
;; Make hdindex file:
|
||||||
|
(let ([ifile (build-path dest-dir "hdindex")])
|
||||||
|
(printf "Writing hdindex...\n")
|
||||||
|
(with-output-to-file ifile
|
||||||
|
(lambda ()
|
||||||
|
(define (writeln x) (printf "~s\n" x))
|
||||||
|
(define (do-entry filename libname html entry)
|
||||||
|
(let ([entry (format "~a" entry)]
|
||||||
|
[title (format "~a teachpack" libname)])
|
||||||
|
(writeln `(,entry ,(bytes->string/utf-8 (path->bytes html)) ,entry ,title))))
|
||||||
|
(printf "(\n")
|
||||||
|
(let ([title "Teachpacks for \"How to Design Classes\""])
|
||||||
|
(writeln `(,title "index.html" "HtDC" ,title)))
|
||||||
|
(for-each (lambda (x) (apply do-entry x)) (reverse index-entries))
|
||||||
|
(printf ")\n"))
|
||||||
|
'truncate))
|
1
teachpack/htdc/draw.ss
Normal file
1
teachpack/htdc/draw.ss
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(printf "this is just a stand-in for the plt/collects/htdch/draw/ library\n")
|
1
teachpack/htdc/idraw.ss
Normal file
1
teachpack/htdc/idraw.ss
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(printf "this is just a stand-in for the plt/collects/htdch/idraw/ library\n")
|
|
@ -58,6 +58,12 @@ students to simulate a small world of animated drawings and games:
|
||||||
<code>(place-image image x y scene)</code>
|
<code>(place-image image x y scene)</code>
|
||||||
places image at (x,y) into scene; (x,y) are comp. graph. coordinates
|
places image at (x,y) into scene; (x,y) are comp. graph. coordinates
|
||||||
|
|
||||||
|
<li><code>{(idx add-line)} : Scene Number Number Number Number Color -> Scene</code><br>
|
||||||
|
<code>(add-line scene x0 y0 x1 y1 c)</code>
|
||||||
|
places a line of color <code>c</code> from <code>(x0,y0)</code> to
|
||||||
|
<code>(x1,y1)</code> into <code>scene</code>;
|
||||||
|
<code>(x,y)</code> are comp. graph. coordinates
|
||||||
|
|
||||||
<li><code>{(idx run-movie)} : (Listof Image) -> true </code><br>
|
<li><code>{(idx run-movie)} : (Listof Image) -> true </code><br>
|
||||||
<code>(run-movie loi)</code>
|
<code>(run-movie loi)</code>
|
||||||
shows the list of images in loi, time-delayed
|
shows the list of images in loi, time-delayed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user