]> gitweb.factorcode.org Git - factor.git/blob - core/vocabs/loader/loader-docs.factor
Make -roots=<paths> known to the documentation
[factor.git] / core / vocabs / loader / loader-docs.factor
1 USING: vocabs vocabs.loader.private help.markup help.syntax
2 words hashtables ;
3 IN: vocabs.loader
4
5 ARTICLE: "add-vocab-roots" "Working with code outside of the Factor source tree"
6 "You can work with code outside of the Factor source tree by adding additional directories to the list of vocabulary roots."
7 $nl
8 "There are four ways of doing this:"
9 $nl
10 "The first way is to use an environment variable. Factor looks at the " { $snippet "FACTOR_ROOTS" } " environment variable for a list of " { $snippet ":" } "-separated paths (on Unix) or a list of " { $snippet ";" } "-separated paths (on Windows)."
11 $nl
12 "The second way is to use the " { $snippet "-roots=" } " command-line argument. The format is the same as for the environment variable."
13 $nl
14 "The third way is to create a configuration file. You can list additional vocabulary roots in a file that Factor reads at startup:"
15 { $subsections ".factor-roots" }
16 "Finally, you can add vocabulary roots by calling a word from your " { $snippet ".factor-rc" } " file (see " { $link ".factor-rc" } "):"
17 { $subsections add-vocab-root } ;
18
19 ARTICLE: "vocabs.roots" "Vocabulary roots"
20 "The vocabulary loader searches for vocabularies in one of the root directories:"
21 { $subsections vocab-roots }
22 "The default set of roots includes the following directories in the Factor source directory:"
23 { $list
24     { { $snippet "core" } " - essential system vocabularies such as " { $vocab-link "parser" } " and " { $vocab-link "sequences" } ". The vocabularies in this root constitute the boot image; see " { $link "bootstrap.image" } "." }
25     { { $snippet "basis" } " - useful libraries and tools, such as " { $vocab-link "compiler" } ", " { $vocab-link "ui" } ", " { $vocab-link "calendar" } ", and so on." }
26     { { $snippet "extra" } " - additional contributed libraries." }
27     { { $snippet "work" } " - a root for vocabularies which are not intended to be contributed back to Factor." }
28 }
29 "You can store your own vocabularies in the " { $snippet "work" } " directory."
30 { $subsections "add-vocab-roots" } ;
31
32 ARTICLE: "vocabs.icons" "Vocabulary icons"
33 "An icon file representing the vocabulary can be provided for use by " { $link "tools.deploy" } ". If any of the following files exist inside the vocabulary directory, they will be used as icons when the application is deployed."
34 { $list
35     { { $snippet "icon.ico" } " on Windows and Linux" }
36     { { $snippet "icon.icns" } " on MacOS X" }
37     { { $snippet "icon.png" } " on Linux" }
38 }
39 "The icon file will be embedded in the vocab's image file." ;
40
41 ARTICLE: "vocabs.loader" "Vocabulary loader"
42 "The " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " words load vocabularies using the vocabulary loader. The vocabulary loader is implemented in the " { $vocab-link "vocabs.loader" } " vocabulary."
43 $nl
44 "The vocabulary loader searches for vocabularies in a set of directories known as vocabulary roots."
45 { $subsections "vocabs.roots" }
46 "Vocabulary names map directly to source files inside these roots. A vocabulary named " { $snippet "foo.bar" } " is defined in " { $snippet "foo/bar/bar.factor" } "; that is, a source file named " { $snippet "bar.factor" } " within a " { $snippet "bar" } " directory nested inside a " { $snippet "foo" } " directory of a vocabulary root. Any level of nesting, separated by dots, is permitted."
47 $nl
48 "The vocabulary directory - " { $snippet "bar" } " in our example - contains a source file:"
49 { $list
50   { { $snippet "foo/bar/bar.factor" } " - the source file must define words in the " { $snippet "foo.bar" } " vocabulary with an " { $snippet "IN: foo.bar" } " form" }
51 }
52 "Two other Factor source files, storing documentation and tests, respectively, may optionally be placed alongside the source file:"
53 { $list
54     { { $snippet "foo/bar/bar-docs.factor" } " - documentation, see " { $link "writing-help" } }
55     { { $snippet "foo/bar/bar-tests.factor" } " - unit tests, see " { $link "tools.test" } }
56 }
57 "Optional text files may contain metadata."
58 { $subsections "vocabs.metadata" "vocabs.icons" }
59 "Vocabularies can also be loaded at run time, without altering the vocabulary search path. This is done by calling a word which loads a vocabulary if it is not in the image, doing nothing if it is:"
60 { $subsections require }
61 "The above word will only ever load a vocabulary once in a given session. Sometimes, two vocabularies require special code to interact. The following word is used to load one vocabulary when another is present:"
62 { $subsections require-when }
63 "There is another word which unconditionally loads vocabulary from disk, regardless of whether or not is has already been loaded:"
64 { $subsections reload }
65 "For interactive development in the listener, calling " { $link reload } " directly is usually not necessary, since a better facility exists for " { $link "vocabs.refresh" } "."
66 $nl
67 "Application vocabularies can define a main entry point, giving the user a convenient way to run the application:"
68 { $subsections
69     POSTPONE: MAIN:
70     run
71     runnable-vocab
72 }
73 { $see-also "vocabularies" "parser" "source-files" } ;
74
75 ABOUT: "vocabs.loader"
76
77 HELP: load-vocab
78 { $values { "name" "a string" } { "vocab" { $maybe hashtable } } }
79 { $description "Attempts to load a vocabulary from disk, or looks up the vocabulary in the dictionary, and then outputs that vocabulary object." } ;
80
81 HELP: vocab-main
82 { $values { "vocab-spec" "a vocabulary specifier" } { "main" word } }
83 { $description "Outputs the main entry point for a vocabulary. The entry point can be executed with " { $link run } " and set with " { $link POSTPONE: MAIN: } "." } ;
84
85 HELP: vocab-roots
86 { $var-description "A sequence of pathname strings to search for vocabularies." } ;
87
88 HELP: add-vocab-root
89 { $values { "root" "a pathname string" } }
90 { $description "Adds a directory pathname to the list of vocabulary roots." }
91 { $see-also ".factor-roots" add-vocab-root-hook } ;
92
93 HELP: add-vocab-root-hook
94 { $var-description "A quotation that is run when a vocab root is added." }
95 { $see-also add-vocab-root } ;
96
97 HELP: find-vocab-root
98 { $values { "vocab" "a vocabulary specifier" } { "path/f" "a pathname string" } }
99 { $description "Searches for a vocabulary in the vocabulary roots." } ;
100
101 HELP: no-vocab
102 { $values { "name" "a vocabulary name" } }
103 { $description "A " { $link no-vocab } " error tuple. Call " { $link no-vocab } " to throw it." }
104 { $error-description "Thrown when a " { $link POSTPONE: USE: } " or " { $link POSTPONE: USING: } " form refers to a non-existent vocabulary." } ;
105
106 HELP: load-help?
107 { $var-description "If set to a true value, documentation will be automatically loaded when vocabularies are loaded. This variable is usually on, except when Factor has been bootstrapped without the help system." } ;
108
109 HELP: load-source
110 { $values { "vocab" "a vocabulary specifier" } }
111 { $description "Loads a vocabulary's source code." } ;
112
113 HELP: load-docs
114 { $values { "vocab" "a vocabulary specifier" } }
115 { $description "If " { $link load-help? } " is on, loads a vocabulary's documentation." } ;
116
117 HELP: reload
118 { $values { "name" "a vocabulary name" } }
119 { $description "Reloads the source code and documentation for a vocabulary." }
120 { $errors "Throws a " { $link no-vocab } " error if the vocabulary does not exist on disk." } ;
121
122 HELP: require-when
123 { $values { "if" { $sequence "vocabulary specifiers" } } { "then" "a vocabulary specifier" } }
124 { $description "Loads the " { $snippet "then" } " vocabulary if it is not loaded and all of the " { $snippet "if" } " vocabulary is. If some of the " { $snippet "if" } " vocabularies are not loaded now, but they are later, then the " { $snippet "then" } " vocabulary will be loaded along with the final one." }
125 { $notes "This is used to express a joint dependency of vocabularies. If vocabularies " { $snippet "a" } " and " { $snippet "b" } " use code in vocabulary " { $snippet "c" } " to interact, then the following line, which can be placed in " { $snippet "a" } " or " { $snippet "b" } ", expresses the dependency."
126 { $code "{ \"a\" \"b\" } \"c\" require-when" } } ;
127
128 HELP: run
129 { $values { "vocab" "a vocabulary specifier" } }
130 { $description "Runs a vocabulary's main entry point. The main entry point is set with the " { $link POSTPONE: MAIN: } " parsing word." } ;
131
132 HELP: vocab-source-path
133 { $values { "vocab" "a vocabulary specifier" } { "path/f" { $maybe "a pathname string" } } }
134 { $description "Outputs a pathname where source code for " { $snippet "vocab" } " might be found. Outputs " { $link f } " if the vocabulary does not have a known directory on disk." } ;
135
136 HELP: vocab-docs-path
137 { $values { "vocab" "a vocabulary specifier" } { "path/f" { $maybe "a pathname string" } } }
138 { $description "Outputs a pathname where the documentation for " { $snippet "vocab" } " might be found. Outputs " { $link f } " if the vocabulary does not have a directory on disk." } ;