]> gitweb.factorcode.org Git - factor.git/commitdiff
Docs: fixed doc example errors triggered by help-lint and added with-disposal where...
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 13 Apr 2014 23:26:43 +0000 (01:26 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 14 Apr 2014 15:42:10 +0000 (08:42 -0700)
12 files changed:
basis/io/buffers/buffers-docs.factor
basis/io/files/windows/windows-docs.factor
basis/io/launcher/launcher-docs.factor
basis/io/timeouts/timeouts-docs.factor
basis/math/matrices/elimination/elimination-docs.factor
basis/math/matrices/matrices-docs.factor
basis/urls/urls-docs.factor
basis/vocabs/files/files-docs.factor
core/io/files/files-docs.factor
core/sequences/sequences-docs.factor
core/source-files/errors/errors-docs.factor
core/words/words-docs.factor

index c2bf6e0f67b9ae0154ccec620e3c7185f82cdfd7..d9fbc683c332818958c85ccbc1d8464f202f9be3 100644 (file)
@@ -49,7 +49,7 @@ $nl
 
 HELP: <buffer>
 { $values { "n" "a non-negative integer" } { "buffer" buffer } }
-{ $description "Creates a buffer with an initial capacity of " { $snippet "n" } " bytes." } ;
+{ $description "Allocates a buffer with an initial capacity of " { $snippet "n" } " bytes." } ;
 
 HELP: buffer-reset
 { $values { "n" "a non-negative integer" } { "buffer" buffer } }
@@ -72,8 +72,8 @@ HELP: buffer-read
 { $description "Collects a byte array of " { $snippet "n" } " bytes starting from the buffer's current position, and advances the position accordingly. If there are less than " { $snippet "n" } " bytes available, the output is truncated." }
 { $examples
   { $example
-    "USING: io.buffers ;"
-    "5 100 <buffer> B{ 7 14 21 } over >buffer buffer-read ."
+    "USING: destructors io.buffers kernel prettyprint ;"
+    "5 100 <buffer> [ B{ 7 14 21 } over >buffer buffer-read ] with-disposal ."
     "B{ 7 14 21 }"
   }
 } ;
@@ -83,8 +83,8 @@ HELP: buffer-length
 { $description "Outputs the number of unconsumed bytes in the buffer." }
 { $examples
   { $example
-    "USING: io.buffers ;"
-    "100 <buffer> B{ 7 14 21 } over >buffer buffer-length ."
+    "USING: destructors io.buffers kernel prettyprint ;"
+    "100 <buffer> [ B{ 7 14 21 } over >buffer buffer-length ] with-disposal ."
     "3"
   }
 } ;
@@ -94,8 +94,8 @@ HELP: buffer-capacity
 { $description "Outputs the buffer's maximum capacity before growing." }
 { $examples
   { $example
-    "USING: io.buffers ;"
-    "100 <buffer> buffer-capacity ."
+    "USING: destructors io.buffers prettyprint ;"
+    "100 <buffer> [ buffer-capacity ] with-disposal ."
     "100"
   }
 } ;
@@ -115,8 +115,8 @@ HELP: byte>buffer
 { $warning "This word will corrupt memory if the buffer is full." }
 { $examples
   { $example
-    "USING: io.buffers ;"
-    "100 <buffer> 237 over byte>buffer buffer-pop ."
+    "USING: destructors io.buffers kernel prettyprint ;"
+    "100 <buffer> [ 237 over byte>buffer buffer-pop ] with-disposal ."
     "237"
   }
 } ;
index d9b3e16a8ba720864ce5404265ead7a8c81fd05e..099efaa07cb79b834c4d42f31c6ebfd3283ee452 100644 (file)
@@ -5,8 +5,8 @@ HELP: open-read
 { $values { "path" "a filesystem path" } { "win32-file" "a win32 file-handle" } }
 { $description "Opens a file for reading and returns a filehandle to it." }
 { $examples
-  { $example
-    "USING: io.files.windows ;"
+  { $unchecked-example
+    "USING: io.files.windows prettyprint ;"
     "\"resource:core/kernel/kernel.factor\" absolute-path open-read ."
     "T{ win32-file { handle ALIEN: 234 } { ptr 0 } }"
   }
index 08d3f6b99d79877d7457ccf036181fbfcdba64e1..f4681ed31564988717ca53edf738f363a4be6286 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax quotations kernel io io.files
-math calendar ;
+USING: calendar help.markup help.syntax io io.files kernel literals math
+quotations sequences ;
 IN: io.launcher
 
 ARTICLE: "io.launcher.command" "Specifying a command"
@@ -101,9 +101,9 @@ HELP: current-process-handle
 { $description "Returns the handle of the current process." }
 { $examples
   { $example
-    "USING: io.launcher ;"
-    "current-process-handle ."
-    "6881"
+    "USING: io.launcher math prettyprint ;"
+    "current-process-handle number? ."
+    "t"
   }
 } ;
 
@@ -117,16 +117,9 @@ HELP: run-process
 { $description "Launches a process. The object can either be a string, a sequence of strings or a " { $link process } ". See " { $link "io.launcher.descriptors" } " for details." }
 { $examples
   { $example
-    "USING: io.launcher ;"
+    "USING: io.launcher prettyprint ;"
     "\"pwd\" run-process ."
-    "/tmp"
-    "T{ process"
-    "    { command \"pwd\" }"
-    "    { environment H{ } }"
-    "    { environment-mode +append-environment+ }"
-    "    { group +same-group+ }"
-    "    { status 0 }"
-    "}"
+    "T{ process\n    { command \"pwd\" }\n    { environment H{ } }\n    { environment-mode +append-environment+ }\n    { group +same-group+ }\n    { status 0 }\n}"
   }
 }
 { $notes "The output value can be passed to " { $link wait-for-process } " to get an exit code." } ;
@@ -150,20 +143,23 @@ HELP: try-process
 { $description "Launches a process and waits for it to complete. If it exits with a non-zero status code, throws a " { $link process-failed } " error." }
 { $examples
   { $example
-    "USING: continuations io.launcher ;"
-    "[ \"ls --invalid-flag\" try-process ] [ ] recover ."
-    "ls: unknown flag \"--invalid-flag\""
-    "Try with ”ls --help” for more information."
-    "T{ process-failed"
-    "    { process"
-    "         T{ process"
-    "         { command \"ls --invalid-flag\" }"
-    "         { environment H{ } }"
-    "         { environment-mode +append-environment+ }"
-    "         { group +same-group+ }"
-    "         { status 2 }"
-    "    }"
-    "}"
+    "USING: continuations io.launcher prettyprint ;"
+    "[ \"i-dont-exist\" try-process ] [ ] recover ."
+    $[
+        {
+            "T{ process-failed"
+            "    { process"
+            "        T{ process"
+            "            { command \"i-dont-exist\" }"
+            "            { environment H{ } }"
+            "            { environment-mode +append-environment+ }"
+            "            { group +same-group+ }"
+            "            { status 255 }"
+            "        }"
+            "    }"
+            "}"
+        } "\n" join
+    ]
   }
 } ;
 
@@ -176,6 +172,7 @@ HELP: kill-process
   { $example
     "USING: io.launcher ;"
     "\"cat\" run-detached kill-process"
+    ""
   }
 } ;
 
@@ -229,8 +226,8 @@ HELP: with-process-reader
 }
 { $description "Launches a process and redirects its output via a pipe. The quotation is called with " { $link input-stream } " and " { $link output-stream } " rebound to this pipe." }
 { $examples
-  { $example
-    "USING: io.launcher ;"
+  { $unchecked-example
+    "USING: io.launcher prettyprint ;"
     "\"ls -dl /etc\" utf8 [ contents ] with-process-reader ."
     "\"drwxr-xr-x 213 root root 12288 mar 11 18:52 /etc\\n\""
   }
index cf7ba5167cde89bf4f18cf6634766ad559c4314b..ce71b1c99b1e2776657e066bac38aee9446f3773 100644 (file)
@@ -9,8 +9,8 @@ HELP: set-timeout
 { $values { "dt/f" { $maybe duration } } { "obj" object } }\r
 { $contract "Sets an object's timeout." }\r
 { $examples "Waits five seconds for a process that sleeps for ten seconds:"\r
-  { $example\r
-    "USING: calendar io.launcher io.timeouts ;"\r
+  { $unchecked-example\r
+    "USING: calendar io.launcher io.timeouts kernel ;"\r
     "\"sleep 10\" >process 5 seconds over set-timeout run-process"\r
     "Process was killed as a result of a call to"\r
     "kill-process, or a timeout"\r
index 4a3bcabac0ed3e21c88282871af361f59acd4cf3..9ea3f607d66c03b16787cbde348171c11e27fd78 100644 (file)
@@ -3,12 +3,12 @@ USING: help.markup help.syntax math sequences ;
 IN: math.matrices.elimination
 
 HELP: inverse
-{ $values { "matrix" sequence } { "matrix" sequence } }
+{ $values { "matrix" sequence } }
 { $description "Computes the multiplicative inverse of a matrix. Assuming the matrix is invertible." }
 { $examples
   "A matrix multiplied by its inverse is the identity matrix."
   { $example
-    "USING: math.matrices math.matrices.elimination prettyprint ;"
+    "USING: kernel math.matrices math.matrices.elimination prettyprint ;"
     "{ { 3 4 } { 7 9 } } dup inverse m. 2 identity-matrix = ."
     "t"
   }
index 3a1eb0a5429412f6908f5ca37b95c27c341710af..2242715c93c8918a0c2fa711548b63e48d4aae4c 100644 (file)
@@ -1,5 +1,4 @@
 USING: help.markup help.syntax math sequences ;
-
 IN: math.matrices
 
 HELP: zero-matrix
@@ -15,7 +14,7 @@ HELP: identity-matrix
 { $description "Creates an identity matrix of size " { $snippet "n x n" } ", where the diagonal values are all ones." } ;
 
 HELP: m.v
-{ $values { "m" sequence } { "v" sequence } { "v" sequence } }
+{ $values { "m" sequence } { "v" sequence } }
 { $description "Computes the dot product between a matrix and a vector." }
 { $examples
   { $example
@@ -26,7 +25,7 @@ HELP: m.v
 } ;
 
 HELP: m.
-{ $values { "m" sequence } { "m" sequence } { "m" sequence } }
+{ $values { "m" sequence } }
 { $description "Computes the dot product between two matrices, i.e multiplies them." }
 { $examples
   { $example
@@ -37,7 +36,7 @@ HELP: m.
 } ;
 
 HELP: m+
-{ $values { "m" sequence } { "m" sequence } { "m" sequence } }
+{ $values { "m" sequence } }
 { $description "Adds the matrices component-wise." }
 { $examples
   { $example
@@ -48,7 +47,7 @@ HELP: m+
 } ;
 
 HELP: m-
-{ $values { "m" sequence } { "m" sequence } { "m" sequence } }
+{ $values { "m" sequence } }
 { $description "Subtracts the matrices component-wise." }
 { $examples
   { $example
index 71423a2361481fe402153552be60e01dbbd2e8cf..46deab82b935148949a0c8e9ffb5ca015cde7302 100644 (file)
@@ -157,11 +157,9 @@ HELP: url-addr
         "T{ inet { host \"ftp.cdrom.com\" } { port 21 } }"
     }
     { $example
-        "USING: prettyprint urls ;"
+        "USING: io.sockets.secure prettyprint urls ;"
         "URL\" https://google.com/\" url-addr ."
-        "T{ secure"
-        "{ addrspec T{ inet { host \"google.com\" } { port 443 } } }"
-        "}"
+        "T{ secure\n    { addrspec T{ inet { host \"google.com\" } { port 443 } } }\n}"
     }
 } ;
 
index 0cf6880bec813f8bbbecc4817de0b33b8d18b31d..60eb4a9009fd7cc1b42617d792b3566792fc53dc 100644 (file)
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax strings ;
+USING: help.markup help.syntax literals sequences strings ;
 IN: vocabs.files
 
 HELP: vocab-tests-path
@@ -18,13 +18,17 @@ HELP: vocab-files
 { $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." }
 { $examples
   { $example
-    "USING: vocabs.files ; "
+    "USING: prettyprint vocabs.files ; "
     "\"alien.libraries\" vocab-files ."
-    "{"
-    "    \"resource:basis/alien/libraries/libraries.factor\""
-    "    \"resource:basis/alien/libraries/libraries-docs.factor\""
-    "    \"resource:basis/alien/libraries/libraries-tests.factor\""
-    "}"
+    $[
+        {
+            "{"
+            "    \"resource:basis/alien/libraries/libraries.factor\""
+            "    \"resource:basis/alien/libraries/libraries-docs.factor\""
+            "    \"resource:basis/alien/libraries/libraries-tests.factor\""
+            "}"
+        } "\n" join
+    ]
   }
 } ;
 
@@ -33,17 +37,22 @@ HELP: vocab-tests
 { $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." }
 { $examples
   { $example
-    "USING: vocabs.files ; "
+    "USING: prettyprint vocabs.files ; "
     "\"xml\" vocab-tests ."
-    "{"
-    "    \"resource:basis/xml/tests/xmode-dtd.factor\""
-    "    \"resource:basis/xml/tests/test.factor\""
-    "    \"resource:basis/xml/tests/state-parser-tests.factor\""
-    "    \"resource:basis/xml/tests/soap.factor\""
-    "    \"resource:basis/xml/tests/templating.factor\""
-    "    \"resource:basis/xml/tests/encodings.factor\""
-    "    \"resource:basis/xml/tests/xmltest.factor\""
-    "    \"resource:basis/xml/tests/funny-dtd.factor\""
-    "}"
+    $[
+        {
+            "{"
+            "    \"resource:basis/xml/tests/xmode-dtd.factor\""
+            "    \"resource:basis/xml/tests/test.factor\""
+            "    \"resource:basis/xml/tests/state-parser-tests.factor\""
+            "    \"resource:basis/xml/tests/soap.factor\""
+            "    \"resource:basis/xml/tests/templating.factor\""
+            "    \"resource:basis/xml/tests/encodings.factor\""
+            "    \"resource:basis/xml/tests/xmltest.factor\""
+            "    \"resource:basis/xml/tests/funny-dtd.factor\""
+            "    \"resource:basis/xml/tests/cdata.factor\""
+            "}"
+        } "\n" join
+    ]
   }
 } ;
index fe52d79ceae2323e9efcd966b235b12a65e14374..c6e7e801d2889718cda13d4bdf9e94256c903145 100644 (file)
@@ -81,9 +81,9 @@ HELP: file-lines
 { $description "Opens the file at the given path using the given encoding, and returns a list of the lines in that file." }
 { $examples
   { $example
-    "USING: io.files io.encodings.utf8 ;"
+    "USING: io.files io.encodings.utf8 prettyprint sequences ;"
     "\"resource:core/kernel/kernel.factor\" utf8 file-lines first ."
-    "! Copyright (C) 2004, 2009 Slava Pestov."
+    "\"! Copyright (C) 2004, 2009 Slava Pestov.\""
   }
 }
 { $errors "Throws an error if the file cannot be opened for reading." } ;
index 60db385cac71cfd1afc91c367beedd5258dc2d98..4b72acc0f2a02458374b07a69cb507bd063b03e0 100644 (file)
@@ -948,8 +948,9 @@ HELP: head?
 { $description "Tests if " { $snippet "seq" } " starts with " { $snippet "begin" } ". If " { $snippet "begin" } " is longer than " { $snippet "seq" } ", this word outputs " { $link f } "." }
 { $examples
   { $example
-    "root-cache get keys [ \"help.l\" head? ] filter ."
-    "{ \"help.lint.checks\" \"help.lint.private\" \"help.lint\" }"
+    "USING: prettyprint sequences ;"
+    "{ \"accept\" \"adept\" \"advance\" \"advice\" \"affect\" } [ \"ad\" head? ] filter ."
+    "{ \"adept\" \"advance\" \"advice\" }"
   }
 } ;
 
index 31351480b6c2288fce485e38396398ca46f26617..17d0094d541f1b8ff15699d774c3cb87d563fa34 100644 (file)
@@ -12,7 +12,7 @@ HELP: error-type-holder
     { { $slot "icon" } { "path to an icon image representing this error type." } }
     { { $slot "quot" } { "quotation that produces a list of all errors of this type." } }
     { { $slot "forget-quot" } { "a quotation that removes errors of this type for a given word." } }
-    { { $slot "fatal?" } { "whether the error is fatal or not. default " { $snippet t } "." } }
+    { { $slot "fatal?" } { "whether the error is fatal or not. default " { $link t } "." } }
   }
 } ;
 
@@ -29,12 +29,14 @@ HELP: all-errors
 { $description "Lists all errors in the system." } ;
 
 HELP: error-file
+{ $values { "error" "an error" } { "file" "a file path" } }
 { $description "File in which the error occurred." } ;
 
 HELP: <definition-error>
 { $values
   { "error" "an error." }
   { "definition" "an asset that contains the error." }
-  { "class" "a tuple class deriving " { $snippet source-file-error } "." }
+  { "class" "a tuple class deriving source-file-error." }
+  { "source-file-error" source-file-error }
 }
-{ $description "Creates a new " { $snippet source-file-error } " instance." } ;
+{ $description "Creates a new " { $link source-file-error } " instance." } ;
index 4d08312cc71d98a12f9ffc76a5efa581d3d9372d..55390ec0e174a64d8e53d89d48647cb9ed4b9ad2 100644 (file)
@@ -1,5 +1,5 @@
 USING: definitions help.markup help.syntax kernel parser
-kernel.private vocabs classes quotations
+kernel.private vocabs classes quotations sequences
 strings effects compiler.units ;
 IN: words
 
@@ -347,13 +347,13 @@ HELP: deprecated?
 { $notes "Outputs " { $link f } " if the object is not a word." } ;
 
 HELP: subwords
-{ $values { "word" word } }
+{ $values { "word" word } { "seq" sequence } }
 { $description "Lists all specializations for the given word." }
 { $examples
   { $example
-    "USING: math.functions ;"
-    "clear \ sin subwords ."
-    "{ M\ object sin M\ complex sin M\ real sin M\ float sin }"
+    "USING: math.functions prettyprint words ;"
+    "\\ sin subwords ."
+    "{ M\\ object sin M\\ complex sin M\\ real sin M\\ float sin }"
   }
 }
 { $notes "Outputs " { $link f } " if the word isn't generic." } ;