diff --git a/library/help/collections.facts b/doc/handbook/collections.facts similarity index 100% rename from library/help/collections.facts rename to doc/handbook/collections.facts diff --git a/library/help/sequences.facts b/doc/handbook/sequences.facts similarity index 100% rename from library/help/sequences.facts rename to doc/handbook/sequences.facts diff --git a/library/help/tutorial.facts b/doc/handbook/tutorial.facts similarity index 100% rename from library/help/tutorial.facts rename to doc/handbook/tutorial.facts diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index 2560d5133d..d7f96e0e27 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -143,6 +143,13 @@ vectors words ; "/library/bootstrap/init.factor" + "/library/help/database.factor" + "/library/help/stylesheet.factor" + "/library/help/help.factor" + "/library/help/markup.factor" + "/library/help/word-help.factor" + "/library/help/syntax.factor" + "/library/sdl/sdl.factor" "/library/sdl/sdl-video.factor" "/library/sdl/sdl-event.factor" @@ -185,17 +192,7 @@ vectors words ; "/library/ui/presentations.factor" "/library/ui/ui.factor" - "/library/help/database.factor" - "/library/help/stylesheet.factor" - "/library/help/help.factor" - "/library/help/markup.factor" - "/library/help/word-help.factor" "/library/help/commands.factor" - "/library/help/syntax.factor" - - "/library/help/collections.facts" - "/library/help/sequences.facts" - "/library/help/tutorial.facts" "/library/collections/growable.facts" "/library/collections/arrays.facts" @@ -217,6 +214,11 @@ vectors words ; "/library/syntax/parser.facts" "/library/syntax/parse-syntax.facts" "/library/syntax/prettyprint.facts" + "/library/syntax/see.facts" + + "/doc/handbook/collections.facts" + "/doc/handbook/sequences.facts" + "/doc/handbook/tutorial.facts" "/library/syntax/parse-syntax.factor" diff --git a/library/help/markup.factor b/library/help/markup.factor index bd8df3913d..12b29ad094 100644 --- a/library/help/markup.factor +++ b/library/help/markup.factor @@ -193,6 +193,3 @@ DEFER: help : $notes ( content -- ) "Notes" $subheading print-element ; - -: $parsing-note - "This word should only be called from parsing words." $notes ; diff --git a/library/syntax/parser.facts b/library/syntax/parser.facts index 8638d22987..249da91e50 100644 --- a/library/syntax/parser.facts +++ b/library/syntax/parser.facts @@ -1,5 +1,8 @@ USING: help parser sequences ; +IN: help : $parsing-note + "This word should only be called from parsing words." $notes ; + HELP: use f { $description "A variable holding the current vocabulary search path as a sequence of hashtables." } { $see-also in use+ set-use POSTPONE: USING: POSTPONE: USE: } ; diff --git a/library/syntax/prettyprint.factor b/library/syntax/prettyprint.factor index 45f3297669..0f7767c3dd 100644 --- a/library/syntax/prettyprint.factor +++ b/library/syntax/prettyprint.factor @@ -296,13 +296,12 @@ M: wrapper pprint* ( wrapper -- ) : unparse ( object -- str ) [ pprint ] string-out ; : pprint-short ( object -- string ) - [ - 1 line-limit set - 15 length-limit set - 2 nesting-limit set - string-limit on - pprint - ] with-scope ; + H{ + { line-limit 1 } + { length-limit 15 } + { nesting-limit 2 } + { string-limit t } + } clone [ pprint ] bind ; : short. ( object -- ) pprint-short terpri ; diff --git a/library/syntax/prettyprint.facts b/library/syntax/prettyprint.facts index db0ca0d653..b28fbc32c7 100644 --- a/library/syntax/prettyprint.facts +++ b/library/syntax/prettyprint.facts @@ -1,5 +1,13 @@ USING: help prettyprint words ; +IN: help + +: $prettyprinting-note + { + "This word should only be called from inside the " + { $link with-pprint } " combinator." + } $notes ; + HELP: position f { $description "Variable. The prettyprinter's current character position." } ; @@ -66,7 +74,8 @@ HELP: block f HELP: pprinter-block "( -- block )" { $values { "block" "a block section" } } -{ $description "Outputs the block currently being constructed." } ; +{ $description "Outputs the block currently being constructed." } +$prettyprinting-note ; HELP: block-empty? "( section -- ? )" { $values { "section" "a section" } { "?" "a boolean" } } @@ -74,21 +83,26 @@ HELP: block-empty? "( section -- ? )" HELP: add-section "( section -- )" { $values { "section" "a section" } } -{ $description "Adds a section to the current block." } ; +{ $description "Adds a section to the current block." } +$prettyprinting-note ; HELP: text "( text style -- )" -{ $description "Adds a section consisting of a single string with style information to the current block." } ; +{ $description "Adds a section consisting of a single string with style information to the current block." } +$prettyprinting-note ; HELP: plain-text "( text -- )" -{ $description "Adds a section consisting of a single string to the current block." } ; +{ $description "Adds a section consisting of a single string to the current block." } +$prettyprinting-note ; HELP: "( section -- )" { $values { "section" "a section" } } { $description "Decreases indent level by the indent level of the section." } +$prettyprinting-note ; HELP: inset-section "( section -- )" { $values { "section" "a section" } } @@ -103,35 +117,42 @@ HELP: pprint-section "( section -- )" { $description "Prints a section, with a line break and increase in indent level if necessary." } ; HELP: newline "( -- )" -{ $description "Adds a section introducing an unconditional line break to the current block." } ; +{ $description "Adds a section introducing an unconditional line break to the current block." } +$prettyprinting-note ; HELP: advance "( section -- )" { $values { "section" "a section" } } { $description "Emits a space unless the section is the first section on the line." } ; HELP: ) "( -- )" -{ $description "Adds the current block to its containing block." } ; +{ $description "Adds the current block to its containing block." } +$prettyprinting-note ; HELP: last-block? "( -- ? )" { $values { "?" "a boolean" } } -{ $description "Tests if the current block is the top-level block." } ; +{ $description "Tests if the current block is the top-level block." } +$prettyprinting-note ; HELP: block> "( -- )" { $description "Adds the current block to its containing block, unless the current block is the top-level block in which case it does nothing." } -{ $notes "This word is used to end blocks in order for the prettyprinter to be forgiving in the case of mismatched begin/end pairs (this can happen when printing parsing words)." } ; +{ $notes "This word is used to end blocks in order for the prettyprinter to be forgiving in the case of mismatched begin/end pairs (this can happen when printing parsing words)." } +$prettyprinting-note ; HELP: block; "( -- )" -{ $description "Adds the current block to its containing block. The current block will be terminated by an unconditional newline." } ; +{ $description "Adds the current block to its containing block. The current block will be terminated by an unconditional newline." } +$prettyprinting-note ; HELP: end-blocks "( -- )" -{ $description "Unwind all prettyprinter state to the top level block." } ; +{ $description "Unwind all prettyprinter state to the top level block." } +$prettyprinting-note ; HELP: do-pprint "( -- )" { $description "Recursively output all children of the top-level block. The continuation is restored and output terminates if the line length is exceeded; this test is performed in " { $link fresh-line } "." } ; @@ -139,11 +160,13 @@ HELP: do-pprint "( -- )" HELP: pprint* "( obj -- )" { $values { "obj" "an object" } } { $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." } +$prettyprinting-note { $see-also text newline block; } ; HELP: pprint-word "( word -- )" { $values { "word" "a word" } } -{ $description "Adds a text section for the word. Unlike the " { $link word } " method of " { $link pprint* } ", this does not add a " { $link POSTPONE: POSTPONE: } " prefix to parsing words." } ; +{ $description "Adds a text section for the word. Unlike the " { $link word } " method of " { $link pprint* } ", this does not add a " { $link POSTPONE: POSTPONE: } " prefix to parsing words." } +$prettyprinting-note ; HELP: ch>ascii-escape "( ch -- str )" { $values { "ch" "a character" } { "str" "a string" } } @@ -163,31 +186,38 @@ HELP: do-string-limit "( str -- trimmed )" HELP: pprint-string "( str prefix -- )" { $values { "str" "a string" } { "prefix" "a prefix string" } } -{ $description "Outputs a text section consisting of the prefix, the string, and a final quote (\")." } ; +{ $description "Outputs a text section consisting of the prefix, the string, and a final quote (\")." } +$prettyprinting-note ; HELP: nesting-limit? "( -- ? )" { $values { "?" "a boolean" } } -{ $description "Tests if the " { $link nesting-limit } " has been reached." } ; +{ $description "Tests if the " { $link nesting-limit } " has been reached." } +$prettyprinting-note ; HELP: check-recursion "( obj quot -- )" { $values { "obj" "an object" } { "quot" "a quotation with stack effect " { $snippet "( obj -- )" } } } -{ $description "If the object is already being printed, that is, if the prettyprinter has encountered a cycle in the object graph, or if the maximum nesting depth has been reached, outputs a dummy string. Otherwise applies the quotation to the object." } ; +{ $description "If the object is already being printed, that is, if the prettyprinter has encountered a cycle in the object graph, or if the maximum nesting depth has been reached, outputs a dummy string. Otherwise applies the quotation to the object." } +$prettyprinting-note ; HELP: length-limit? "( seq -- trimmed ? )" { $values { "seq" "a sequence" } { "trimmed" "a trimmed sequence" } { "?" "a boolean indicating if trimming took place" } } -{ $description "If the " { $link length-limit } " is set, trims the sequence if necessary, and outputs a boolean indicating if \"...\" should be output." } ; +{ $description "If the " { $link length-limit } " is set, trims the sequence if necessary, and outputs a boolean indicating if \"...\" should be output." } +$prettyprinting-note ; HELP: pprint-element "( obj -- )" { $values { "obj" "an object" } } -{ $description "Prettyprints a sequence element." } ; +{ $description "Prettyprints a sequence element." } +$prettyprinting-note ; HELP: pprint-elements "( seq -- )" { $values { "seq" "a sequence" } } -{ $description "Prettyprints the elements of a sequence, trimming the sequence to " { $link length-limit } " if necessary." } ; +{ $description "Prettyprints the elements of a sequence, trimming the sequence to " { $link length-limit } " if necessary." } +$prettyprinting-note ; HELP: pprint-sequence "( seq start end -- )" { $values { "seq" "a sequence" } { "start" "a word" } { "end" "a word" } } -{ $description "Prettyprints a sequence." } ; +{ $description "Prettyprints a sequence." } +$prettyprinting-note ; HELP: with-pprint "( quot -- )" { $values { "quot" "a quotation" } } diff --git a/library/syntax/see.factor b/library/syntax/see.factor index 291f0a3141..ea4421a67b 100644 --- a/library/syntax/see.factor +++ b/library/syntax/see.factor @@ -24,16 +24,16 @@ sequences strings styles words ; : comment. ( comment -- ) [ H{ { font-style italic } } text ] when* ; -: stack-picture% ( seq -- string ) +: stack-picture ( seq -- string ) dup integer? [ object ] when - [ word-name % " " % ] each ; + [ word-name ] map " " join ; : effect>string ( effect -- string ) [ - "( " % - dup first stack-picture% - "-- " % - second stack-picture% + "(" % + dup first stack-picture % + " -- " % + second stack-picture % ")" % ] "" make ; diff --git a/library/test/collections/strings.factor b/library/test/collections/strings.factor index 2c67f8ed09..f01fee33ed 100644 --- a/library/test/collections/strings.factor +++ b/library/test/collections/strings.factor @@ -1,5 +1,4 @@ IN: temporary -USING: vectors ; USE: errors USE: kernel USE: math @@ -8,6 +7,7 @@ USE: strings USE: test USE: sequences USE: lists +USE: vectors [ ] [ 10 [ [ -1000000 ] catch drop ] times ] unit-test @@ -53,7 +53,7 @@ unit-test [ "OneWord" " " split ] unit-test -[ [ "a" "b" "c" "d" "e" "f" ] ] +[ { "a" "b" "c" "d" "e" "f" } ] [ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test [ "Hello world" t ] [ "Hello world\n" "\n" ?tail ] unit-test diff --git a/library/test/parser.factor b/library/test/parser.factor index e64430cd2d..599776af19 100644 --- a/library/test/parser.factor +++ b/library/test/parser.factor @@ -6,16 +6,16 @@ USE: kernel USE: generic USE: words -[ CHAR: a 1 ] +[ 1 CHAR: a ] [ 0 "abcd" next-char ] unit-test -[ CHAR: \s 6 ] +[ 6 CHAR: \s ] [ 1 "\\u0020hello" next-escape ] unit-test -[ CHAR: \n 2 ] +[ 2 CHAR: \n ] [ 1 "\\nhello" next-escape ] unit-test -[ CHAR: \s 6 ] +[ 6 CHAR: \s ] [ 0 "\\u0020hello" next-char ] unit-test [ [ 1 [ 2 [ 3 ] 4 ] 5 ] ] diff --git a/library/test/prettyprint.factor b/library/test/prettyprint.factor index a6bdbb5485..0e10ada2fe 100644 --- a/library/test/prettyprint.factor +++ b/library/test/prettyprint.factor @@ -55,7 +55,7 @@ unit-test [ ] [ \ compound see ] unit-test -[ ] [ \ pprinter see ] unit-test +[ ] [ \ duplex-stream see ] unit-test [ "ALIEN: 1234" ] [ 1234 unparse ] unit-test diff --git a/library/tools/jedit.factor b/library/tools/jedit.factor index b0b0ae6c22..245c64ce2a 100644 --- a/library/tools/jedit.factor +++ b/library/tools/jedit.factor @@ -56,9 +56,7 @@ parser prettyprint sequences strings words ; : read-packet ( -- string ) 4 read be> read ; : eval>string ( str -- ) - [ - [ [ "Input" parse-stream call ] keep ] try drop - ] string-out ; + [ [ [ eval ] keep ] try drop ] string-out ; : wire-server ( -- ) #! Repeatedly read jEdit requests and execute them. Return