diff --git a/basis/tools/vocabs/vocabs-docs.factor b/basis/tools/vocabs/vocabs-docs.factor index 33f197d0ea..98902f8fe6 100644 --- a/basis/tools/vocabs/vocabs-docs.factor +++ b/basis/tools/vocabs/vocabs-docs.factor @@ -73,3 +73,11 @@ HELP: set-vocab-tags HELP: all-vocabs { $values { "assoc" "an association list mapping vocabulary roots to sequences of vocabulary specifiers" } } { $description "Outputs an association list of all vocabularies which have been loaded or are available for loading." } ; + +HELP: load-all-under +{ $values { "prefix" string } } +{ $description "Load all vocabularies that match the provided prefix." } ; + +HELP: all-vocabs-under +{ $values { "prefix" string } } +{ $description "Return a sequence of vocab or vocab-links for each vocab matching the provided prefix. Unlike " { $link all-child-vocabs } " this word will return both loaded and unloaded vocabularies." } ; diff --git a/basis/tools/vocabs/vocabs-tests.factor b/basis/tools/vocabs/vocabs-tests.factor index 04e628d080..a4430c07bc 100644 --- a/basis/tools/vocabs/vocabs-tests.factor +++ b/basis/tools/vocabs/vocabs-tests.factor @@ -1,5 +1,5 @@ IN: tools.vocabs.tests -USING: tools.test tools.vocabs namespaces continuations ; +USING: continuations namespaces tools.test tools.vocabs tools.vocabs.private ; [ ] [ changed-vocabs get-global @@ -7,3 +7,6 @@ USING: tools.test tools.vocabs namespaces continuations ; [ t ] [ "kernel" changed-vocab? ] unit-test [ "kernel" changed-vocab ] [ changed-vocabs set-global ] [ ] cleanup ] unit-test + +[ t ] [ "some-vocab" valid-vocab-dirname ] unit-test +[ f ] [ ".git" valid-vocab-dirname ] unit-test diff --git a/basis/tools/vocabs/vocabs.factor b/basis/tools/vocabs/vocabs.factor index 4b9a72a443..7cd94827db 100644 --- a/basis/tools/vocabs/vocabs.factor +++ b/basis/tools/vocabs/vocabs.factor @@ -205,15 +205,21 @@ M: vocab-link summary vocab-summary ; : set-vocab-authors ( authors vocab -- ) dup vocab-authors-path set-vocab-file-contents ; -: subdirs ( dir -- dirs ) + + + +: vocab-subdirs ( dir -- dirs ) [ - [ link-info directory? ] filter + [ [ link-info directory? ] [ valid-vocab-dirname ] bi and ] filter ] with-directory-files natural-sort ; : (all-child-vocabs) ( root name -- vocabs ) [ vocab-dir append-path dup exists? - [ subdirs ] [ drop { } ] if + [ vocab-subdirs ] [ drop { } ] if ] keep [ swap [ "." glue ] with map ] unless-empty ; @@ -235,6 +241,11 @@ M: vocab-link summary vocab-summary ; dup [ "" vocabs-in-dir ] { } make ] { } map>assoc ; +: all-vocabs-under ( prefix -- vocabs ) + [ + vocab-roots get [ over vocabs-in-dir ] each drop + ] { } make ; + MEMO: all-vocabs-seq ( -- seq ) all-vocabs values concat ; @@ -252,6 +263,9 @@ MEMO: all-vocabs-seq ( -- seq ) : load-everything ( -- ) try-everything load-failures. ; +: load-all-under ( prefix -- ) + all-vocabs-under filter-unportable require-all load-failures. ; + : unrooted-child-vocabs ( prefix -- seq ) dup empty? [ CHAR: . suffix ] unless vocabs