From d892cb243e8b74377eae058ab431f5d1e796b1e1 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 28 Sep 2008 20:43:13 +0000 Subject: [PATCH] * Move the help functionality into the search collection, so it is not packaged with the mzscheme distribution * Make scheme/help throw a helpful message if the file is missing svn: r11896 --- .../help-autoload.ss => help/help-utils.ss} | 17 +++++++----- collects/scheme/help.ss | 26 ++++++++++++++++--- 2 files changed, 34 insertions(+), 9 deletions(-) rename collects/{scheme/private/help-autoload.ss => help/help-utils.ss} (88%) diff --git a/collects/scheme/private/help-autoload.ss b/collects/help/help-utils.ss similarity index 88% rename from collects/scheme/private/help-autoload.ss rename to collects/help/help-utils.ss index 0fb6813ab4..8e69e454cb 100644 --- a/collects/scheme/private/help-autoload.ss +++ b/collects/help/help-utils.ss @@ -1,15 +1,23 @@ #lang scheme/base +;; This file provides the utilities that mzscheme's `help' form uses. +;; It is required dynamically when used from mzscheme, to avoid the +;; loading overhead, and to have mzscheme independent of having the +;; documentation system. + (require setup/xref scribble/xref scribble/manual-struct - help/search net/uri-codec net/sendurl scheme/path - scheme/list) + scheme/list + "search.ss") -(provide find-help find-help/lib search-for) +(provide search-for find-help find-help/lib) + +(define (search-for strs) + (perform-search (apply string-append (add-between strs " ")))) (define-namespace-anchor anchor) @@ -62,6 +70,3 @@ (when anchor (printf " anchor: ~a\n" anchor)) (unless (send-url/file file #:fragment (and anchor (uri-encode anchor))) (error 'help "browser launch failed")))) - -(define (search-for strs) - (perform-search (apply string-append (add-between strs " ")))) diff --git a/collects/scheme/help.ss b/collects/scheme/help.ss index f8569728ee..da6966a0c4 100644 --- a/collects/scheme/help.ss +++ b/collects/scheme/help.ss @@ -39,10 +39,30 @@ (define (open-help-start) (find-help #'help)) +;; 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]) + (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)))))))) + (define-syntax-rule (define-help-autoload id) - (begin - (define auto (delay (dynamic-require 'scheme/private/help-autoload 'id))) - (define (id . args) (apply (force auto) args)))) + (define id + (let ([proc (delay (get-binding 'id))]) + (lambda args (apply (force proc) args))))) (define-help-autoload find-help) (define-help-autoload find-help/lib)