change 'help' to open the main doc page instead of the docs for 'help' itself
svn: r13004
This commit is contained in:
parent
206553c816
commit
821a82195e
|
@ -14,7 +14,7 @@
|
|||
scheme/list
|
||||
"search.ss")
|
||||
|
||||
(provide search-for find-help find-help/lib)
|
||||
(provide search-for find-help find-help/lib go-to-main-page)
|
||||
|
||||
(define (search-for strs)
|
||||
(perform-search (apply string-append (add-between strs " "))))
|
||||
|
@ -64,9 +64,15 @@
|
|||
(printf " ~a\n" (car libs)))
|
||||
(loop (cdr libs))))))))
|
||||
|
||||
(define (report-sending-browser file)
|
||||
(printf "Sending to web browser...\n file: ~a\n" file))
|
||||
|
||||
(define (go-to-main-page)
|
||||
(send-main-page #:notify report-sending-browser))
|
||||
|
||||
(define (go-to-tag xref t)
|
||||
(let-values ([(file anchor) (xref-tag->path+anchor xref t)])
|
||||
(printf "Sending to web browser...\n file: ~a\n" file)
|
||||
(report-sending-browser file)
|
||||
(when anchor (printf " anchor: ~a\n" anchor))
|
||||
(unless (send-url/file file #:fragment (and anchor (uri-encode anchor)))
|
||||
(error 'help "browser launch failed"))))
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
;; using javascript.
|
||||
|
||||
(define (send-main-page #:sub [sub "index.html"]
|
||||
#:fragment [fragment #f] #:query [query #f])
|
||||
#:fragment [fragment #f] #:query [query #f]
|
||||
#:notify [notify void])
|
||||
(let* ([path (build-path (find-user-doc-dir) sub)]
|
||||
[path (if (file-exists? path) path (build-path (find-doc-dir) sub))])
|
||||
(notify path)
|
||||
(send-url/file path #:fragment fragment #:query query)))
|
||||
|
||||
;; This is an example of changing this code to use the online manuals.
|
||||
|
|
|
@ -33,31 +33,34 @@
|
|||
(raise-syntax-error
|
||||
#f
|
||||
(string-append "expects a single identifer, a #:from clause, or a"
|
||||
" #:search clause; try just `help' for more information")
|
||||
" #:search clause; try `(help help)' for more information")
|
||||
stx)])))
|
||||
|
||||
(define (open-help-start)
|
||||
(find-help #'help))
|
||||
(go-to-main-page))
|
||||
|
||||
;; Autoload utilities from help/help-utils; if it does not exists,
|
||||
;; suggest using docs.plt-scheme.org.
|
||||
|
||||
(define-namespace-anchor anchor)
|
||||
(define get-binding
|
||||
(let ([ns #f] [utils #f])
|
||||
(let ([ns #f])
|
||||
(lambda (sym)
|
||||
(unless ns
|
||||
(set! ns (namespace-anchor->empty-namespace anchor))
|
||||
(set! utils (resolved-module-path-name
|
||||
(module-path-index-resolve
|
||||
(module-path-index-join 'help/help-utils #f)))))
|
||||
(parameterize ([current-namespace ns])
|
||||
(if (file-exists? utils)
|
||||
(dynamic-require utils sym)
|
||||
(lambda _
|
||||
(error 'help "documentation system unavailable; ~a\n~a"
|
||||
"try http://docs.plt-scheme.org/"
|
||||
(format " (missing file: ~a)" utils))))))))
|
||||
(set! ns (namespace-anchor->empty-namespace anchor)))
|
||||
(with-handlers ([exn:fail?
|
||||
(lambda (exn)
|
||||
((error-display-handler)
|
||||
(if (exn? exn)
|
||||
(exn-message exn)
|
||||
(format "~s" exn))
|
||||
exn)
|
||||
(raise-user-error
|
||||
'help
|
||||
(string-append
|
||||
"documentation system unavailable; "
|
||||
"try http://docs.plt-scheme.org/")))])
|
||||
(dynamic-require 'help/help-utils sym)))))
|
||||
|
||||
(define-syntax-rule (define-help-autoload id)
|
||||
(define id
|
||||
|
@ -67,3 +70,4 @@
|
|||
(define-help-autoload find-help)
|
||||
(define-help-autoload find-help/lib)
|
||||
(define-help-autoload search-for)
|
||||
(define-help-autoload go-to-main-page)
|
||||
|
|
|
@ -32,7 +32,8 @@ browser (using the user's selected browser) to display the results.
|
|||
@margin-note{See @schememodname[net/sendurl] for information on how
|
||||
the user's browser is launched to display help information.}
|
||||
|
||||
A simple @scheme[help] or @scheme[(help)] form opens this page.
|
||||
A simple @scheme[help] or @scheme[(help)] form opens the main
|
||||
documentation page.
|
||||
|
||||
A @scheme[(help id)] form looks for documentation specific to the
|
||||
current binding of @scheme[id]. For example,
|
||||
|
|
Loading…
Reference in New Issue
Block a user