moving documentation

cvs
Slava Pestov 2006-01-05 05:33:12 +00:00
parent 389e2e0672
commit cbc4946d93
13 changed files with 84 additions and 55 deletions

View File

@ -143,6 +143,13 @@ vectors words ;
"/library/bootstrap/init.factor" "/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.factor"
"/library/sdl/sdl-video.factor" "/library/sdl/sdl-video.factor"
"/library/sdl/sdl-event.factor" "/library/sdl/sdl-event.factor"
@ -185,17 +192,7 @@ vectors words ;
"/library/ui/presentations.factor" "/library/ui/presentations.factor"
"/library/ui/ui.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/commands.factor"
"/library/help/syntax.factor"
"/library/help/collections.facts"
"/library/help/sequences.facts"
"/library/help/tutorial.facts"
"/library/collections/growable.facts" "/library/collections/growable.facts"
"/library/collections/arrays.facts" "/library/collections/arrays.facts"
@ -217,6 +214,11 @@ vectors words ;
"/library/syntax/parser.facts" "/library/syntax/parser.facts"
"/library/syntax/parse-syntax.facts" "/library/syntax/parse-syntax.facts"
"/library/syntax/prettyprint.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" "/library/syntax/parse-syntax.factor"

View File

@ -193,6 +193,3 @@ DEFER: help
: $notes ( content -- ) : $notes ( content -- )
"Notes" $subheading print-element ; "Notes" $subheading print-element ;
: $parsing-note
"This word should only be called from parsing words." $notes ;

View File

@ -1,5 +1,8 @@
USING: help parser sequences ; USING: help parser sequences ;
IN: help : $parsing-note
"This word should only be called from parsing words." $notes ;
HELP: use f HELP: use f
{ $description "A variable holding the current vocabulary search path as a sequence of hashtables." } { $description "A variable holding the current vocabulary search path as a sequence of hashtables." }
{ $see-also in use+ set-use POSTPONE: USING: POSTPONE: USE: } ; { $see-also in use+ set-use POSTPONE: USING: POSTPONE: USE: } ;

View File

@ -296,13 +296,12 @@ M: wrapper pprint* ( wrapper -- )
: unparse ( object -- str ) [ pprint ] string-out ; : unparse ( object -- str ) [ pprint ] string-out ;
: pprint-short ( object -- string ) : pprint-short ( object -- string )
[ H{
1 line-limit set { line-limit 1 }
15 length-limit set { length-limit 15 }
2 nesting-limit set { nesting-limit 2 }
string-limit on { string-limit t }
pprint } clone [ pprint ] bind ;
] with-scope ;
: short. ( object -- ) pprint-short terpri ; : short. ( object -- ) pprint-short terpri ;

View File

