]> gitweb.factorcode.org Git - factor.git/blob - core/vocabs/vocabs-docs.factor
328dce9b03a03049dbe81acb10e9476ee465a941
[factor.git] / core / vocabs / vocabs-docs.factor
1 USING: help.markup help.syntax strings words compiler.units ;
2 IN: vocabs
3
4 ARTICLE: "vocabularies" "Vocabularies"
5 "A " { $emphasis "vocabulary" } " is a named collection of words. Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
6 $nl
7 "Vocabularies are stored in a global hashtable:"
8 { $subsection dictionary }
9 "Vocabularies form a class."
10 { $subsection vocab }
11 { $subsection vocab? }
12 "Various vocabulary words are overloaded to accept a " { $emphasis "vocabulary specifier" } ", which is a string naming the vocabulary, the " { $link vocab } " instance itself, or a " { $link vocab-link } ":"
13 { $subsection vocab-link }
14 { $subsection >vocab-link }
15 "Looking up vocabularies by name:"
16 { $subsection vocab }
17 "Accessors for various vocabulary attributes:"
18 { $subsection vocab-name }
19 { $subsection vocab-main }
20 { $subsection vocab-help }
21 "Looking up existing vocabularies and creating new vocabularies:"
22 { $subsection vocab }
23 { $subsection child-vocabs }
24 { $subsection create-vocab }
25 "Getting words from a vocabulary:"
26 { $subsection vocab-words }
27 { $subsection words }
28 { $subsection all-words }
29 { $subsection words-named }
30 "Removing a vocabulary:"
31 { $subsection forget-vocab }
32 { $see-also "words" "vocabs.loader" } ;
33
34 ABOUT: "vocabularies"
35
36 HELP: dictionary
37 { $var-description "Holds a hashtable mapping vocabulary names to vocabularies." } ;
38
39 HELP: vocabs
40 { $values { "seq" "a sequence of strings" } }
41 { $description "Outputs a sequence of all defined vocabulary names." } ;
42
43 HELP: vocab
44 { $values { "vocab-spec" "a vocabulary specifier" } { "vocab" vocab } }
45 { $description "Outputs a named vocabulary, or " { $link f } " if no vocabulary with this name exists." }
46 { $class-description "Instances represent vocabularies." } ;
47
48 HELP: vocab-name
49 { $values { "vocab-spec" "a vocabulary specifier" } { "name" string } }
50 { $description "Outputs the name of a vocabulary." } ;
51
52 HELP: vocab-words
53 { $values { "vocab-spec" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } }
54 { $description "Outputs the words defined in a vocabulary." } ;
55
56 HELP: vocab-source-loaded?
57 { $values { "vocab-spec" "a vocabulary specifier" } { "?" "a boolean" } }
58 { $description "Outputs if the source for this vocubulary has been loaded." } ;
59
60 HELP: vocab-docs-loaded?
61 { $values { "vocab-spec" "a vocabulary specifier" } { "?" "a boolean" } }
62 { $description "Outputs if the documentation for this vocubulary has been loaded." } ;
63
64 HELP: words
65 { $values { "vocab" string } { "seq" "a sequence of words" } }
66 { $description "Outputs a sequence of words defined in the vocabulary, or " { $link f } " if no vocabulary with this name exists." } ;
67
68 HELP: all-words
69 { $values { "seq" "a sequence of words" } }
70 { $description "Outputs a sequence of all words in the dictionary." } ;
71
72 HELP: forget-vocab
73 { $values { "vocab" string } }
74 { $description "Removes a vocabulary. All words in the vocabulary are forgotten." }
75 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
76
77 HELP: load-vocab-hook
78 { $var-description "a quotation with stack effect " { $snippet "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functinality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
79
80 HELP: words-named
81 { $values { "str" string } { "seq" "a sequence of words" } }
82 { $description "Outputs a sequence of all words named " { $snippet "str" } " from the set of currently-loaded vocabularies." } ;
83
84 HELP: create-vocab
85 { $values { "name" string } { "vocab" vocab } }
86 { $description "Creates a new vocabulary if one does not exist with the given name, otherwise outputs an existing vocabulary." } ;
87
88 HELP: child-vocabs
89 { $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of strings" } }
90 { $description "Outputs all vocabularies which are conceptually under " { $snippet "vocab" } " in the hierarchy." }
91 { $examples
92     { $unchecked-example
93         "\"io.streams\" child-vocabs ."
94         "{\n    \"io.streams.c\"\n    \"io.streams.duplex\"\n    \"io.streams.lines\"\n    \"io.streams.nested\"\n    \"io.streams.plain\"\n    \"io.streams.string\"\n}"
95     }
96 } ;
97
98 HELP: vocab-link
99 { $class-description "Instances of this class identify vocabularies which are potentially not loaded. The " { $link vocab-name } " slot is the vocabulary name."
100 $nl
101 "Vocabulary links are created by calling " { $link >vocab-link } "."
102 } ;
103
104 HELP: >vocab-link
105 { $values { "name" string } { "vocab" "a vocabulary specifier" } }
106 { $description "If the vocabulary is loaded, outputs the corresponding " { $link vocab } " instance, otherwise creates a new " { $link vocab-link } "." } ;