racket/collects/unstable/scribblings/dirs.scrbl
Carl Eastlund d03aed44fd * unstable/srcloc.ss
Added `update-source-location', which provides keyword-based functional update
for source location representations.

Removed automatic collection-relative printing for source locations.

* unstable/location.ss

Made `quote-srcloc' and its related forms all automatically use source locations
relative to collections and/or planet, where appropriate, and to compute
source locations dynamically if they cannot be made relative.

Removed #:module-source argument from `quote-srcloc'.

Changed `quote-module-path' and `quote-module-name' to use source file name
extensions.

Removed `quote-module-source'.  I'm not sure what the use case is for
generating a resolved module path that doesn't correspond to a real module.

* unstable/dirs.ss

Implemented `path->directory-relative-string' for rendering a path to a string
that is relative to one of a list of given directories, with associated
abbreviations for each.

* unstable/scribblings/unstable.scrbl
* unstable/scribblings/srcloc.scrbl
* unstable/scribblings/dirs.scrbl

Documented the above changes.

* scheme/contract/private/provide.ss
* scheme/contract/private/base.ss

Changed contract forms to always blame a module path where appropriate.

Removed use of #:module-source option for `quote-srcloc'.

* setup/private/path-utils.ss

Updated `path->name' to use more general `path->directory-relative-string'.

svn: r18816
2010-04-14 17:49:29 +00:00

87 lines
2.9 KiB
Racket

#lang scribble/manual
@(require scribble/eval "utils.ss" (for-label scheme unstable/dirs))
@(define unsyntax #f)
@(define (new-evaluator)
(let* ([e (make-base-eval)])
(e '(require (for-syntax scheme/base)
unstable/dirs))
e))
@(define evaluator (new-evaluator))
@(define reference-path
'(lib "scribblings/reference/reference.scrbl"))
@title[#:tag "dirs"]{Directories}
@defmodule[unstable/dirs]
@unstable[@author+email["Carl Eastlund" "cce@ccs.neu.edu"]]
This library defines utilities dealing with the directory paths used by the
PLT Scheme distribution.
@defproc[(path->directory-relative-string
[path path-string?]
[#:default default any/c (if (path? path) (path->string path) path)]
[#:dirs dirs
(listof (cons/c (-> path?) any/c))
library-relative-directories])
(or/c string? (one-of/c default))]{
Produces a string rendering of @scheme[path], replacing distribution-specific
paths (normally: collections, user-installed collections, or PLanet cache) with
short abbreviations.
The set of paths and their abbreviations may be overridden by the
@scheme[#:dirs] option, which accepts an association list. Its keys must be
thunks which produce a path. Its values may be either @scheme[#f] for no
abbreviation (the directory prefix is simply omitted) or any other value to be
@scheme[display]ed in the output. For instance, @filepath{document.txt}
relative to a path abbreviated @scheme["path"] would be rendered as
@scheme["<path>/document.txt"].
If the path is not relative to one of the given directories, the default return
value is a string rendering of the unmodified path. This default may be
overridden by providing @scheme[default].
@defexamples[#:eval evaluator
(path->directory-relative-string
(build-path "source" "project.rkt"))
(path->directory-relative-string
(build-path (current-directory) "source" "project.rkt"))
(path->directory-relative-string
(build-path "/" "source" "project.rkt"))
(path->directory-relative-string
(build-path "/" "source" "project.rkt")
#:default #f)
(path->directory-relative-string
(build-path "/" "source" "project.rkt")
#:dirs (list
(cons (lambda () (build-path "/" "source"))
'src)))
]
}
@defthing[library-relative-directories (listof (cons (-> path?) any/c))]{
Represents the default directory substitutions for
@scheme[path->directory-relative-string]. By default, the collections directory
is replaced by @schemeresult[collects], the user-installed collections directory
is replaced by @schemeresult[user], and the PLaneT cache is replaced by
@schemeresult[planet].
}
@defthing[setup-relative-directories (listof (cons (-> path?) any/c))]{
Represents the directory substitutions used by @exec{setup-plt}. The
collections directory is omitted, the user-installed collections directory is
replaced by @schemeresult[user], and the PLaneT cache is replaced by
@schemeresult[planet].
}