]> gitweb.factorcode.org Git - factor.git/commitdiff
vocabs.metadata: cleanup paths to be fully specified.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 5 Mar 2020 16:59:36 +0000 (08:59 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 5 Mar 2020 16:59:36 +0000 (08:59 -0800)
basis/tools/deploy/config/editor/editor.factor
basis/tools/deploy/libraries/unix/unix.factor
basis/vocabs/files/files-docs.factor
basis/vocabs/files/files.factor
basis/vocabs/metadata/metadata-docs.factor
basis/vocabs/metadata/metadata.factor

index f4ef9cc2df4e5fe950b3b49cbca3ad2f77e1e381..c9ecac3b0a627f09e0ffa1f5fa91b1f8bdafb50a 100644 (file)
@@ -5,17 +5,17 @@ prettyprint.config sequences splitting tools.deploy.config
 vocabs.loader vocabs.metadata ;
 IN: tools.deploy.config.editor
 
-: deploy-config-path ( vocab -- string )
-    vocab-dir "deploy.factor" append-path ;
+: deploy-config-path ( vocab -- path/f )
+    "deploy.factor" vocab-file-path ;
 
 : deploy-config ( vocab -- assoc )
-    dup default-config swap
-    dup deploy-config-path vocab-file-lines
+    [ default-config ] keep
+    "deploy.factor" vocab-file-lines
     parse-fresh [ first assoc-union ] unless-empty ;
 
 : set-deploy-config ( assoc vocab -- )
     [ [ unparse-use ] without-limits string-lines ] dip
-    dup deploy-config-path set-vocab-file-lines ;
+    "deploy.factor" set-vocab-file-lines ;
 
 : set-deploy-flag ( value key vocab -- )
     [ deploy-config [ set-at ] keep ] keep set-deploy-config ;
index 73b95d38a9757a8c8035971d7eb5bfdee5bb0bf5..ca9c999ad110c8c7be573fef747cf6b650453c51 100644 (file)
@@ -6,9 +6,14 @@ IN: tools.deploy.libraries.unix
 
 ! stupid hack. better ways to find the library name would be open the library,
 ! note a symbol address found in the library, then call dladdr (or use
+
+<PRIVATE
+
 : ?exists ( path -- path/f )
     dup exists? [ drop f ] unless ; inline
 
+PRIVATE>
+
 M: unix find-library-file
     dup absolute-path? [ ?exists ] [
         { "/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" "resource:" }
index 7b44b56dbb7ce6e1493e6b9d72cbc0662d6c0023..a2c523e650f27ee5feb811e021a538992d9607df 100644 (file)
@@ -2,19 +2,15 @@ USING: help.markup help.syntax literals sequences strings ;
 IN: vocabs.files
 
 HELP: vocab-tests-path
-{ $values { "vocab" "a vocabulary specifier" } { "path" "pathname string to test file" } }
+{ $values { "vocab" "a vocabulary specifier" } { "path/f" { $maybe "pathname string to test file" } } }
 { $description "Outputs a pathname where the unit test file for " { $snippet "vocab" } " is located. Outputs " { $link f } " if the vocabulary does not have a directory on disk." } ;
 
-HELP: vocab-tests-file
-{ $values { "vocab" "a vocabulary specifier" } { "path/f" "pathname string to test file" } }
-{ $description "Outputs a pathname where the unit test file is located, or " { $link f } " if the file does not exist." } ;
-
 HELP: vocab-tests-dir
 { $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } }
 { $description "Outputs a sequence of pathnames for the tests in the test directory." } ;
 
 HELP: vocab-files
-{ $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of pathname strings" } }
+{ $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } }
 { $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." }
 { $examples
   { $example
@@ -33,7 +29,7 @@ HELP: vocab-files
 } ;
 
 HELP: vocab-tests
-{ $values { "vocab" "a vocabulary specifier" } { "tests" "a sequence of pathname strings" } }
+{ $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } }
 { $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." }
 { $examples
   { $example
index c9a828ac199490a4d169e8d770bc3ed9766e3259..33af6889c7b06a8048f863325b0d7e8be24ea30d 100644 (file)
@@ -1,33 +1,31 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io.directories io.files io.pathnames kernel make
-sequences vocabs vocabs.loader ;
+USING: combinators io.directories io.files io.pathnames kernel
+make sequences vocabs.loader ;
 IN: vocabs.files
 
-: vocab-tests-path ( vocab -- path )
+: vocab-tests-path ( vocab -- path/f )
     dup "-tests.factor" append-vocab-dir vocab-append-path ;
 
-: vocab-tests-file ( vocab -- path/f )
-    vocab-tests-path dup
-    [ dup exists? [ drop f ] unless ] [ drop f ] if ;
-
 : vocab-tests-dir ( vocab -- paths )
-    dup vocab-dir "tests" append-path vocab-append-path dup [
+    dup vocab-dir "tests" append-path vocab-append-path [
         dup exists? [
             dup directory-files [ ".factor" tail? ] filter
             [ append-path ] with map
         ] [ drop f ] if
-    ] [ drop f ] if ;
+    ] [ f ] if* ;
 
-: vocab-tests ( vocab -- tests )
+: vocab-tests ( vocab -- paths )
     [
-        [ vocab-tests-file [ , ] when* ]
-        [ vocab-tests-dir [ % ] when* ] bi
+        [ vocab-tests-path [ dup exists? [ , ] [ drop ] if ] when* ]
+        [ vocab-tests-dir % ] bi
     ] { } make ;
 
-: vocab-files ( vocab -- seq )
+: vocab-files ( vocab -- paths )
     [
-        [ vocab-source-path [ , ] when* ]
-        [ vocab-docs-path [ , ] when* ]
-        [ vocab-tests % ] tri
+        {
+            [ vocab-source-path [ , ] when* ]
+            [ vocab-docs-path [ , ] when* ]
+            [ vocab-tests % ]
+        } cleave
     ] { } make ;
index 9081619e6cb0af2ef8add86d4da97446992b3811..f24144f850037303178f061c0a70e12361cd59a4 100644 (file)
@@ -3,32 +3,20 @@ IN: vocabs.metadata
 
 ARTICLE: "vocabs.metadata" "Vocabulary metadata"
 "Vocabulary directories can contain text files with metadata:"
-{ $list
-    { { $snippet "authors.txt" } " - a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." }
-    { { $snippet "platforms.txt" } " - a series of lines, with one operating system name per line." }
-    { { $snippet "resources.txt" } " - a series of lines, with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." }
-    { { $snippet "summary.txt" } " - a one-line description." }
-    { { $snippet "tags.txt" } " - a series of lines, with one tag per line. Tags help classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." }
+{ $table
+    { { $snippet "authors.txt" } { "a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." } }
+    { { $snippet "platforms.txt" } { "a series of lines, with one operating system name per line." } }
+    { { $snippet "resources.txt" } { "a series of lines, with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." } }
+    { { $snippet "summary.txt" } { "a one-line description." } }
+    { { $snippet "tags.txt" } { "a series of lines, with one tag per line. Tags help classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } }
 }
-"Words for reading " { $snippet "summary.txt" } ":"
-{ $subsections
-    vocab-summary
-}
-"Words for reading " { $snippet "authors.txt" } ":"
+"These metadata files can be accessed with the following words:"
 { $subsections
     vocab-authors
-}
-"Words for reading " { $snippet "tags.txt" } ":"
-{ $subsections
-    vocab-tags
-}
-"Words for reading " { $snippet "platforms.txt" } ":"
-{ $subsections
     vocab-platforms
-}
-"Words for reading " { $snippet "resources.txt" } ":"
-{ $subsections
     vocab-resources
+    vocab-summary
+    vocab-tags
 }
 "Getting and setting arbitrary vocabulary metadata:"
 { $subsections
index b20e055f83f894bfcaf0fe73b1aae330e085fcf8..044447878c2288b32df04ebbfd38053d64286981 100644 (file)
@@ -1,17 +1,20 @@
 ! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs classes.algebra
+USING: accessors assocs classes.algebra
 combinators.short-circuit continuations io.directories
 io.encodings.utf8 io.files io.pathnames kernel make math.parser
-memoize namespaces sequences sets summary system vocabs
-vocabs.loader words ;
+memoize namespaces sequences summary system vocabs vocabs.loader
+words ;
 IN: vocabs.metadata
 
 : check-vocab ( vocab -- vocab )
     dup find-vocab-root [ no-vocab ] unless ;
 
+: vocab-file-path ( vocab name -- path/f )
+    [ dup vocab-dir ] [ append-path ] bi* vocab-append-path ;
+
 MEMO: vocab-file-lines ( vocab name -- lines/f )
-    vocab-append-path dup [
+    vocab-file-path dup [
         dup exists? [
             utf8 file-lines harvest
         ] [
@@ -20,23 +23,22 @@ MEMO: vocab-file-lines ( vocab name -- lines/f )
     ] when ;
 
 : set-vocab-file-lines ( lines vocab name -- )
-    dupd vocab-append-path [
+    dupd vocab-file-path [
         swap [ ?delete-file ] [ swap utf8 set-file-lines ] if-empty
         \ vocab-file-lines reset-memoized
     ] [ vocab-name no-vocab ] ?if ;
 
-: vocab-resources-path ( vocab -- string )
-    vocab-dir "resources.txt" append-path ;
+: vocab-resources-path ( vocab -- path/f )
+    "resources.txt" vocab-file-path ;
 
 : vocab-resources ( vocab -- patterns )
-    dup vocab-resources-path vocab-file-lines ;
+    "resources.txt" vocab-file-lines ;
 
-: vocab-summary-path ( vocab -- string )
-    vocab-dir "summary.txt" append-path ;
+: vocab-summary-path ( vocab -- path/f )
+    "summary.txt" vocab-file-path ;
 
 : vocab-summary ( vocab -- summary )
-    dup dup vocab-summary-path vocab-file-lines
-    [
+    dup "summary.txt" vocab-file-lines [
         vocab-name " vocabulary" append
     ] [
         nip first
@@ -52,25 +54,25 @@ M: vocab summary
 
 M: vocab-link summary vocab-summary ;
 
-: vocab-tags-path ( vocab -- string )
-    vocab-dir "tags.txt" append-path ;
+: vocab-tags-path ( vocab -- path/f )
+    "tags.txt" vocab-file-path ;
 
 : vocab-tags ( vocab -- tags )
-    dup vocab-tags-path vocab-file-lines ;
+    "tags.txt" vocab-file-lines ;
 
-: vocab-authors-path ( vocab -- string )
-    vocab-dir "authors.txt" append-path ;
+: vocab-authors-path ( vocab -- path/f )
+    "authors.txt" vocab-file-path ;
 
 : vocab-authors ( vocab -- authors )
-    dup vocab-authors-path vocab-file-lines ;
+    "authors.txt" vocab-file-lines ;
 
-: vocab-platforms-path ( vocab -- string )
-    vocab-dir "platforms.txt" append-path ;
+: vocab-platforms-path ( vocab -- path/f )
+    "platforms.txt" vocab-file-path ;
 
 ERROR: bad-platform name ;
 
 : vocab-platforms ( vocab -- platforms )
-    dup vocab-platforms-path vocab-file-lines
+    "platforms.txt" vocab-file-lines
     [ dup "system" lookup-word [ ] [ bad-platform ] ?if ] map ;
 
 : supported-platform? ( platforms -- ? )