diff --git a/basis/environment/environment.factor b/basis/environment/environment.factor index 492925c7c0..ca78c3efa7 100644 --- a/basis/environment/environment.factor +++ b/basis/environment/environment.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: assocs combinators kernel sequences splitting system -vocabs.loader ; +vocabs.loader init ; IN: environment HOOK: os-env os ( key -- value ) @@ -25,3 +25,8 @@ HOOK: (set-os-envs) os ( seq -- ) { [ os winnt? ] [ "environment.winnt" require ] } { [ os wince? ] [ ] } } cond + +[ + "FACTOR_ROOTS" os-env os windows? ";" ":" ? split + [ add-vocab-root ] each +] "environment" add-init-hook diff --git a/basis/help/tutorial/tutorial.factor b/basis/help/tutorial/tutorial.factor index afa16bbf8a..9ed36ac77c 100644 --- a/basis/help/tutorial/tutorial.factor +++ b/basis/help/tutorial/tutorial.factor @@ -13,6 +13,8 @@ $nl { $code "\"resource:work\" \"palindrome\" scaffold-vocab" } "If you look at the output, you will see that a few files were created in your ``work'' directory. The following phrase will print the full path of your work directory:" { $code "\"work\" resource-path ." } +"The work directory is one of several " { $link "vocabs.roots" } " where Factor searches for vocabularies. It is possible to define new vocabulary roots; see " { $link "add-vocab-roots" } ". To keep things simple in this tutorial, we'll just use the work directory, though." +$nl "Open the work directory in your file manager, and open the subdirectory named " { $snippet "palindrome" } ". Inside this subdirectory you will see a file named " { $snippet "palindrome.factor" } ". We will be editing this file." $nl "Notice that the file ends with an " { $link POSTPONE: IN: } " form telling Factor that all definitions in this source file should go into the " { $snippet "palindrome" } " vocabulary using the " { $link POSTPONE: IN: } " word:" diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index d658a8e033..bc57c48a62 100644 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -2,6 +2,18 @@ USING: vocabs vocabs.loader.private help.markup help.syntax words strings io ; IN: vocabs.loader +ARTICLE: "add-vocab-roots" "Working with code outside of the Factor source tree" +"You can work with code outside of the Factor source tree by adding additional directories to the list of vocabulary roots." +$nl +"There are three ways of doing this." +$nl +"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)." +$nl +"The second way is to create a configuration file. You can list additional vocabulary roots in a file that Factor reads at startup:" +{ $subsection "factor-roots" } +"Finally, you can add vocabulary roots dynamically using a word:" +{ $subsection add-vocab-root } ; + ARTICLE: "vocabs.roots" "Vocabulary roots" "The vocabulary loader searches for it in one of the root directories:" { $subsection vocab-roots } @@ -12,12 +24,8 @@ ARTICLE: "vocabs.roots" "Vocabulary roots" { { $snippet "extra" } " - additional contributed libraries." } { { $snippet "work" } " - a root for vocabularies which are not intended to be contributed back to Factor." } } -"You can store your own vocabularies in the " { $snippet "work" } " directory. You can also store code outside of the Factor source tree by making Factor aware of it first. There are two ways of doing this." -$nl -"You can list additional vocabulary roots in a file that Factor reads at startup:" -{ $subsection "factor-roots" } -"Or you can add them dynamically using a word:" -{ $subsection add-vocab-root } ; +"You can store your own vocabularies in the " { $snippet "work" } " directory." +{ $subsection "add-vocab-roots" } ; ARTICLE: "vocabs.loader" "Vocabulary loader" "The vocabulary loader is defined in the " { $vocab-link "vocabs.loader" } " vocabulary."