From a7bc240b3c03f6be3f6a758b3e221bcd2168fbc8 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 7 Jan 2014 14:09:10 -0700 Subject: [PATCH] setup/[main-]collects: doc and error-message repairs Closes PR 14222 --- .../racket-doc/scribblings/raco/setup.scrbl | 21 ++++++++++--------- racket/collects/setup/collects.rkt | 7 +++++-- racket/collects/setup/path-relativize.rkt | 9 ++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl index f1b3e1b592..f5d479eb4f 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl @@ -1315,7 +1315,9 @@ display such paths (e.g., in error messages). @defproc[(path->collects-relative [path path-string?] [#:cache cache (or/c #f (and/c hash? (not/c immutable?)))]) - (or/c path-string? (cons/c 'collects (listof bytes?)))]{ + (or/c path-string? + (cons/c 'collects + (cons/c bytes? (non-empty-listof bytes?))))]{ Checks whether @racket[path] (normalized by @racket[path->complete-path] and @racket[simplify-path] with @@ -1328,7 +1330,8 @@ The @racket[cache] argument is used with @racket[path->pkg], if needed.} @defproc[(collects-relative->path [rel (or/c path-string? - (list/c 'collects bytes? bytes? (listof bytes?)))]) + (cons/c 'collects + (cons/c bytes? (non-empty-listof bytes?))))]) path-string?]{ The inverse of @racket[path->collects-relative]: if @racket[rel] @@ -1348,7 +1351,7 @@ Like @racket[path->collects-relative], but the result is either @defmodule[setup/main-collects] @defproc[(path->main-collects-relative [path (or/c bytes? path-string?)]) - (or/c path? (cons/c 'collects (listof bytes?)))]{ + (or/c path? (cons/c 'collects (non-empty-listof bytes?)))]{ Checks whether @racket[path] has a prefix that matches the prefix to the main @filepath{collects} directory as determined by @@ -1366,16 +1369,14 @@ converted to a path using @racket[bytes->path]. See also @racket[collects-relative->path].} @defproc[(main-collects-relative->path - [rel (or/c bytes? path-string? - (cons/c 'collects (listof bytes?)))]) - path?]{ + [rel (or/c bytes? + path-string? + (cons/c 'collects (non-empty-listof bytes?)))]) + path>]{ The inverse of @racket[path->main-collects-relative]: if @racket[rel] is a pair that starts with @racket['collects], then it is converted -back to a path relative to @racket[(find-collects-dir)]. - -For historical reasons, if @racket[rel] is any kind of value other -than specified in the contract above, it is returned as-is.} +back to a path relative to @racket[(find-collects-dir)].} @subsection{Displaying Paths Relative to a Common Root} diff --git a/racket/collects/setup/collects.rkt b/racket/collects/setup/collects.rkt index 39b852d642..56b9e38280 100644 --- a/racket/collects/setup/collects.rkt +++ b/racket/collects/setup/collects.rkt @@ -86,6 +86,9 @@ [else (raise-argument-error 'collects-relative->path (format "~s" - '(or/c bytes? path-string? - (list/c 'collects bytes? bytes? (listof bytes?)))) + '(or/c bytes? + path-string? + (cons/c 'collects + (cons/c bytes? + (non-empty-listof bytes?))))) p)])) diff --git a/racket/collects/setup/path-relativize.rkt b/racket/collects/setup/path-relativize.rkt index a8d8fead55..ade83d09ac 100644 --- a/racket/collects/setup/path-relativize.rkt +++ b/racket/collects/setup/path-relativize.rkt @@ -30,8 +30,9 @@ (define path1 (cond [(bytes? path0) (bytes->path path0)] [(path-string? path0) path0] - [else (raise-type-error to-rel-name "path, string, or bytes" - path0)])) + [else (raise-argument-error to-rel-name + "(or/c path-string? bytes?)" + path0)])) (let loop ([path (explode-path* path1)] [root (force exploded-root)]) (cond [(not root) path0] [(null? root) (cons tag (map (lambda (pe) @@ -61,9 +62,9 @@ [(path? path) path] [(bytes? path) (bytes->path path)] [(string? path) (string->path path)] - [else (raise-type-error + [else (raise-argument-error from-rel-name - (format "path, string, bytes, or a list beginning with ~a" tag) + (format "(or/c path? bytes? (cons '~a (non-empty-listof bytes?)))" tag) path)])) (values path->relative relative->path))