]> gitweb.factorcode.org Git - factor.git/commitdiff
Documentation fixes
authorSlava Pestov <slava@factorcode.org>
Wed, 12 Dec 2007 03:36:40 +0000 (22:36 -0500)
committerSlava Pestov <slava@factorcode.org>
Wed, 12 Dec 2007 03:36:40 +0000 (22:36 -0500)
32 files changed:
core/bootstrap/image/image-docs.factor
core/continuations/continuations-docs.factor
core/generator/generator-docs.factor
core/generic/math/math-docs.factor
core/hashtables/hashtables-docs.factor
core/io/files/files-docs.factor
core/io/io-docs.factor
core/kernel/kernel-docs.factor
core/libc/libc-docs.factor
core/math/math-docs.factor
core/prettyprint/backend/backend-docs.factor
extra/channels/remote/remote-docs.factor
extra/combinators/lib/lib-docs.factor
extra/concurrency/concurrency-docs.factor
extra/crypto/common/common-docs.factor
extra/help/help-docs.factor
extra/help/lint/lint-docs.factor
extra/help/lint/lint.factor
extra/lazy-lists/lazy-lists-docs.factor
extra/locals/locals-docs.factor
extra/math/functions/functions-docs.factor
extra/models/models-docs.factor
extra/parser-combinators/replace/replace-docs.factor
extra/parser-combinators/simple/simple-docs.factor
extra/peg/peg-docs.factor
extra/promises/promises-docs.factor
extra/serialize/serialize-docs.factor
extra/tools/deploy/config/config-docs.factor
extra/tools/test/test.factor
extra/tuples/lib/lib-docs.factor
extra/ui/gadgets/gadgets-docs.factor
extra/ui/gadgets/worlds/worlds-docs.factor

index 868e49deeb9cb2dbba5008cb3033f502038e0bcf..91aa22b73814aed26835ea3692967eac4a92333b 100644 (file)
@@ -14,7 +14,7 @@ $nl
 ABOUT: "bootstrap.image"
 
 HELP: make-image
-{ $values { "architecture" "a string" } }
+{ $values { "arch" "a string" } }
 { $description "Creates a bootstrap image from sources, where " { $snippet "architecture" } " is one of the following:"
 { $code "x86.32" "x86.64" "ppc" "arm" }
 "The new image file is written to the " { $link resource-path } " and is named " { $snippet "boot." { $emphasis "architecture" } ".image" } "." } ;
index eb6afbf51e71bb0e9f12a35e513f40bddc70716e..87616d883338e3c8ab84525785fa1f9fefe2a618 100644 (file)
@@ -85,7 +85,7 @@ HELP: continuation
 { $description "Reifies the current continuation from the point immediately after which the caller returns." } ;
 
 HELP: >continuation<
-{ $values { "continuation" continuation } { "data" vector } { "retain" vector } { "call" vector } { "name" vector } { "catch" vector } { "c" array } }
+{ $values { "continuation" continuation } { "data" vector } { "retain" vector } { "call" vector } { "name" vector } { "catch" vector } }
 { $description "Takes a continuation apart into its constituents." } ;
 
 HELP: ifcc
index a68454f0012f593ac1d498e64d53bdd078e9c363..655b23e517da32ecee5d15fa7d94d4d522594300 100644 (file)
@@ -48,11 +48,10 @@ HELP: literal-table
 { $var-description "Holds a vector of literal objects referenced from the currently compiling word. If " { $link compiled-stack-traces? } " is on, " { $link init-generator } " ensures that the first entry is the word being compiled." } ;
 
 HELP: init-generator
-{ $values { "word" word } }
 { $description "Prepares to generate machine code for a word." } ;
 
 HELP: generate-1
-{ $values { "label" word } { "node" "a dataflow node" } { "quot" "a quotation with stack effect " { $snippet "( node -- )" } } }
+{ $values { "word" word } { "label" word } { "node" "a dataflow node" } { "quot" "a quotation with stack effect " { $snippet "( node -- )" } } }
 { $description "Generates machine code for " { $snippet "label" } " by applying the quotation to the dataflow node." } ;
 
 HELP: generate-node
index b19b358343a980a591a3d627aacbd69ddf554cc5..b1148bb34e15f55c117c3a6f235720421a36c899 100644 (file)
@@ -4,7 +4,7 @@ generic.math ;
 HELP: math-upgrade
 { $values { "class1" "a class word" } { "class2" "a class word" } { "quot" "a quotation with stack effect " { $snippet "( n n -- n n )" } } }
 { $description "Outputs a quotation for upgrading numberical types. It takes two numbers on the stack, an instance of " { $snippet "class1" } ", and an instance of " { $snippet "class2" } ", and converts the one with the lower priority to the higher priority type." }
-{ $examples { $example "USE: generic.math" "fixnum bignum math-upgrade ." "[ >r >bignum r> ]" } } ;
+{ $examples { $example "USE: generic.math" "fixnum bignum math-upgrade ." "[ [ >bignum ] dip ]" } } ;
 
 HELP: no-math-method
 { $values { "left" "an object" } { "right" "an object" } { "generic" "a generic word" } }
@@ -14,7 +14,7 @@ HELP: no-math-method
 HELP: math-method
 { $values { "word" "a generic word" } { "class1" "a class word" } { "class2" "a class word" } { "quot" "a quotation" } }
 { $description "Generates a definition for " { $snippet "word" } " when the two inputs are instances of " { $snippet "class1" } " and " { $snippet "class2" } ", respectively." }
-{ $examples { $example "USE: generic.math" "\\ + fixnum float math-method ." "[ >r >float r> float+ ]" } } ;
+{ $examples { $example "USE: generic.math" "\\ + fixnum float math-method ." "[ [ >float ] dip float+ ]" } } ;
 
 HELP: math-class
 { $class-description "The class of subtypes of " { $link number } " which are not " { $link null } "." } ;
index 5ed8fbbe3a7e66245342732d1351c8eff522b8fb..3719c2f9e004704b597f7d9b12bb9ec36df34ad6 100644 (file)
@@ -96,7 +96,7 @@ HELP: hash-deleted+
 { $side-effects "hash" } ;
 
 HELP: (set-hash)
-{ $values { "value" "a value" } { "key" "a key to add" } { "hash" hashtable } }
+{ $values { "value" "a value" } { "key" "a key to add" } { "hash" hashtable } { "new?" "a boolean" } }
 { $description "Stores the key/value pair into the hashtable. This word does not grow the hashtable if it exceeds capacity, therefore a hang can result. User code should use " { $link set-at } " instead, which grows the hashtable if necessary." }
 { $side-effects "hash" } ;
 
