Skip to content

Commit 7b2d1ab

Browse files
committed
docs: revise language-family handling
Simplify language-family handling by having a `#lang` report just a family name, and `help/search` takes care of the rest based on `language-family` definitions in "info.rkt" files.
1 parent 4cb57af commit 7b2d1ab

File tree

9 files changed

+49
-87
lines changed

9 files changed

+49
-87
lines changed

drracket-core-lib/drracket/private/app.rkt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,10 @@
246246
[label (string-constant help-desk)]
247247
[parent button-panel]
248248
[callback (λ (x y)
249-
(define-values (query-table sub)
250-
(drracket:frame:try-to-find-a-query-table-and-sub
249+
(define fam
250+
(drracket:frame:try-to-find-a-language-family
251251
(drracket:frame:try-to-find-an-irl)))
252-
(help-desk:help-desk #:query-table query-table
253-
#:sub sub))])])
252+
(help-desk:help-desk #:language-family fam))])])
254253
(send docs-button focus))
255254
(send button-panel stretchable-height #f)
256255
(send button-panel set-alignment 'center 'center)

drracket-core-lib/drracket/private/frame.rkt

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,9 @@
771771
(define lang-name
772772
(cond
773773
[irl
774-
(define ht
775-
(call-read-language irl
776-
'documentation-language-family
777-
(hash)))
778-
(hash-ref ht 'doc-language-name default-lang-name)]
774+
(call-read-language irl
775+
'documentation-language-family
776+
"Racket")]
779777
[else default-lang-name]))
780778
(format (string-constant x-documentation) lang-name))
781779
(new menu-item%
@@ -786,9 +784,8 @@
786784
(send menu-item set-label (get-menu-item-label)))]
787785
[callback (λ (item evt)
788786
(define irl (maybe-get-irl))
789-
(define ht (call-read-language irl 'documentation-language-family (hash)))
790-
(help:help-desk #:sub (hash-ref ht 'doc-path "index.html")
791-
#:query-table (hash-ref ht 'doc-query (hash)))
787+
(define fam (call-read-language irl 'documentation-language-family "Racket"))
788+
(help:help-desk #:language-family fam)
792789
#t)]))
793790

794791
(define (drracket-help-menu:after-about menu dlg-parent)
@@ -822,16 +819,12 @@
822819
(and drr-frame
823820
(send (send (send drr-frame get-current-tab) get-defs) get-irl)))
824821

825-
;; (or/c #f irl) -> (values hash string)
826-
(define (try-to-find-a-query-table-and-sub irl)
827-
(define ht
828-
(if irl
829-
(call-read-language irl
830-
'documentation-language-family
831-
(hash))
832-
(hash)))
833-
(values (hash-ref ht 'doc-query (hash))
834-
(hash-ref ht 'doc-path "index.html"))))
822+
;; (or/c #f irl) -> string
823+
(define (try-to-find-a-language-family irl)
824+
(and irl
825+
(call-read-language irl
826+
'documentation-language-family
827+
#f))))
835828

836829

837830
(require (submod "." add-racket-to-path)

drracket-core-lib/drracket/private/help-desk.rkt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@
149149
(equal? choice 1))
150150

151151
(define (help-desk [key #f] [context #f] [parent #f]
152-
#:sub [sub #f]
153-
#:query-table [query-table (hash)])
152+
#:language-family [language-family #f])
154153
(when key (maybe-try-to-materialize-docs parent))
155-
(if key
156-
(perform-search key context #:query-table query-table)
157-
(send-main-page #:query-table query-table
158-
#:sub (or sub "index.html"))))
154+
(cond
155+
[key
156+
(perform-search key context #:language-family language-family)]
157+
[language-family
158+
(send-language-family-page language-family)]
159+
[else
160+
(send-main-page)]))

drracket-core-lib/drracket/private/in-irl-namespace.rkt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,7 @@
245245
(-> read-only-text/c exact-integer?
246246
string?)
247247
string?)))))]
248-
[(documentation-language-family)
249-
(hash/dc
250-
[key symbol?]
251-
[val (key)
252-
(case key
253-
[(doc-language-name) string?]
254-
[(doc-path) path-string?]
255-
[(doc-query) (hash/c symbol? string? #:immutable #t)]
256-
[else any/c])]
257-
#:immutable #t)]
248+
[(documentation-language-family) string?]
258249
[else
259250
(error 'key->contract "unknown key")]))
260251

drracket-core-lib/drracket/private/rep.rkt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ TODO
191191
(send (send (send frame get-current-tab) get-defs) get-irl)]
192192
[else
193193
(drracket:frame:try-to-find-an-irl)]))
194-
(define-values (query-table sub)
195-
(drracket:frame:try-to-find-a-query-table-and-sub irl))
194+
(define fam
195+
(drracket:frame:try-to-find-a-language-family irl))
196196
(cond
197197
[(is-a? obj text%)
198198
(define start (send obj get-start-position))
@@ -202,7 +202,7 @@ TODO
202202
(send obj get-text start end)))
203203
(cond
204204
[(or (not str) (equal? "" str))
205-
(drracket:help-desk:help-desk #:query-table query-table #:sub sub)]
205+
(drracket:help-desk:help-desk #:language-family fam)]
206206
[else
207207
(let* ([l (send obj get-canvas)]
208208
[l (and l (send l get-top-level-window))]
@@ -217,11 +217,9 @@ TODO
217217
[name (and l (send l get-language-name))])
218218
(drracket:help-desk:help-desk
219219
str (and ctxt (list ctxt name)) frame
220-
#:query-table query-table
221-
#:sub sub))])]
220+
#:language-family fam))])]
222221
[else
223-
(drracket:help-desk:help-desk #:query-table query-table
224-
#:sub sub)])))
222+
(drracket:help-desk:help-desk #:language-family fam)])))
225223

226224
;; keep this in case people use it in their keymaps
227225
(add-drs-function "execute" (λ (frame) (send frame execute-callback)))

drracket-core-lib/drracket/private/unit.rkt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@
233233
(string-append short-str "...")))
234234
menu
235235
(λ x
236-
(define-values (query-table sub)
237-
(drracket:frame:try-to-find-a-query-table-and-sub irl))
236+
(define fam
237+
(drracket:frame:try-to-find-a-language-family irl))
238238
(help-desk:help-desk str (list ctxt name)
239-
#:query-table query-table
240-
#:sub sub)))
239+
#:language-family fam)))
241240
(void)))))))
242241

243242
(define (filename->kind fn)

drracket-core-lib/drracket/tool-lib.rkt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,17 +933,17 @@ all of the names in the tools library, for use defining keybindings
933933
((or/c #f string?)
934934
(or/c #f string? (list/c string? string?))
935935
(or/c (is-a?/c frame%) (is-a?/c dialog%) #f)
936-
#:sub string?)
936+
#:language-family string?)
937937
any)
938938
(()
939939
((search-key #f)
940940
(search-context #f)
941941
(parent #f)
942-
(sub "index.html")))
942+
(language-family #f)))
943943
@{if @racket[search-key] is a string, performs a search in the docs with
944944
@racket[search-key] and @racket[search-context].
945-
Otherwise, calls @racket[send-main-page] with @racket[sub] as the
946-
@racket[#:sub] keyword argument.
945+
Otherwise, calls @racket[send-language-family-page]. The @racket[language-family]
946+
argument is passed along in either case.
947947

948948
The search may involve asking the user a question, in which case the
949949
dialog with the question uses @racket[parent] as its parent.

drracket-core/scribblings/tools/lang-tools.scrbl

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -585,45 +585,25 @@ find a prefix and extract the subsequent name:
585585

586586
When a language's @racket[_get-info] procedure (accessed via @racket[read-language])
587587
responds to the @racket['documentation-language-family]
588-
key, the information it provides is used to find documentation
589-
for the @tech[#:doc '(lib "scribblings/raco/raco.scrbl")]{language family}
590-
that the language is a part of. The response to that key should be a
591-
@tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{hash
592-
table} with certain known keys, such that those keys have to
593-
have specific kinds of values attached to them, but is
594-
allowed to have extra keys that are unconstrained (for
595-
better forwards compatibility). This is the contract:
596-
597-
@racketblock[
598-
(hash/dc
599-
[key symbol?]
600-
[val (key)
601-
(case key
602-
[(doc-language-name) string?]
603-
[(doc-path) path-string?]
604-
[(doc-query) (hash/c symbol? string? #:immutable #t)]
605-
[else any/c])]
606-
#:immutable #t)
607-
]
588+
key, the result is a string that names a language family. The
589+
language family should be defined as @racketidfont{language-family} in
590+
some collection's @filepath{info.rkt} file, and that definition
591+
configures a documentation entry point, a navigation configuration,
592+
and search precedence.
608593

609594
DrRacket uses the contents of this hash in three ways:
610595
@itemlist[
611596
@item{
612-
When typing “f1” (or right clicking) to search for
597+
When typing f1 (or right clicking) to search for
613598
documentation in DrRacket, DrRacket calls
614-
@racket[perform-search] and @racket[send-main-page] to
615-
summon browser-based documentation. If
616-
hash contains the @racket['doc-query] key, then the value
617-
associated with that key is supplied as the
618-
@racket[#:query-table] argument.}
619-
@item{If the hash maps the
620-
@racket['doc-language-name] to a string, then DrRacket uses that
621-
string in the first menu item in the @onscreen{Help} menu
599+
@racket[perform-search] or @racket[send-language-family-page] to
600+
summon browser-based documentation, and it passes
601+
along the language family.}
602+
@item{DrRacket uses the name in the first menu item in the @onscreen{Help} menu
622603
item, replacing the word “Racket” with the string in the hash.}
623-
@item{ When selecting that menu item, DrRacket visits the web
624-
page named by the @racket['doc-path] key. Specifically,
625-
DrRacket passes @racket['doc-path] as the @racket[#:sub]
626-
argument to @racket[send-main-page].
604+
@item{ When selecting that menu item, DrRacket visits the
605+
documentation page the language family by passing it
606+
along to @racket[send-language-family-page].
627607
}]
628608
}
629609

drracket-plugin-lib/drracket/private/drsig.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
add-keybindings-item
267267
planet-spec?
268268
try-to-find-an-irl
269-
try-to-find-a-query-table-and-sub))
269+
try-to-find-a-language-family))
270270

271271
(define-signature drracket:program-cm^
272272
(frame%))

0 commit comments

Comments
 (0)