Skip to content

Commit 7e635db

Browse files
committed
doc search: fill in PLT_Root query
Whenever a specific entry point into documentation is given, set `PLT_Root` to point to the first point in the doc-search path, as long as "index.html" exists there. This fixes two problems: the given entry point probably doesn't set `PLT_Root` for further searching, and it may not be in user scope while other documentation is in user scope.
1 parent 1a7d579 commit 7e635db

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

scribble-lib/help/search.rkt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
null)
5959
query-table-list-of-pairs)])))]
6060
[else
61-
(define path (or (for/or ([dir (in-list (get-doc-search-dirs))])
61+
(define doc-dirs (get-doc-search-dirs))
62+
(define path (or (for/or ([dir (in-list doc-dirs)])
6263
(define path (build-path dir sub))
6364
(and (file-exists? path)
6465
path))
@@ -70,12 +71,23 @@
7071
#f
7172
(substring (url->string (url #f #f #f #f #f (list) query-table-list-of-pairs #f))
7273
1)))
73-
(define combined-query
74+
(define combined-base-query
7475
(cond
7576
[(and query parsed-query-table)
7677
(string-append query "&" parsed-query-table)]
7778
[else
7879
(or query parsed-query-table)]))
80+
(define combined-query
81+
(cond
82+
[(and (not (equal? sub "index.html"))
83+
(pair? doc-dirs)
84+
(file-exists? (build-path (car doc-dirs) "index.html")))
85+
;; the entry point may or may not try to set `PLT_Root` itself
86+
(define root (format "PLT_Root=~a" (uri-encode (path->string (path->directory-path (car doc-dirs))))))
87+
(if combined-base-query
88+
(string-append combined-base-query "&" root)
89+
root)]
90+
[else combined-base-query]))
7991
(cond
8092
[(file-exists? path) (send-url/file path #:fragment fragment #:query combined-query)]
8193
[else

0 commit comments

Comments
 (0)