index fba91ded0ac0305aced9bc58c03fb5ff2d284623..3a23c8f6efa95d5e462afeafcd8cb42463d6c661 100755 (executable)
@@ -104,7 +104,7 @@ HELP: file-modified
 HELP: parent-directory
 { $values { "path" "a pathname string" } { "parent" "a pathname string" } }
 { $description "Strips the last component off a pathname." }
-{ $examples { $example "USE: io.files" "\"/etc/passwd\" parent-directory print" "/etc" } } ;
+{ $examples { $example "USE: io.files" "\"/etc/passwd\" parent-directory print" "/etc/" } } ;
 
 HELP: file-name
 { $values { "path" "a pathname string" } { "string" string } }
index d653bc8032f84ccb1eab568ec0d03d70ccc499a4..5c71714c649d86ad4facbf77c6ce4bec9786a23d 100644 (file)
@@ -134,12 +134,13 @@ $nl
 $io-error ;
 
 HELP: make-block-stream
-{ $values { "quot" "a quotation" } { "style" "a hashtable" } { "stream" "an output stream" } }
-{ $contract "Calls the quotation in a new dynamic scope with the " { $link stdio } " stream rebound to a nested paragraph stream, with formatting information applied."
+{ $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } }
+{ $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "."
 $nl
 "Unlike " { $link make-span-stream } ", this creates a new paragraph block in the output."
 $nl
 "The " { $snippet "style" } " hashtable holds paragraph style information. See " { $link "paragraph-styles" } "." }
+{ $notes "Instead of calling this word directly, use " { $link with-nesting } "." }
 $io-error ;
 
 HELP: stream-write-table
@@ -151,16 +152,17 @@ $nl
 $io-error ;
 
 HELP: make-cell-stream
-{ $values { "quot" quotation } { "style" hashtable } { "stream" "an output stream" } { "table-cell" object } }
-{ $contract "Creates a table cell by calling the quotation in a new scope with a rebound " { $link stdio } " stream. Callers should not make any assumptions about the type of this word's output value; it should be treated like an opaque handle passed to " { $link stream-write-table } "." }
+{ $values { "style" hashtable } { "stream" "an output stream" } { "stream'" object } }
+{ $contract "Creates an output stream which writes to a table cell object." }
 { $notes "Instead of calling this word directly, use " { $link tabular-output } "." }
 $io-error ;
 
 HELP: make-span-stream
-{ $values { "style" "a hashtable" } { "quot" "a quotation" } { "stream" "an output stream" } }
-{ $contract "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "."
+{ $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } }
+{ $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "."
 $nl
-"Unlike " { $link make-block-stream } ", the quotation's output is inline, and not nested in a paragraph block." }
+"Unlike " { $link make-block-stream } ", the stream output is inline, and not nested in a paragraph block." }
+{ $notes "Instead of calling this word directly, use " { $link with-style } "." }
 $io-error ;
 
 HELP: stream-print
index de3c0ead3ef4723e054187f61cd9f41fd1d7b583..31d28a6ec617d33e3e21d4f72a8cf3ca4f493712 100644 (file)
@@ -542,7 +542,7 @@ HELP: 3compose
 } ;
 
 HELP: while
-{ $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "quot" "a quotation" } { "tail" "a quotation" } }
+{ $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } }
 { $description "Repeatedly calls " { $snippet "pred" } ". If it yields " { $link f } ", iteration stops, otherwise " { $snippet "quot" } " is called. After iteration stops, " { $snippet "tail" } " is called." }
 { $notes "In most cases, tail recursion should be used, because it is simpler both in terms of implementation and conceptually. However in some cases this combinator expresses intent better and should be used."
 $nl
index ba870560d6517de5ee76f0f720d1bf584b84b2a6..45d6b9432607afc02bf577984f5ae1bcc4aa2f2f 100644 (file)
@@ -25,7 +25,7 @@ HELP: memcpy
 { $warning "As per the BSD C library documentation, the behavior is undefined if the source and destination overlap." } ;
 
 HELP: check-ptr
-{ $values { "c-ptr" "an alien address, byte array, or " { $link f } } { "checked" "an alien address or byte array with non-zero address" } }
+{ $values { "c-ptr" "an alien address, byte array, or " { $link f } } }
 { $description "Throws an error if the input is " { $link f } ". Otherwise the object remains on the data stack." } ;
 
 HELP: free
index 60e5310ce47bf003531fd3f677bc4d3ec6102355..5a004534efc7babacc4e85e19b59e73e5cd09046 100755 (executable)
@@ -222,12 +222,12 @@ $nl
 HELP: bit?
 { $values { "x" integer } { "n" integer } { "?" "a boolean" } }
 { $description "Tests if the " { $snippet "n" } "th bit of " { $snippet "x" } " is set." }
-{ $examples { $example "BIN: 101 3 bit? ." "t" } } ;
+{ $examples { $example "BIN: 101 2 bit? ." "t" } } ;
 
 HELP: log2
-{ $values { "n" "a positive integer" } { "b" integer } }
-{ $description "Outputs the largest integer " { $snippet "b" } " such that " { $snippet "2^b" } " is less than " { $snippet "n" } "." }
-{ $errors "Throws an error if " { $snippet "n" } " is zero or negative." } ;
+{ $values { "x" "a positive integer" } { "n" integer } }
+{ $description "Outputs the largest integer " { $snippet "n" } " such that " { $snippet "2^n" } " is less than " { $snippet "x" } "." }
+{ $errors "Throws an error if " { $snippet "x" } " is zero or negative." } ;
 
 HELP: 1+
 { $values { "x" number } { "y" number } }
@@ -344,7 +344,7 @@ HELP: each-integer
 { $notes "This word is used to implement " { $link each } "." } ;
 
 HELP: all-integers?
-{ $values { "n" integer } { "quot" "a quotation with stack effect " { $snippet "( i -- ? )" } } { "i" "an integer or " { $link f } } }
+{ $values { "n" integer } { "quot" "a quotation with stack effect " { $snippet "( i -- ? )" } } { "?" "a boolean" } }
 { $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iterationi stops when the quotation outputs " { $link f } " or the end is reached. If the quotation yields a false value for some integer, this word outputs " { $link f } ". Otherwise, this word outputs " { $link t } "." }
 { $notes "This word is used to implement " { $link all? } "." } ;
 
index bf1c5c2fc20c65c6e9bcef556a01c738ae9f1ccc..4605308a95c18eb2a7ff2f82e787ca611f5b14d2 100644 (file)
@@ -31,7 +31,7 @@ HELP: do-string-limit
 { $description "If " { $link string-limit } " is on, trims the string such that it does not exceed the margin, appending \"...\" if trimming took place." } ;
 
 HELP: pprint-string
-{ $values { "obj" object } { "str" string } { "prefix" "a prefix string" } }
+{ $values { "obj" object } { "str" string } { "prefix" string } { "suffix" string } }
 { $description "Outputs a text section consisting of the prefix, the string, and a final quote (\")." }
 $prettyprinting-note ;
 
index 3cce6fdc4eb300966961aa7f77cc0e9f762ab574..5400f147f414724115eb7a5909a5a8ddcc8c8cd0 100644 (file)
@@ -13,7 +13,7 @@ HELP: <remote-channel>
 "returned by " { $link publish }
 }
 { $examples 
-  { $example "\"localhost\" 9000 <node> \"ID123456\" <remote-channel> \"foo\" over to" }
+  { $code "\"localhost\" 9000 <node> \"ID123456\" <remote-channel> \"foo\" over to" }
 }
 { $see-also publish unpublish } ;
 
@@ -24,7 +24,7 @@ HELP: unpublish
 "accessible by remote nodes."
 }
 { $examples 
-  { $example "<channel> publish unpublish" }
+  { $code "<channel> publish unpublish" }
 }
 { $see-also <remote-channel> publish } ;
 
