factor/core/prettyprint/sections.facts

97 lines
3.7 KiB
Plaintext

IN: help
USING: io kernel prettyprint prettyprint-internals words ;
HELP: pprint-section
{ $values { "section" "a section" } }
{ $contract "Prettyprints an object delegating to an instance of " { $link section } ", performing wrapping and indentation using the formatting information in the section." } ;
HELP: section
{ $class-description "A section represents a run of text with a known length and indentation level." } ;
HELP: line-limit?
{ $values { "?" "a boolean" } }
{ $description "Tests if the line number limit has been reached, and thus if prettyprinting should stop." } ;
HELP: do-indent
{ $description "Outputs the current indent nesting to the " { $link stdio } " stream." } ;
HELP: fresh-line
{ $values { "n" "the current column position" } }
{ $description "Advances the prettyprinter by one line unless the current line is empty. If the line limit is exceeded, escapes the prettyprinter by restoring a continuation captured in " { $link do-pprint } "." } ;
HELP: <text>
{ $values { "string" "a string" } { "style" "a hashtable" } { "text" "a new text section" } }
{ $description "Creates a text section." } ;
HELP: block
{ $class-description "A block is a section consisting of whitespace-separated child sections." } ;
HELP: pprinter-block
{ $values { "block" "a block section" } }
{ $description "Outputs the block currently being constructed." }
$prettyprinting-note ;
HELP: block-empty?
{ $values { "section" "a section" } { "?" "a boolean" } }
{ $description "Tests if a section is empty. A section is empty if it is a block with no children." } ;
HELP: add-section
{ $values { "section" "a section" } }
{ $description "Adds a section to the current block." }
$prettyprinting-note ;
HELP: text
{ $values { "string" "a string" } }
{ $description "Adds a section consisting of a single string to the current block. The current style on the style stack is used; see " { $link with-style } "." }
$prettyprinting-note ;
HELP: <indent
{ $description "Increases indent level." }
$prettyprinting-note ;
HELP: indent>
{ $description "Decreases indent level." }
$prettyprinting-note ;
HELP: section-fits?
{ $values { "section" "a section" } { "?" "a boolean" } }
{ $description "Tests if a section should be printed on the current line." } ;
HELP: newline
{ $description "Adds a section introducing an unconditional line break to the current block." }
$prettyprinting-note ;
HELP: advance
{ $values { "section" "a section" } }
{ $description "Emits a space unless the section is the first section on the line." } ;
HELP: <inset
{ $values { "style" "a style" } }
{ $description "Begins a nested block." }
$prettyprinting-note ;
HELP: end-block
{ $values { "block" "a block" } }
{ $description "Save the current position as the end position of the block." } ;
HELP: (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." }
$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)." }
$prettyprinting-note ;
HELP: end-blocks
{ $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 } "." } ;