factor/library/help/markup.facts

207 lines
9.0 KiB
Plaintext
Raw Normal View History

2006-06-16 23:12:40 -04:00
IN: help
USING: arrays definitions tools io math prettyprint
2006-08-02 15:17:13 -04:00
sequences ;
2006-06-16 23:12:40 -04:00
2006-08-16 21:55:53 -04:00
HELP: print-element
{ $values { "element" "a markup element" } }
{ $description "Prints a markup element to the " { $link stdio } " stream." } ;
HELP: print-content
{ $values { "element" "a markup element" } }
{ $description "Prints a top-level markup element to the " { $link stdio } " stream." } ;
HELP: simple-element
{ $class-description "Class of simple elements, which are just arrays of elements." } ;
2006-06-16 23:12:40 -04:00
2006-08-16 21:55:53 -04:00
HELP: ($span)
{ $values { "quot" "a quotation" } }
2006-06-16 23:12:40 -04:00
{ $description "Prints an inline markup element." } ;
2006-08-16 21:55:53 -04:00
HELP: ($block)
2006-06-16 23:12:40 -04:00
{ $values { "quot" "a quotation" } }
{ $description "Prints a block markup element with newlines before and after." } ;
2006-08-16 21:55:53 -04:00
HELP: $heading
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints a markup element, usually a string, as a block with the " { $link heading-style } "." }
{ $examples
{ $markup-example { $heading "What remains to be discovered" } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $code
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ string... }" } } }
{ $description "Prints code examples, as seen in many help articles. The markup element must be an array of strings." }
{ $notes
"The code becomes clickable if the output stream supports it, and clicking it opens a listener window with the text inserted at the input prompt."
$terpri
"If you want to show code along with sample output, use the " { $link $example } " element."
}
{ $examples
{ $markup-example { $code "2 2 + ." } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $vocabulary
{ $values { "element" "a markup element of the form " { $snippet "{ word }" } } }
2006-06-16 23:12:40 -04:00
{ $description "Prints a word's vocabulary. This markup element is automatically output by the help system, so help descriptions of parsing words should not call it." } ;
2006-08-16 21:55:53 -04:00
HELP: $description
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints the description subheading found on the help page of most words." } ;
2006-08-16 21:55:53 -04:00
HELP: $contract
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints a heading followed by a contract, found on the help page of generic words. Every generic word should document a contract which specifies method behavior that callers can rely upon, and implementations must obey." }
{ $examples
{ $markup-example { $contract "Methods of this generic word must always crash." } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $examples
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints a heading followed by some examples. Word documentation should include examples, at least if the usage of the word is not entirely obvious." }
{ $examples
{ $markup-example { $examples { $example "2 2 + ." "4" } } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $example
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ inputs... output }" } } }
{ $description "Prints a clickable example with sample output. The markup element must be an array of strings. All but the last string are joined by newlines and taken as the input text, and the last string is the output. The example becomes clickable if the output stream supports it, and clicking it opens a listener window with the input text inserted at the input prompt." }
{ $examples
"The output text should be a string of what the input prints when executed, not the final stack contents or anything like that. So the following is an incorrect example:"
{ $markup-example { $example "2 2 +" "4" } }
"However the following is right:"
{ $markup-example { $example "2 2 + ." "4" } }
"Examples can incorporate a call to " { $link .s } " to show multiple output values; the convention is that you may assume the stack is empty before the example evaluates."
} ;
2006-08-16 21:55:53 -04:00
HELP: $markup-example
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints a clickable example showing the prettyprinted source text of " { $snippet "element" } " followed by rendered output. The example becomes clickable if the output stream supports it." }
{ $examples
{ $markup-example { $markup-example { $emphasis "Hi" } } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $warning
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints an element inset in a block styled as so to draw the reader's attention towards it." }
{ $examples
{ $markup-example { $warning "Incorrect use of this product may cause serious injury or death." } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $link
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ topic }" } } }
{ $description "Prints a link to a help article or word." }
{ $examples
{ $markup-example { $link "queues" } }
{ $markup-example { $link + } }
} ;
2006-08-16 21:55:53 -04:00
HELP: textual-list
{ $values { "seq" "a sequence" } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } }
{ $description "Applies the quotation to each element of the sequence, printing a comma between each pair of elements." }
2006-06-16 23:12:40 -04:00
{ $examples
2006-08-16 21:55:53 -04:00
{ $example "{ \"fish\" \"chips\" \"salt\" } [ write ] textual-list print" "fish, chips, salt" }
2006-06-16 23:12:40 -04:00
} ;
2006-08-16 21:55:53 -04:00
HELP: $links
2006-06-16 23:12:40 -04:00
{ $values { "topics" "a sequence of article names or words" } }
{ $description "Prints a series of links to help articles or word documentation." }
{ $notes "This markup element is used to implement " { $link $links } "." }
{ $examples
{ $markup-example { $links + - * / } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $see-also
2006-06-16 23:12:40 -04:00
{ $values { "topics" "a sequence of article names or words" } }
{ $description "Prints a heading followed by a series of links." }
{ $examples
{ $markup-example { $see-also "graphs" "queues" } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $table
2006-06-16 23:12:40 -04:00
{ $values { "element" "an array of arrays of markup elements" } }
{ $description "Prints a table given as an array of rows, where each row must have the same number of columns." }
{ $examples
{ $markup-example
{ $table
{ "a" "b" "c" }
{ "d" "e" "f" }
}
}
} ;
2006-08-16 21:55:53 -04:00
HELP: $values
2006-06-16 23:12:40 -04:00
{ $values { "element" "an array of pairs of markup elements" } }
{ $description "Prints the description of arguments and values found on every word help page. The first element of a pair is the argument name and is output with " { $link $snippet } ". The remainder can be an element of any form." } ;
2006-08-16 21:55:53 -04:00
HELP: $predicate
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ word }" } } }
{ $description "Prints the boilerplate description of a class membership predicate word such as " { $link array? } " or " { $link integer? } "." } ;
2006-08-16 21:55:53 -04:00
HELP: $list
2006-06-16 23:12:40 -04:00
{ $values { "element" "an array of markup elements" } }
{ $description "Prints a bulleted list of markup elements." }
{ $notes
"A common mistake is that if an item consists of more than just a string, it will be broken up as several items:"
{ $markup-example
{ $list
"First item"
"Second item " { $emphasis "with emphasis" }
}
}
"The fix is easy; just group the two markup elements making up the second item into one markup element:"
{ $markup-example
{ $list
"First item"
{ "Second item " { $emphasis "with emphasis" } }
}
}
} ;
2006-08-16 21:55:53 -04:00
HELP: $errors
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints the errors subheading found on the help page of some words. This section should document any errors thrown by the word." }
{ $examples
{ $markup-example { $errors "I/O errors, network errors, hardware errors... oh my!" } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $side-effects
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ string... }" } } }
{ $description "Prints a heading followed by a list of input values or variables which are modified by the word being documented." }
{ $examples
{ $markup-example
{ { $values { "seq" "a mutable sequence" } } { $side-effects "seq" } }
}
} ;
2006-08-16 21:55:53 -04:00
HELP: $notes
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints the errors subheading found on the help page of some words. This section should usage tips and pitfalls." } ;
2006-08-16 21:55:53 -04:00
HELP: $see
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ word }" } } }
{ $description "Prints the definition of " { $snippet "word" } " by calling " { $link see } "." }
{ $examples
{ $markup-example { "Here is a word definition:" { $see reverse } } }
} ;
2006-08-16 21:55:53 -04:00
HELP: $definition
2006-06-17 01:03:56 -04:00
{ $values { "word" "a word" } }
2006-06-16 23:12:40 -04:00
{ $description "Prints a heading followed by the definition of " { $snippet "word" } " by calling " { $link see } "." }
{ $notes
2006-06-17 01:03:56 -04:00
"This markup element is output by " { $link see-help } " but not " { $link help } "."
2006-06-16 23:12:40 -04:00
} ;
2006-08-16 21:55:53 -04:00
HELP: $curious
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element" } }
{ $description "Prints a heading followed by a markup element." }
{ $notes "This element type is used by the cookbook-style introductory articles in the " { $link "handbook" } "." } ;
2006-08-16 21:55:53 -04:00
HELP: $references
2006-06-16 23:12:40 -04:00
{ $values { "element" "a markup element of the form " { $snippet "{ topic... }" } } }
{ $description "Prints a heading followed by a series of links." }
{ $notes "This element type is used by the cookbook-style introductory articles in the " { $link "handbook" } "." } ;
2006-08-16 21:55:53 -04:00
HELP: sort-articles
2006-06-16 23:12:40 -04:00
{ $values { "seq" "a sequence of help article names and words" } { "assoc" "a new sequence of pairs" } }
{ $description "Constructs a key-sorted association list mapping article titles to help topics." } ;