@@ -37,7 +37,7 @@ HELP: publish
 { $link to } " and " { $link from } " to access the channel."
 }
 { $examples 
-  { $example "<channel> publish" }
+  { $code "<channel> publish" }
 }
 { $see-also <remote-channel> unpublish } ;
 
index 719af59d9e82f17987251dcf93a5d9cacfb893d5..ac05160b317d9cdd690084282ce90657462cb920 100644 (file)
@@ -1,8 +1,9 @@
-USING: help.syntax help.markup kernel prettyprint sequences ;
+USING: help.syntax help.markup kernel prettyprint sequences
+quotations math ;
 IN: combinators.lib
 
 HELP: generate
-{ $values { "generator" "a quotation" } { "predicate" "a quotation" } { "obj" "an object" } }
+{ $values { "generator" quotation } { "predicate" quotation } { "obj" object } }
 { $description "Loop until the generator quotation generates an object that satisfies predicate quotation." }
 { $unchecked-example
     "! Generate a random 20-bit prime number congruent to 3 (mod 4)"
@@ -12,7 +13,7 @@ HELP: generate
 } ;
 
 HELP: ndip
-{ $values { "quot" "a quotation" } { "n" "a number" } }
+{ $values { "quot" quotation } { "n" number } }
 { $description "A generalisation of " { $link dip } " that can work " 
 "for any stack depth. The quotation will be called with a stack that "
 "has 'n' items removed first. The 'n' items are then put back on the "
@@ -25,7 +26,7 @@ HELP: ndip
 { $see-also dip dipd } ;
 
 HELP: nslip
-{ $values { "n" "a number" } }
+{ $values { "n" number } }
 { $description "A generalisation of " { $link slip } " that can work " 
 "for any stack depth. The first " { $snippet "n" } " items after the quotation will be "
 "removed from the stack, the quotation called, and the items restored."
@@ -36,7 +37,7 @@ HELP: nslip
 { $see-also slip nkeep } ;
 
 HELP: nkeep
-{ $values { "quot" "a quotation" } { "n" "a number" } }
+{ $values { "quot" quotation } { "n" number } }
 { $description "A generalisation of " { $link keep } " that can work " 
 "for any stack depth. The first " { $snippet "n" } " items after the quotation will be "
 "saved, the quotation called, and the items restored."
@@ -47,7 +48,7 @@ HELP: nkeep
 { $see-also keep nslip } ;
 
 HELP: map-withn
-{ $values { "seq" "a sequence" } { "quot" "a quotation" } { "n" "a number" } { "newseq" "a sequence" } }
+{ $values { "seq" sequence } { "quot" quotation } { "n" number } { "newseq" sequence } }
 { $description "A generalisation of " { $link map } ". The first " { $snippet "n" } " items after the quotation will be "
 "passed to the quotation given to map-withn for each element in the sequence."
 } 
@@ -57,43 +58,44 @@ HELP: map-withn
 { $see-also each-withn } ;
 
 HELP: each-withn
-{ $values { "seq" "a sequence" } { "quot" "a quotation" } { "n" "a number" } }
+{ $values { "seq" sequence } { "quot" quotation } { "n" number } }
 { $description "A generalisation of " { $link each } ". The first " { $snippet "n" } " items after the quotation will be "
 "passed to the quotation given to each-withn for each element in the sequence."
 } 
 { $see-also map-withn } ;
 
 HELP: sigma
-{ $values { "seq" "a sequence" } { "quot" "a quotation" } }
+{ $values { "seq" sequence } { "quot" quotation } { "n" number } }
 { $description "Like map sum, but without creating an intermediate sequence." }
 { $example
     "! Find the sum of the squares [0,99]"
-    "USE: math.ranges"
-    "100 [1,b] [ sq ] sigma"
+    "USING: math.ranges combinators.lib ;"
+    "100 [1,b] [ sq ] sigma ."
     "338350"
 } ;
 
 HELP: count
-{ $values { "seq" "a sequence" } { "quot" "a quotation" } }
+{ $values { "seq" sequence } { "quot" quotation } { "n" integer } }
 { $description "Efficiently returns the number of elements that the predicate quotation matches." }
 { $example
-    "USE: math.ranges"
+    "USING: math.ranges combinators.lib ;"
     "100 [1,b] [ even? ] count ."
     "50"
 } ;
 
 HELP: all-unique?
-{ $values { "seq" "a sequence" } { "?" "a boolean" } }
+{ $values { "seq" sequence } { "?" "a boolean" } }
 { $description "Tests whether a sequence contains any repeated elements." }
 { $example
+    "USE: combinators.lib"
     "{ 0 1 1 2 3 5 } all-unique? ."
     "f"
 } ;
 
 HELP: &&
-{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } }
+{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } }
 { $description "Calls each quotation in turn; outputs " { $link f } " if one of the quotations output " { $link f } ", otherwise outputs " { $link t } ". As soon as a quotation outputs " { $link f } ", evaluation stops and subsequent quotations are not called." } ;
 
 HELP: ||
-{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } }
+{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } }
 { $description "Calls each quotation in turn; outputs " { $link t } " if one of the quotations output " { $link t } ", otherwise outputs " { $link f } ". As soon as a quotation outputs " { $link t } ", evaluation stops and subsequent quotations are not called." } ;
