From 821a82195e6947a96a97df0f7928e0ba0f799247 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 4 Jan 2009 23:15:50 +0000 Subject: [PATCH] change 'help' to open the main doc page instead of the docs for 'help' itself svn: r13004 --- collects/help/help-utils.ss | 10 +++++-- collects/help/search.ss | 4 ++- collects/scheme/help.ss | 32 +++++++++++++---------- collects/scribblings/reference/help.scrbl | 3 ++- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/collects/help/help-utils.ss b/collects/help/help-utils.ss index 8e69e454cb..0388c69432 100644 --- a/collects/help/help-utils.ss +++ b/collects/help/help-utils.ss @@ -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")))) diff --git a/collects/help/search.ss b/collects/help/search.ss index c7e15cbf61..b83c3c3db2 100644 --- a/collects/help/search.ss +++ b/collects/help/search.ss @@ -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. diff --git a/collects/scheme/help.ss b/collects/scheme/help.ss index da6966a0c4..dba69b06e3 100644 --- a/collects/scheme/help.ss +++ b/collects/scheme/help.ss @@ -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) diff --git a/collects/scribblings/reference/help.scrbl b/collects/scribblings/reference/help.scrbl index 1d2b11a3fc..b98f6f070f 100644 --- a/collects/scribblings/reference/help.scrbl +++ b/collects/scribblings/reference/help.scrbl @@ -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,