racket/collects/setup/private/path-utils.rkt
Eli Barzilay 4da4a2759b New setup/path-to-relative' that supersedes unstable/dirs' and most of
`setup/private/path-utils'.

The API is a little different: instead of getting the alist and the
path, there's a curried function that gets the alist and produces a
function to do the substitutions.
2011-07-02 01:10:38 -04:00

21 lines
781 B
Racket

#lang scheme/base
(require setup/dirs setup/main-collects)
(provide doc-path)
;; user-doc-mode can be `false-if-missing' or `never'
(define (doc-path dir name flags [user-doc-mode #f])
(define (user-doc [sub #f])
(and (not (eq? 'never user-doc-mode))
(let ([d (find-user-doc-dir)])
(and (or (not (eq? 'false-if-missing user-doc-mode))
(directory-exists? d))
(if sub (build-path d sub) d)))))
(cond [(memq 'main-doc-root flags) (find-doc-dir)]
[(memq 'user-doc-root flags) (user-doc)]
[(memq 'user-doc flags) (user-doc name)]
[(or (memq 'main-doc flags) (pair? (path->main-collects-relative dir)))
(build-path (find-doc-dir) name)]
[else (build-path dir "doc" name)]))