index cf09f3bb576e57bb0ebcfbf3dddebaaa7d02ddb7..39e8b277e3edc9a1edead5d2f1d48e80fec80379 100644 (file)
@@ -25,9 +25,8 @@ HELP: mailbox-put
 
 HELP: (mailbox-block-unless-pred)
 { $values { "pred" "a quotation with stack effect " { $snippet "( X -- bool )" } } 
-          { "mailbox" "a mailbox object" } 
-         { "pred2" "same object as 'pred'" }
-         { "mailbox2" "same object as 'mailbox'" }
+          { "mailbox" "a mailbox object" }
+          { "timeout" "a timeout in milliseconds" }
 }
 { $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack. The predicate must have stack effect " { $snippet "( X -- bool )" } "." } 
 { $see-also make-mailbox mailbox-empty? mailbox-put mailbox-get mailbox-get-all while-mailbox-empty mailbox-get? } ;
@@ -35,6 +34,7 @@ HELP: (mailbox-block-unless-pred)
 HELP: (mailbox-block-if-empty)
 { $values { "mailbox" "a mailbox object" } 
          { "mailbox2" "same object as 'mailbox'" }
+      { "timeout" "a timeout in milliseconds" }
 }
 { $description "Block the thread if the mailbox is empty." } 
 { $see-also make-mailbox mailbox-empty? mailbox-put mailbox-get mailbox-get-all while-mailbox-empty mailbox-get? } ;
index 1be85a364b3dc79c308e6c2f2356567c15e8071d..1292e047778594da7028025aee3dbbcda52b8aa9 100644 (file)
@@ -13,8 +13,8 @@ HELP: bitroll
 { $values { "x" "an integer (input)" } { "s" "an integer (shift)" } { "w" "an integer (wrap)" } { "y" "an integer" } }
 { $description "Roll n by s bits to the left, wrapping around after w bits." }
 { $examples
-    { $example "1 -1 32 bitroll .b" "10000000000000000000000000000000" }
-    { $example "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" }
+    { $example "USE: crypto.common" "1 -1 32 bitroll .b" "10000000000000000000000000000000" }
+    { $example "USE: crypto.common" "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" }
 } ;
 
 
@@ -22,7 +22,7 @@ HELP: hex-string
 { $values { "seq" "a sequence" } { "str" "a string" } }
 { $description "Converts a sequence of values from 0-255 to a string of hex numbers from 0-ff." }
 { $examples
-    { $example "B{ 1 2 3 4 } hex-string print" "01020304" }
+    { $example "USE: crypto.common" "B{ 1 2 3 4 } hex-string print" "01020304" }
 }
 { $notes "Numbers are zero-padded on the left." } ;
 
index 2d53e4e59d98764e3f2543b92083d6dd6198ad9c..d2d0b9beaee26f6b83fb6fc8e9d8830a8afaf3b9 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.markup help.crossref help.topics help.syntax
-definitions io prettyprint inspector ;
+definitions io prettyprint inspector help.lint ;
 IN: help
 
 ARTICLE: "printing-elements" "Printing markup elements"
@@ -81,7 +81,8 @@ $nl
 }
 { $subsection "element-types" }
 "Related words can be cross-referenced:"
-{ $subsection related-words } ;
+{ $subsection related-words }
+{ $see-also "help.lint" } ;
 
 ARTICLE: "help-impl" "Help system implementation"
 "Help topic protocol:"
@@ -108,6 +109,7 @@ ARTICLE: "help" "Help system"
 "The help system maintains documentation written in a simple markup language, along with cross-referencing and search. Documentation can either exist as free-standing " { $emphasis "articles" } " or be associated with words."
 { $subsection "browsing-help" }
 { $subsection "writing-help" }
+{ $subsection "help.lint" }
 { $subsection "help-impl" } ;
 
 ABOUT: "help"
@@ -143,7 +145,7 @@ HELP: $index
 { $description "Calls the quotation to generate a sequence of help topics, and outputs a " { $link $subsection } " for each one." } ;
 
 HELP: ($index)
-{ $values { "seq" "a sequence of help article names and words" } { "quot" "a quotation with stack effect " { $snippet "( topic -- )" } } }
+{ $values { "articles" "a sequence of help articles" } }
 { $description "Writes a list of " { $link $subsection } " elements to the " { $link stdio } " stream." } ;
 
 HELP: xref-help
index 6ff0699471283ef812637ec9c515296748a0dde3..2813391d074cb2a493e3201b12b575140a751a1d 100644 (file)
@@ -1,8 +1,20 @@
 USING: help.markup help.syntax ;
 IN: help.lint
 
+HELP: check-help
+{ $description "Checks all word and article help." } ;
+
+HELP: check-vocab-help
+{ $values { "vocab" "a vocabulary specifier" } }
+{ $description "Checks all word help in the given vocabulary." } ;
+
 ARTICLE: "help.lint" "Help lint tool"
