source: project/generator/generator-eggdoc.scm @ 2774

Last change on this file since 2774 was 2774, checked in by Kon Lovett, 14 years ago

Complete re-impl. Just has general coroutine & generator macros.

File size: 4.0 KB
Line 
1;;;; generator-eggdoc.scm
2
3(use eggdoc)
4
5(define license
6"Copyright (c) 2006, Kon Lovett.  All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a
9copy of this software and associated documentation files (the Software),
10to deal in the Software without restriction, including without limitation
11the rights to use, copy, modify, merge, publish, distribute, sublicense,
12and/or sell copies of the Software, and to permit persons to whom the
13Software is furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included
16in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24OTHER DEALINGS IN THE SOFTWARE.")
25
26(define examples '((pre #<<EOF
27(use generator)
28
29(define-generator (list->iterator ls) (for-each yield ls) (yield 'EOL))
30(define t (list->iterator '(1 2)))
31(t)   ; => 1 continues at caller
32(t)   ; => 2 continues at caller
33(t)   ; => EOL
34
35(define-generator (counter n) (yield n) (counter (add1 n)))
36(define t (counter 20))
37(t) ; => 20
38(t) ; => 21
39;... and so on
40EOF
41)))
42
43(define doc `(
44  (eggdoc:begin
45    (name "generator")
46    (description (p "Provides generator-like coroutine operations."))
47    (author (url "mailto:klovett@pacbell.net" "Kon Lovett"))
48    (history
49      (version "1.2" "Redefined make-generator, added coroutine, removed generator")
50      (version "1.1" "Added generator procedure")
51      (version "1.0" "Initial release"))
52
53    (usage)
54    (download "generator.egg")
55
56    (documentation
57
58      (p "Routines supporting generator-like operations. For more general "
59      "control operators see the " (url "F-operator.html" "F-operator") " egg.")
60
61      (subsection "Macros"
62
63        (macro "(make-coroutine ARGS EXPR ...)"
64          (p "Returns a coroutine procedure of " (tt "ARGS") ". Use '(resume "
65          "COROUTINE VALUE0 ...)' within the body to invoke another "
66          "coroutine."))
67
68        (macro "(define-coroutine (NAME ARG ... [ARGLST]) EXPR ...)"
69          (p "Defines a procedure, " (tt "NAME") ", that, when invoked, returns "
70          "a coroutine procedure parameterized on '" (tt "ARG ...") "'. The " (tt
71          "ARGLST") ", if present, are the coroutine procedure arguments. Otherwise "
72          "the coroutine procedure parameter is 'X'. Use '(resume COROUTINE "
73          "VALUE0 ...)' within the body to invoke another coroutine."))
74
75        (macro "(make-generator EXPR ...)"
76          (p "Returns a generator. The '(yield VALUE)' procedure is used within "
77          "the body '" (tt "EXPR ...") "' of the generator to produce a single "
78          "value."))
79
80        (macro "(make-generator/values EXPR ...)"
81          (p "Returns a generator. The '(yield VALUE0 ...)' procedure is used "
82          "within the body '" (tt "EXPR ...") "' of the generator to produce a "
83          "multiple values."))
84
85        (macro "(define-generator (NAME ARG ...) EXPR ...)"
86          (p "Defines a procedure, " (tt "NAME") ", that, when invoked, returns "
87          "a generator parameterized on '" (tt "ARG ...") "'. The '(yield "
88          "VALUE)' procedure is used within the body '" (tt "EXPR ...") "' of "
89          "the generator to produce a single value."))
90
91        (macro "(define-generator/values (NAME ARG ...) EXPR ...)"
92          (p "Defines a procedure, " (tt "NAME") ", that, when invoked, returns "
93          "a generator parameterized on '" (tt "ARG ...") "'. The '(yield VALUE0 "
94          "...)' procedure is used within the body '" (tt "EXPR ...") "' of the "
95          "generator to produce a multiple values."))
96      )
97    )
98
99    (examples ,examples)
100
101    (section "License" (pre ,license))
102  )
103))
104
105(eggdoc->html doc)
Note: See TracBrowser for help on using the repository browser.