vocabs.metadata: cleanup paths to be fully specified.

flac
John Benediktsson 2020-03-05 08:59:36 -08:00 committed by Steve Ayerhart
parent 761cf1a5dd
commit 685c3eae2c
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
6 changed files with 59 additions and 70 deletions

View 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 ;

View 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:" }

View 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

View 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 ;

View 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

View 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 -- ? )