-"A quick and dirty tool to check documentation in an automated fashion."
+"The " { $vocab-link "help.lint" } " vocabulary implements a tool to check documentation in an automated fashion. You should use this tool to check any documentation that you write."
+$nl
+"To run help lint, use one of the following two words:"
+{ $subsection check-help }
+{ $subsection check-vocab-help }
+"Help lint performs the following checks:"
 { $list
     "ensures examples run and produce stated output"
     { "ensures " { $link $see-also } " elements don't contain duplicate entries" }
index 3621b3c6ad8a02b3b7b825e5093d0ef3a2c8546e..6496ca21ff985bbd74552ceb208ce3008a0b6781 100644 (file)
@@ -4,7 +4,8 @@ USING: sequences parser kernel help help.markup help.topics
 words strings classes tools.browser namespaces io
 io.streams.string prettyprint definitions arrays vectors
 combinators splitting debugger hashtables sorting effects vocabs
-vocabs.loader assocs editors continuations classes.predicate ;
+vocabs.loader assocs editors continuations classes.predicate
+macros combinators.lib ;
 IN: help.lint
 
 : check-example ( element -- )
@@ -29,7 +30,7 @@ IN: help.lint
     stack-effect dup effect-in swap effect-out
     append [ string? ] subset prune natural-sort ;
 
-: check-values ( word element -- )
+: contains-funky-elements? ( element -- ? )
     {
         $shuffle
         $values-x/y
@@ -38,11 +39,20 @@ IN: help.lint
         $predicate
         $class-description
         $error-description
-    }
-    over [ elements empty? ] curry all?
-    pick "declared-effect" word-prop and
-    [ extract-values >array >r effect-values >array r> assert= ]
-    [ 2drop ] if ;
+    } swap [ elements f like ] curry contains? ;
+
+: check-values ( word element -- )
+    {
+        [ over "declared-effect" word-prop ]
+        [ dup contains-funky-elements? not ]
+        [ over macro? not ]
+        [
+            2dup extract-values >array
+            >r effect-values >array
+            r> assert=
+            t
+        ]
+    } && 3drop ;
 
 : check-see-also ( word element -- )
     nip \ $see-also swap elements [
@@ -61,55 +71,59 @@ IN: help.lint
 : check-rendering ( word element -- )
     [ help ] string-out drop ;
 
-: all-word-help ( -- seq )
-    all-words [ word-help ] subset ;
+: all-word-help ( words -- seq )
+    [ word-help ] subset ;
 
 TUPLE: help-error topic ;
 
 : <help-error> ( topic delegate -- error )
     { set-help-error-topic set-delegate } help-error construct ;
 
-: fix-help ( error -- )
-    dup delegate error.
-    help-error-topic >link edit
-    "Press ENTER when done." print flush readln drop
-    refresh-all ;
+M: help-error error.
+    "In " write dup help-error-topic ($link) nl
+    delegate error. ;
+
+: check-something ( obj quot -- )
+    over . flush [ <help-error> , ] recover ; inline
 
 : check-word ( word -- )
-    dup . flush
-    [
-        dup word-help [
-            2dup check-examples
-            2dup check-values
-            2dup check-see-also
-            2dup check-modules
-            2dup drop check-rendering
-        ] assert-depth 2drop
-    ] [
-        dupd <help-error> fix-help check-word
-    ] recover ;
-
-: check-words ( -- )
-    [
-        all-vocabs-seq [ vocab-name ] map
-        "all-vocabs" set
-        all-word-help [ check-word ] each
-    ] with-scope ;
+    dup word-help [
+        [
+            dup word-help [
+                2dup check-examples
+                2dup check-values
+                2dup check-see-also
+                2dup check-modules
+                2dup drop check-rendering
+            ] assert-depth 2drop
+        ] check-something
+    ] [ drop ] if ;
+
+: check-words ( words -- ) [ check-word ] each ;
 
 : check-article ( article -- )
-    dup . flush
     [
         [ dup check-rendering ] assert-depth drop
-    ] [
-        dupd <help-error> fix-help check-article
-    ] recover ;
+    ] check-something ;
 
 : check-articles ( -- )
     articles get keys [ check-article ] each ;
 
-: check-help ( -- ) check-words check-articles ;
+: with-help-lint ( quot -- )
+    [
+        all-vocabs-seq [ vocab-name ] map "all-vocabs" set
+        call
+    ] { } make [ nl error. ] each ; inline
+
+: check-help ( -- )
+    [ all-words check-words check-articles ] with-help-lint ;
+
+: check-vocab-help ( vocab -- )
+    [
+        child-vocabs [ words check-words ] each
+    ] with-help-lint ;
 
-: unlinked-words ( -- seq )
+: unlinked-words ( words -- seq )
     all-word-help [ article-parent not ] subset ;
 
 : linked-undocumented-words ( -- seq )