@ -1,5 +1,13 @@
USING: help prettyprint words ; 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 HELP: position f
{ $description "Variable. The prettyprinter's current character position." } ; { $description "Variable. The prettyprinter's current character position." } ;
@ -66,7 +74,8 @@ HELP: block f
HELP: pprinter-block "( -- block )" HELP: pprinter-block "( -- block )"
{ $values { "block" "a block section" } } { $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 -- ? )" HELP: block-empty? "( section -- ? )"
{ $values { "section" "a section" } { "?" "a boolean" } } { $values { "section" "a section" } { "?" "a boolean" } }
@ -74,21 +83,26 @@ HELP: block-empty? "( section -- ? )"
HELP: add-section "( section -- )" HELP: add-section "( section -- )"
{ $values { "section" "a 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 -- )" 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 -- )" 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: <indent "( section -- )" HELP: <indent "( section -- )"
{ $values { "section" "a section" } } { $values { "section" "a section" } }
{ $description "Increases indent level by the indent level of the section." } { $description "Increases indent level by the indent level of the section." }
$prettyprinting-note ;
HELP: indent> "( section -- )" HELP: indent> "( section -- )"
{ $values { "section" "a section" } } { $values { "section" "a section" } }
{ $description "Decreases indent level by the indent level of the section." } { $description "Decreases indent level by the indent level of the section." }
$prettyprinting-note ;
HELP: inset-section "( section -- )" HELP: inset-section "( section -- )"
{ $values { "section" "a 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." } ; { $description "Prints a section, with a line break and increase in indent level if necessary." } ;
HELP: newline "( -- )" 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 -- )" HELP: advance "( section -- )"
{ $values { "section" "a section" } } { $values { "section" "a section" } }
{ $description "Emits a space unless the section is the first section on the line." } ; { $description "Emits a space unless the section is the first section on the line." } ;
HELP: <block "( -- )" HELP: <block "( -- )"
{ $description "Begins a nested block." } ; { $description "Begins a nested block." }
$prettyprinting-note ;
HELP: end-block "( section -- )" HELP: end-block "( section -- )"
{ $values { "section" "a section" } } { $values { "section" "a section" } }
{ $description "Save the current position as the end position of the section." } ; { $description "Save the current position as the end position of the section." } ;
HELP: (block>) "( -- )" HELP: (block>) "( -- )"
{ $description "Adds the current block to its containing block." } ; { $description "Adds the current block to its containing block." }
$prettyprinting-note ;
HELP: last-block? "( -- ? )" HELP: last-block? "( -- ? )"
{ $values { "?" "a boolean" } } { $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> "( -- )" 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." } { $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; "( -- )" 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 "( -- )" 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 "( -- )" 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 } "." } ; { $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 -- )" HELP: pprint* "( obj -- )"
{ $values { "obj" "an object" } } { $values { "obj" "an object" } }
{ $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." } { $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." }
$prettyprinting-note
{ $see-also text newline <block block> block; } ; { $see-also text newline <block block> block; } ;
HELP: pprint-word "( word -- )" HELP: pprint-word "( word -- )"
{ $values { "word" "a 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 )" HELP: ch>ascii-escape "( ch -- str )"
{ $values { "ch" "a character" } { "str" "a string" } } { $values { "ch" "a character" } { "str" "a string" } }
@ -163,31 +186,38 @@ HELP: do-string-limit "( str -- trimmed )"
HELP: pprint-string "( str prefix -- )" HELP: pprint-string "( str prefix -- )"
{ $values { "str" "a string" } { "prefix" "a prefix string" } } { $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? "( -- ? )" HELP: nesting-limit? "( -- ? )"
{ $values { "?" "a boolean" } } { $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 -- )" HELP: check-recursion "( obj quot -- )"
{ $values { "obj" "an object" } { "quot" "a quotation with stack effect " { $snippet "( obj -- )" } } } { $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 ? )" HELP: length-limit? "( seq -- trimmed ? )"
{ $values { "seq" "a sequence" } { "trimmed" "a trimmed sequence" } { "?" "a boolean indicating if trimming took place" } } { $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 -- )" HELP: pprint-element "( obj -- )"
{ $values { "obj" "an object" } } { $values { "obj" "an object" } }
{ $description "Prettyprints a sequence element." } ; { $description "Prettyprints a sequence element." }
$prettyprinting-note ;
HELP: pprint-elements "( seq -- )" HELP: pprint-elements "( seq -- )"
{ $values { "seq" "a sequence" } } { $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 -- )" HELP: pprint-sequence "( seq start end -- )"
{ $values { "seq" "a sequence" } { "start" "a word" } { "end" "a word" } } { $values { "seq" "a sequence" } { "start" "a word" } { "end" "a word" } }
{ $description "Prettyprints a sequence." } ; { $description "Prettyprints a sequence." }
$prettyprinting-note ;
HELP: with-pprint "( quot -- )" HELP: with-pprint "( quot -- )"
{ $values { "quot" "a quotation" } } { $values { "quot" "a quotation" } }

View File

@ -24,16 +24,16 @@ sequences strings styles words ;
: comment. ( comment -- ) : comment. ( comment -- )
[ H{ { font-style italic } } text ] when* ; [ H{ { font-style italic } } text ] when* ;
: stack-picture% ( seq -- string ) : stack-picture ( seq -- string )
dup integer? [ object <array> ] when dup integer? [ object <array> ] when
[ word-name % " " % ] each ; [ word-name ] map " " join ;
: effect>string ( effect -- string ) : effect>string ( effect -- string )
[ [
"( " % "(" %
dup first stack-picture% dup first stack-picture %
"-- " % " -- " %
second stack-picture% second stack-picture %
")" % ")" %
] "" make ; ] "" make ;

View File

@ -1,5 +1,4 @@
IN: temporary IN: temporary
USING: vectors ;
USE: errors USE: errors
USE: kernel USE: kernel
USE: math USE: math
@ -8,6 +7,7 @@ USE: strings
USE: test USE: test
USE: sequences USE: sequences
USE: lists USE: lists
USE: vectors
[ ] [ 10 [ [ -1000000 <sbuf> ] catch drop ] times ] unit-test [ ] [ 10 [ [ -1000000 <sbuf> ] catch drop ] times ] unit-test
@ -53,7 +53,7 @@ unit-test
[ "OneWord" " " split ] [ "OneWord" " " split ]
unit-test unit-test
[ [ "a" "b" "c" "d" "e" "f" ] ] [ { "a" "b" "c" "d" "e" "f" } ]
[ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test [ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test
[ "Hello world" t ] [ "Hello world\n" "\n" ?tail ] unit-test [ "Hello world" t ] [ "Hello world\n" "\n" ?tail ] unit-test

View File

@ -6,16 +6,16 @@ USE: kernel
USE: generic USE: generic
USE: words USE: words
[ CHAR: a 1 ] [ 1 CHAR: a ]
[ 0 "abcd" next-char ] unit-test [ 0 "abcd" next-char ] unit-test
[ CHAR: \s 6 ] [ 6 CHAR: \s ]
[ 1 "\\u0020hello" next-escape ] unit-test [ 1 "\\u0020hello" next-escape ] unit-test
[ CHAR: \n 2 ] [ 2 CHAR: \n ]
[ 1 "\\nhello" next-escape ] unit-test [ 1 "\\nhello" next-escape ] unit-test
[ CHAR: \s 6 ] [ 6 CHAR: \s ]
[ 0 "\\u0020hello" next-char ] unit-test [ 0 "\\u0020hello" next-char ] unit-test
[ [ 1 [ 2 [ 3 ] 4 ] 5 ] ] [ [ 1 [ 2 [ 3 ] 4 ] 5 ] ]

View File

@ -55,7 +55,7 @@ unit-test
[ ] [ \ compound see ] unit-test [ ] [ \ compound see ] unit-test
[ ] [ \ pprinter see ] unit-test [ ] [ \ duplex-stream see ] unit-test
[ "ALIEN: 1234" ] [ 1234 <alien> unparse ] unit-test [ "ALIEN: 1234" ] [ 1234 <alien> unparse ] unit-test

View File

@ -56,9 +56,7 @@ parser prettyprint sequences strings words ;
: read-packet ( -- string ) 4 read be> read ; : read-packet ( -- string ) 4 read be> read ;
: eval>string ( str -- ) : eval>string ( str -- )
[ [ [ [ eval ] keep ] try drop ] string-out ;
[ [ <string-reader> "Input" parse-stream call ] keep ] try drop
] string-out ;
: wire-server ( -- ) : wire-server ( -- )
#! Repeatedly read jEdit requests and execute them. Return #! Repeatedly read jEdit requests and execute them. Return