racket-index: fix document links for layered installations

When a layer renders new documentation that refers to a previous
layer, the redirection script was not generated as needed to reach
the previous layer.

The documentation currently implements less sharing that would be
possible across layers. For each installation layer, `raco setup`
duplicates the documentation database in "docindex.sqlite", and it
duplicates the search index, and it duplicates the local-redirection
index. That duplication avoids having to join across an an arbitrary
number of SQLite databases or chain the search and local-redirection
indexes.
This commit is contained in:
Matthew Flatt 2021-05-19 08:09:29 -06:00
parent dfbb7040aa
commit a40bfc5204
5 changed files with 23 additions and 13 deletions

View File

@ -545,6 +545,10 @@ Optional @filepath{info.rkt} fields trigger additional actions by
@item{@racket['no-search] : Build the document without a search @item{@racket['no-search] : Build the document without a search
box.} box.}
@item{@racket['every-main-layer] : With @racket['main-doc],
indicates that the document should be rendered separately
at every installation layer (see @secref["layered-install"]).}
] ]
The @racket[_category] list specifies how to show the document in The @racket[_category] list specifies how to show the document in

View File

@ -1,10 +1,9 @@
#lang info #lang info
(define scribblings (define scribblings
'(("start.scrbl" '(("start.scrbl" (main-doc-root depends-all-main no-depend-on) (omit))
(main-doc-root depends-all-main no-depend-on) (omit)) ("search.scrbl" (depends-all-main no-depend-on every-main-layer) (omit) "search" 1 10)
("search.scrbl" (depends-all-main no-depend-on) (omit) "search" 1 10) ("local-redirect.scrbl" (depends-all-main no-depend-on every-main-layer) (omit) "local-redirect" 1 10)
("local-redirect.scrbl" (depends-all-main no-depend-on) (omit) "local-redirect" 1 10)
("license.scrbl" () (omit)) ("license.scrbl" () (omit))
("acks.scrbl" () (omit)) ("acks.scrbl" () (omit))
("release.scrbl" (depends-all-main no-depend-on) (omit)))) ("release.scrbl" (depends-all-main no-depend-on) (omit))))

View File

@ -284,7 +284,8 @@
[i (in-naturals)]) [i (in-naturals)])
(define name (extract-name e)) (define name (extract-name e))
(fprintf o (if (zero? i) "\n" ",\n")) (fprintf o (if (zero? i) "\n" ",\n"))
(fprintf o " [~s, ~s]" name (if user? (fprintf o " [~s, ~s]" name (if (or user?
(not (immediately-in-doc-dir? e)))
(url->string (path->url e)) (url->string (path->url e))
(format "../~a" name)))) (format "../~a" name))))
(fprintf o "];\n\n") (fprintf o "];\n\n")
@ -305,4 +306,8 @@
(js-addition (string->url "local-user-redirect.js")) (js-addition (string->url "local-user-redirect.js"))
(js-addition (js-addition
(string->bytes/utf-8 search-code)))) (string->bytes/utf-8 search-code))))
null))) null)))
(define (immediately-in-doc-dir? path)
(define-values (base name dir?) (split-path path))
(equal? (path->directory-path (find-doc-dir)) base))

View File

@ -23,12 +23,13 @@
(memq 'main-doc flags) (memq 'main-doc flags)
(pair? (path->main-collects-relative dir))) (pair? (path->main-collects-relative dir)))
(and main? (and main?
;; check for existing directory in search path before ;; check for existing directory in search path (unless
;; assuming the main doc directory ;; 'every-main-layer) before assuming the main doc directory
(or (for/or ([dir (get-doc-search-dirs)]) (or (and (not (memq 'every-main-layer flags))
(define p (build-path dir name)) (for/or ([dir (get-doc-extra-search-dirs)])
(and (directory-exists? p) (define p (build-path dir name))
p)) (and (directory-exists? p)
p)))
(build-path (find-doc-dir) name)))] (build-path (find-doc-dir) name)))]
[else [else
(and (not (eq? 'never user-doc-mode)) (and (not (eq? 'never user-doc-mode))

View File

@ -158,7 +158,8 @@
(define (scribblings-flag? sym) (define (scribblings-flag? sym)
(memq sym '(main-doc main-doc-root user-doc-root user-doc multi-page (memq sym '(main-doc main-doc-root user-doc-root user-doc multi-page
depends-all depends-all-main depends-all-user depends-all depends-all-main depends-all-user
no-depend-on always-run keep-style no-search))) no-depend-on always-run keep-style no-search
every-main-layer)))
(define (validate-scribblings-infos infos) (define (validate-scribblings-infos infos)
(define (validate path [flags '()] [cat '(library)] [name #f] [out-count 1] [order-hint 0]) (define (validate path [flags '()] [cat '(library)] [name #f] [out-count 1] [order-hint 0])
(and (string? path) (relative-path? path) (and (string? path) (relative-path? path)