index 5b53b80cbad8b4dbfe9b0881d6ff881d97c2a300..e8acb397df319c27362e96aa19781a1e99d8f407 100644 (file)
@@ -181,7 +181,7 @@ HELP: lmerge
 { $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } }
 { $description "Return the result of merging the two lists in a lazy manner." } 
 { $examples
-  { $example "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
+  { $example "USE: lazy-lists" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
 }
 { $see-also leach lmap lmap-with lconcat ltake lsubset lfrom-by lcartesian-product lcomp } ;
 
index 92d64d5c6fccdbf89985c13183bd7e6c57ba7bcc..97f9aa5c6513b433771d71b448fa74051fd3b934 100644 (file)
@@ -4,7 +4,7 @@ IN: locals
 <PRIVATE
 
 : $with-locals-note
-    {
+    drop {
         "This form must appear either in a word defined by " { $link POSTPONE: :: } " or " { $link POSTPONE: MACRO:: } ", or alternatively, " { $link with-locals } " must be called on the top-level form of the word to perform closure conversion."
     } $notes ;
 
@@ -28,10 +28,10 @@ HELP: [let
 { $description "Introduces a set of lexical bindings and evaluates the body. The values are evaluated in parallel, and may not refer to other bindings within the same " { $link POSTPONE: [let } " form; for Lisp programmers, this means that Factor's " { $link POSTPONE: [let } " is equivalent to the Lisp " { $snippet "let" } ", not " { $snippet "let*" } "." }
 { $examples
     { $example
-        "USE: locals"
+        "USING: locals math.functions ;"
         ":: frobnicate | n seq |"
         "    [let | n' [ n 6 * ] |"
-        "        seq [ n' gcd ] map ] ;"
+        "        seq [ n' gcd nip ] map ] ;"
         "6 { 36 14 } frobnicate ."
         "{ 36 2 }"
     }
index 08f3918197abdf1f61868a61b8d036f16d80caee..d3a81566b992b353410ed1fabc376c72ea044cab 100755 (executable)
@@ -273,20 +273,20 @@ HELP: mod-inv
 { $description "Outputs an integer " { $snippet "y" } " such that " { $snippet "xy = 1 (mod n)" } "." }
 { $errors "Throws an error if " { $snippet "n" } " is not invertible modulo " { $snippet "n" } "." }
 { $examples
-    { $example "173 1119 mod-inv ." "815" }
-    { $example "173 815 * 1119 mod ." "1" }
+    { $example "USE: math.functions" "173 1119 mod-inv ." "815" }
+    { $example "USE: math.functions" "173 815 * 1119 mod ." "1" }
 } ;
 
 HELP: each-bit
 { $values { "n" integer } { "quot" "a quotation with stack effect " { $snippet "( ? -- )" } } }
 { $description "Applies the quotation to each bit of the integer, starting from the least significant bit, and stopping at the last bit from which point on all bits are either clear (if the integer is positive) or all bits are set (if the integer is negataive)." }
 { $examples
-    { $example "[ BIN: 1101 [ , ] each-bit ] { } make ." "{ t f t t }" }
-    { $example "[ -3 [ , ] each-bit ] { } make ." "{ f t }" }
+    { $example "USE: math.functions" "[ BIN: 1101 [ , ] each-bit ] { } make ." "{ t f t t }" }
+    { $example "USE: math.functions" "[ -3 [ , ] each-bit ] { } make ." "{ t f }" }
 } ;
 
 HELP: ~
-{ $values { "x" real } { "y" real } { "epsilon" real } }
+{ $values { "x" real } { "y" real } { "epsilon" real } { "?" "a boolean" } }
 { $description "Tests if " { $snippet "x" } " and " { $snippet "y" } " are approximately equal to each other. There are three possible comparison tests, chosen based on the sign of " { $snippet "epsilon" } ":"
     { $list
         { { $snippet "epsilon" } " is zero: exact comparison." }
index ace7a3ba034e7fcd3452cdf2311fbc66fbfb99b9..92ea6ced95ce88b7d890f9adcb65d2a7b0160381 100755 (executable)
@@ -45,7 +45,7 @@ HELP: deactivate-model
 { $warning "Calls to " { $link activate-model } " and " { $link deactivate-model } " should be balanced to keep the reference counting consistent, otherwise " { $link model-changed } " might be called at the wrong time or not at all." } ;
 
 HELP: model-changed
-{ $values { "observer" object } }
+{ $values { "model" model } { "observer" object } }
 { $contract "Called to notify observers of a model that the model value has changed as a result of a call to " { $link set-model } ". Observers can be registered with " { $link add-connection } "." } ;
 
 { add-connection remove-connection model-changed } related-words
index e0d75b38a738da4143c94339baff5e0b6f18b5d7..fe73f5d3c22c78e55d02c3657e8e7f52dac859c3 100644 (file)
@@ -10,7 +10,7 @@ HELP: tree-write
     "Write the object to the standard output stream, unless "
     "it is an array, in which case recurse through the array "
     "writing each object to the stream." }
-{ $example "[ { 65 \"bc\" { 68 \"ef\" } } tree-write ] string-out ." "\"AbcDef\"" } ;
+{ $example "USE: parser-combinators" "{ 65 \"bc\" { 68 \"ef\" } } tree-write" "AbcDef" } ;
 
 HELP: search
 { $values 
@@ -24,8 +24,8 @@ HELP: search
     "parser."
 }
     
-{ $example "\"one 123 two 456\" 'integer' search ." "{ 123 456 }" }
-{ $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' <|> search ." "{ 123 \"hello\" 456 }" }
+{ $example "USE: parser-combinators" "\"one 123 two 456\" 'integer' search ." "{ 123 456 }" }
+{ $example "USE: parser-combinators" "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' <|> search ." "{ 123 \"hello\" 456 }" }
 { $see-also search* replace replace* } ;
 
 HELP: search*
@@ -40,7 +40,7 @@ HELP: search*
     "parsers in the 'parsers' sequence."
 }
     
-{ $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2array search* ." "{ 123 \"hello\" 456 }" }
+{ $example "USE: parser-combinators" "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2array search* ." "{ 123 \"hello\" 456 }" }
 { $see-also search replace replace* } ;
 
 HELP: replace
@@ -54,9 +54,9 @@ HELP: replace
     "successfully parse with the given parser replaced with "
     "the result of that parser."
 }   
-{ $example "\"one 123 two 456\" 'integer' [ 2 * number>string ] <@ replace ." "\"one 246 two 912\"" }
-{ $example "\"hello *world* from *factor*\" 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@ replace ." "\"hello <strong>world</strong> from <strong>factor</strong>\"" }
-{ $example "\"hello *world* from _factor_\"\n 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@\n 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ <|>\n replace ." "\"hello <strong>world</strong> from <emphasis>factor</emphasis>\"" }
+{ $example "USING: parser-combinators math.parser ;" "\"one 123 two 456\" 'integer' [ 2 * number>string ] <@ replace ." "\"one 246 two 912\"" }
+{ $example "USE: parser-combinators" "\"hello *world* from *factor*\" 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@ replace ." "\"hello <strong>world</strong> from <strong>factor</strong>\"" }
+{ $example "USE: parser-combinators" "\"hello *world* from _factor_\"\n 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@\n 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ <|>\n replace ." "\"hello <strong>world</strong> from <emphasis>factor</emphasis>\"" }
 { $see-also search search* replace* } ;
 
 HELP: replace*
@@ -71,6 +71,6 @@ HELP: replace*
     "the result of that parser. Each parser is done in sequence so that "
     "the parse results of the first parser can be replaced by later parsers."
 }   
-{ $example "\"*hello _world_*\"\n 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@\n 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ 2array\n replace* ." "\"<strong>hello <emphasis>world</emphasis></strong>\"" }
+{ $example "USE: parser-combinators" "\"*hello _world_*\"\n 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@\n 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ 2array\n replace* ." "\"<strong>hello <emphasis>world</emphasis></strong>\"" }
 { $see-also search search* replace* } ;
 
index 52786aceae50879c6c1c1459e6da56cbcaf4e0af..c2cca6e4a097a3a60d38575a561c606cd892d7f2 100755 (executable)
@@ -60,6 +60,6 @@ HELP: comma-list
     "'element' should be a parser that can parse the elements. The "
     "result of the parser is a sequence of the parsed elements." }
 { $examples
-{ $example "USING: lazy-lits parser-combinators ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
+{ $example "USING: lazy-lists parser-combinators ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
 
 { $see-also 'digit' 'integer' 'string' 'bold' 'italic' comma-list } related-words
index 63b9d4431061012e34b7a0bfed16441e59806174..41463d85a0d62c0f73607834bd203ae347a78b13 100644 (file)
@@ -4,9 +4,9 @@ USING: help.markup help.syntax peg ;
 
 HELP: parse
 { $values 
-  { "string" "a string" } 
-  { "parse" "a parser" } 
-  { "result" "a <parse-result> or f" } 
+  { "input" "a string" } 
+  { "parser" "a parser" } 
+  { "result" "a parse-result or f" } 
 }
 { $description 
     "Given the input string, parse it using the given parser. The result is a <parse-result> object if "
@@ -37,7 +37,7 @@ HELP: range
 }
 { $description 
     "Returns a parser that matches a single character that lies within the range of characters given, inclusive." }
-{ $example ": digit ( -- parser ) CHAR: 0 CHAR: 9 range ;" } ;
+{ $examples { $code ": digit ( -- parser ) CHAR: 0 CHAR: 9 range ;" } } ;
 
 HELP: seq
 { $values 
@@ -60,8 +60,7 @@ HELP: choice
 
 HELP: repeat0
 { $values 
-  { "p1" "a parser" } 
-  { "p2" "a parser" } 
+  { "parser" "a parser" } 
 }
 { $description 
     "Returns a parser that parses 0 or more instances of the 'p1' parser. The AST produced is "
@@ -70,8 +69,7 @@ HELP: repeat0
 
 HELP: repeat1
 { $values 
-  { "p1" "a parser" } 
-  { "p2" "a parser" } 
+  { "parser" "a parser" } 
 }
 { $description 
     "Returns a parser that parses 1 or more instances of the 'p1' parser. The AST produced is "
@@ -79,8 +77,7 @@ HELP: repeat1
 
 HELP: optional
 { $values 
-  { "p1" "a parser" } 
-  { "p2" "a parser" } 
+  { "parser" "a parser" } 
 }
 { $description 
     "Returns a parser that parses 0 or 1 instances of the 'p1' parser. The AST produced is "
@@ -88,29 +85,27 @@ HELP: optional
 
 HELP: ensure
 { $values 
-  { "p1" "a parser" } 
-  { "p2" "a parser" } 
+  { "parser" "a parser" } 
 }
 { $description 
     "Returns a parser that succeeds if the 'p1' parser succeeds but does not add anything to the "
     "AST and does not move the location in the input string. This can be used for lookahead and "
     "disambiguation, along with the " { $link ensure-not } " word." }
-{ $example "\"0\" token ensure octal-parser" } ;
+{ $examples { $code "\"0\" token ensure octal-parser" } } ;
 
 HELP: ensure-not
 { $values 
-  { "p1" "a parser" } 
-  { "p2" "a parser" } 
+  { "parser" "a parser" } 
 }
 { $description 
     "Returns a parser that succeeds if the 'p1' parser fails but does not add anything to the "
     "AST and does not move the location in the input string. This can be used for lookahead and "
     "disambiguation, along with the " { $link ensure } " word." }
-{ $example "\"+\" token \"=\" token ensure-not \"+=\" token 3array seq" } ;
+{ $code "\"+\" token \"=\" token ensure-not \"+=\" token 3array seq" } ;
 
 HELP: action
 { $values 
-  { "p1" "a parser" } 
+  { "parser" "a parser" } 
   { "quot" "a quotation with stack effect ( ast -- ast )" } 
 }
 { $description 
@@ -118,11 +113,10 @@ HELP: action
     "from that parse. The result of the quotation is then used as the final AST. This can be used "
     "for manipulating the parse tree to produce a AST better suited for the task at hand rather than "
     "the default AST." }
-{ $example "CHAR: 0 CHAR: 9 range [ to-digit ] action" } ;
+{ $code "CHAR: 0 CHAR: 9 range [ to-digit ] action" } ;
 
 HELP: sp
 { $values 
-  { "p1" "a parser" } 
   { "parser" "a parser" } 
 }
 { $description 
@@ -131,17 +125,15 @@ HELP: sp
 
 HELP: hide
 { $values 
-  { "p1" "a parser" } 
   { "parser" "a parser" } 
 }
 { $description 
     "Returns a parser that succeeds if the original parser succeeds, but does not " 
     "put any result in the AST. Useful for ignoring 'syntax' in the AST." }
-{ $example "\"[\" token hide number \"]\" token hide 3array seq" } ;
+{ $code "\"[\" token hide number \"]\" token hide 3array seq" } ;
 
 HELP: delay
 { $values 
-  { "quot" "a quotation with stack effect ( -- parser )" } 
   { "parser" "a parser" } 
 }
 { $description 
index f9477feaa3280910e26d91bfe08ea3b9ddfde4cc..8fe2afd2f2e6ff5179b3aa1fae44f5021f7bd15b 100644 (file)
@@ -28,6 +28,6 @@ HELP: LAZY:
 { $values { "word" "a new word to define" } { "definition" "a word definition" } }
 { $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." } 
 { $examples
-  { $example "LAZY: my-add ( a b -- c ) + ;\n1 2 my-add force ." "3" }
+  { $example "IN: promises LAZY: my-add ( a b -- c ) + ;\n1 2 my-add force ." "3" }
 }
 { $see-also force promise-with promise-with2 } ;
index fd257c98797989711f9f785ac91bf17597b1c497..5f21b02ae73049785922c5fd98b5d5e993b8b575 100644 (file)
@@ -8,7 +8,7 @@ HELP: (serialize)
 }
 { $description "Serializes the object to the current output stream. Object references within the structure being serialized are maintained. It must be called from within the scope of a " { $link with-serialized } " call." } 
 { $examples 
-    { $example "USE: serialize" "[\n  [ { 1 2 } dup  (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n  [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" }
+    { $example "USING: serialize io.streams.string ;" "[\n  [ { 1 2 } dup  (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n  [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" }
 }
 { $see-also deserialize (deserialize) serialize with-serialized } ;
 
@@ -17,7 +17,7 @@ HELP: (deserialize)
 }
 { $description "Deserializes an object by reading from the current input stream. Object references within the structure that was originally serialized are maintained. It must be called from within the scope of a " { $link with-serialized } " call." } 
 { $examples 
-    { $example "USE: serialize" "[\n  [ { 1 2 } dup  serialize serialize ] with-serialized\n] string-out\n\n[\n  [ deserialize deserialize ] with-serialized\n] string-in eq? ." "t" }
+    { $example "USING: serialize io.streams.string ;" "[\n  [ { 1 2 } dup  (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n  [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" }
 }
 { $see-also (serialize) deserialize serialize with-serialized } ;
 
@@ -26,7 +26,7 @@ HELP: with-serialized
 }
 { $description "Creates a scope for serialization and deserialization operations. The quotation is called within this scope. The scope is used for maintaining the structure and object references of serialized objects." } 
 { $examples 
-    { $example "USE: serialize" "[\n  [ { 1 2 } dup  (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n  [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" }
+    { $example "USING: serialize io.streams.string ;" "[\n  [ { 1 2 } dup  (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n  [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" }
 }
 { $see-also (serialize) (deserialize) serialize deserialize } ;
 
@@ -35,7 +35,7 @@ HELP: serialize
 }
 { $description "Serializes the object to the current output stream. Object references within the structure being serialized are maintained." } 
 { $examples 
-    { $example "USE: serialize" "[  { 1 2 } serialize ] ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" }
+    { $example "USING: serialize io.streams.string ;" "[ { 1 2 } serialize ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" }
 }
 { $see-also deserialize (deserialize) (serialize) with-serialized } ;
 
@@ -44,6 +44,6 @@ HELP: deserialize
 }
 { $description "Deserializes an object by reading from the current input stream. Object references within the structure that was originally serialized are maintained." } 
 { $examples 
-    { $example "USE: serialize" "[  { 1 2 } serialize ] ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" }
+    { $example "USING: serialize io.streams.string ;" "[ { 1 2 } serialize ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" }
 }
 { $see-also (serialize) deserialize (deserialize) with-serialized } ;
index 5b1efce25e508f620879c4a1530d49e847d6f1cb..c1b9755cd66b8fb1a8b96b11b62f5acae18c98a1 100755 (executable)
@@ -43,7 +43,7 @@ $nl
 HELP: deploy-word-defs?
 { $description "Deploy flag. If set, the deploy tool retains word definition quotations for words compiled with the optimizing compiler. Otherwise, word definitions are stripped from words compiled with the optimizing compiler."
 $nl
-"Off by default. During normal execution, the word definition quotation of a word compiled with the optimizing compiler is not used, so disabling this flag can save space. However, some libraries introspect word definitions dynamically (for example, " { $link "inverse" } ") and so programs using these libraries must retain word definition quotations." } ;
+"Off by default. During normal execution, the word definition quotation of a word compiled with the optimizing compiler is not used, so disabling this flag can save space. However, some libraries introspect word definitions dynamically (for example, " { $vocab-link "inverse" } ") and so programs using these libraries must retain word definition quotations." } ;
 
 HELP: deploy-c-types?
 { $description "Deploy flag. If set, the deploy tool retains the " { $link c-types } " table, otherwise this table is stripped out, saving space."
index 88f94a7fd6df57e72e30151099ba441d6cd876a9..1cefce8721f93b6d5aa62f8489db61e4746091db 100644 (file)
@@ -18,9 +18,7 @@ SYMBOL: this-test
 : (unit-test) ( what quot -- )
     swap dup . flush this-test set
     [ time ] curry failures get [
-        [
-            this-test get <failure> failures get push
-        ] recover
+        [ this-test get failure ] recover
     ] [
         call
     ] if ;
index 040ef3576cb4fcabe4c9166c8d8a77ccaf917923..0ab709a11ff58126c598cb3ec5d1a242b78e334f 100644 (file)
@@ -5,6 +5,7 @@ HELP: >tuple<
 { $values { "class" "a tuple class" } }
 { $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." }
 { $example
+    "USE: tuples.lib"
     "TUPLE: foo a b c ;"
     "1 2 3 \\ foo construct-boa \\ foo >tuple< .s"
     "1\n2\n3"
@@ -16,6 +17,7 @@ HELP: >tuple*<
 { $values { "class" "a tuple class" } }
 { $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." }
 { $example
+    "USE: tuples.lib"
     "TUPLE: foo a bb* ccc dddd* ;"
     "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s"
     "2\n4"
index faac461888d657ef82439827e3b8039d2607ce28..1132ea8d66e5ab4a8eeeeed3234bb0ceff5cb887 100644 (file)
@@ -1,5 +1,5 @@
 USING: ui.gadgets help.markup help.syntax opengl kernel strings
-tuples classes quotations ;
+tuples classes quotations models ;
 
 HELP: rect
 { $class-description "A rectangle with the following slots:"
@@ -259,3 +259,52 @@ HELP: g
 HELP: g->
 { $values { "x" object } { "gadget" gadget } }
 { $description "Duplicates the top of the stack and outputs the gadget being built. Can only be used inside a quotation passed to " { $link build-gadget } "." } ;
+
+HELP: construct-control
+{ $values { "model" model } { "gadget" gadget } { "class" class } { "control" gadget } }
+{ $description "Creates a new control linked to the given model. The gadget parameter becomes the control's delegate. The quotation is called when the model value changes." }
+{ $examples
+    "The following example creates a gadget whose fill color is determined by the value of a model:"
+    { $code
+        "USING: ui.gadgets ui.gadgets.panes models ;"
+        ": set-fill-color >r <solid> r> set-gadget-interior ;"
+        ""
+        "TUPLE: color-gadget ;"
+        ""
+        "M: color-gadget model-changed"
+        "    >r model-value r> set-fill-color ;"
+        ""
+        ": <color-gadget> ( model -- gadget )"
+        "    <gadget>"
+        "    { 100 100 } over set-rect-dim"
+        "    color-gadget"
+        "    construct-control ;"
+        ""
+        "{ 1.0 0.0 0.5 1.0 } <model> <color-gadget>"
+        "gadget."
+    }
+    "The " { $vocab-link "color-picker" } " module extends this example into a more elaborate color chooser."
+} ;
+
+{ construct-control control-value set-control-value gadget-model } related-words
+
+HELP: control-value
+{ $values { "control" gadget } { "value" object } }
+{ $description "Outputs the value of the control's model." } ;
+
+HELP: set-control-value
+{ $values { "value" object } { "control" gadget } }
+{ $description "Sets the value of the control's model." } ;
+
+ARTICLE: "ui-control-impl" "Implementing controls"
+"A " { $emphasis "control" } " is a gadget which is linked to an underlying " { $link model } " by having its " { $link gadget-model } " slot set to a model instance."
+$nl
+"To implement a new control, simply use this word in your constructor:"
+{ $subsection construct-control }
+"Some utility words useful in control implementations:"
+{ $subsection gadget-model }
+{ $subsection control-value }
+{ $subsection set-control-value }
+{ $see-also "models" } ;
+
+ABOUT: "ui-control-impl"
index aedad9e049876a805b06cbaec3892aa51d1f342e..34da6da6b3910b73d8fcbb5bfaab8512edc1619f 100644 (file)
@@ -55,6 +55,6 @@ HELP: find-world
 { $description "Finds the " { $link world } " containing the gadget, or outputs " { $link f } " if the gadget is not grafted." } ;
 
 HELP: draw-world
-{ $values { "rect" "a clipping rectangle" } { "world" world } }
+{ $values { "world" world } }
 { $description "Redraws a world." }
 { $notes "This word should only be called by the UI backend. To force a gadget to redraw from user code, call " { $link relayout-1 } "." } ;