diff --git a/collects/file/gif.ss b/collects/file/gif.ss index a9938f423d..526ffb39bc 100644 --- a/collects/file/gif.ss +++ b/collects/file/gif.ss @@ -573,7 +573,7 @@ Given a set of pixels expressed in ARGB format (i.e., each four bytes is a set of values for one pixel: alpha, red, blue, and - green),@scheme[quantize] produces produces + green), @scheme[quantize] produces produces @(itemize @item{bytes for the image (i.e., a array of colors, expressed as a byte string)} diff --git a/collects/scribble/extract.ss b/collects/scribble/extract.ss index 1d51a912c6..66380c7888 100644 --- a/collects/scribble/extract.ss +++ b/collects/scribble/extract.ss @@ -5,9 +5,12 @@ scribble/srcdoc (for-syntax scheme/base scheme/path - syntax/path-spec)) + syntax/path-spec + (for-syntax scheme/base))) -(provide include-extracted) +(provide include-extracted + provide-extracted + include-previously-extracted) (define-for-syntax (strip-context c) (cond @@ -19,72 +22,124 @@ (strip-context (cdr c)))] [else c])) +(define-for-syntax (extract orig-path stx) + (let ([path (resolve-path-spec orig-path orig-path stx)]) + (let ([s-exp + (parameterize ([current-namespace (make-base-namespace)] + [read-accept-reader #t] + [current-load-relative-directory + (path-only path)]) + (expand + (with-input-from-file path + (lambda () + (port-count-lines! (current-input-port)) + (read-syntax path)))))]) + (syntax-case s-exp () + [(mod name lang + (mod-beg + content ...)) + (with-syntax ([((content id) ...) + (apply + append + (map (lambda (c) + (syntax-case c (#%plain-app void quote-syntax provide/doc) + [(#%plain-app void (quote-syntax (provide/doc spec ...))) + (syntax->list #'(spec ...))] + [_ null])) + (syntax->list #'(content ...))))] + [(req ...) + (map + strip-context + (apply + append + (map (lambda (c) + (syntax-case c (#%require #%plain-app void quote-syntax require/doc) + [(#%require spec ...) + (let loop ([specs (syntax->list #'(spec ...))]) + (cond + [(null? specs) '()] + [else (let ([spec (car specs)]) + (syntax-case spec (for-syntax for-meta) + [(for-syntax . spec) (loop (cdr specs))] + [(for-meta . spec) (loop (cdr specs))] + [(for-template . spec) (loop (cdr specs))] + [(for-label . spec) (loop (cdr specs))] + [(just-meta . spec) (loop (cdr specs))] + [_ (cons #`(for-label #,spec) (loop (cdr specs)))]))]))] + [(#%plain-app void (quote-syntax (require/doc spec ...))) + (syntax->list #'(spec ...))] + [_ null])) + (syntax->list #'(content ...)))))] + [orig-tag (datum->syntax #f 'orig)]) + ;; This template is matched in `filter-info', below + #`(begin + (#%require (for-label #,(strip-context #'lang)) + (for-label #,(strip-context orig-path)) + req ...) + (drop-first (quote-syntax id) (def-it orig-tag content)) ...))])))) + (define-syntax (include-extracted stx) (syntax-case stx () - [(_ orig-path) #'(include-extracted orig-path #rx"")] ;; this regexp matches everything + [(_ orig-path) + (extract #'orig-path stx)])) + +(define-syntax (provide-extracted stx) + (syntax-case stx () + [(_ orig-path) + (with-syntax ([(_begin reqs (_drop-first (_quote-syntax id) def) ...) + (extract #'orig-path stx)]) + #'(begin + (require (for-label (only-in orig-path))) ;; creates build dependency + (define-syntax (extracted stx) + (syntax-case stx () + [(_ rx) + (let-syntax ([quote-syntax/loc + (lambda (stx) + (syntax-case stx () + [(_ s) + (let loop ([stx #'s]) + (cond + [(syntax? stx) + (let ([ctx (datum->syntax stx 'ctx #f #f stx)]) + (let ([s + #`(datum->syntax (quote-syntax #,ctx) + #,(loop (syntax-e stx)) + #,(and (syntax-position stx) + (vector (let ([s (syntax-source stx)]) + (if (path-string? s) + s + (format "~s" s))) + (syntax-line stx) + (syntax-column stx) + (syntax-position stx) + (syntax-span stx))))]) + (let ([p (syntax-property stx 'paren-shape)]) + (if p + #`(syntax-property #,s 'paren-shape '#,p) + s))))] + [(pair? stx) #`(cons #,(loop (car stx)) #,(loop (cdr stx)))] + [(vector? stx) #`(vector #,@(map loop (vector->list stx)))] + [(box? stx) #`(box #,(loop (unbox stx)))] + [else #`(quote #,stx)]))]))]) + #`(begin #,(quote-syntax/loc reqs) + #,@(filter + values + (map (lambda (i d) + (if (regexp-match (syntax-e #'rx) (symbol->string i)) + (d) + #f)) + (list 'id ...) + (list (lambda () (quote-syntax/loc def)) ...)))))])) + (provide extracted)))])) + +(define-syntax (include-previously-extracted stx) + (syntax-case stx () [(_ orig-path regexp-s) - (let ([path (resolve-path-spec #'orig-path #'orig-path stx)] - [reg (syntax-e #'regexp-s)]) - (unless (regexp? reg) - (raise-syntax-error #f "expected a literal regular expression as the second argument" stx #'regexp-s)) - (let ([s-exp - (parameterize ([current-namespace (make-base-namespace)] - [read-accept-reader #t] - [current-load-relative-directory - (path-only path)]) - (expand - (with-input-from-file path - (lambda () - (port-count-lines! (current-input-port)) - (read-syntax path)))))]) - (syntax-case s-exp () - [(mod name lang - (mod-beg - content ...)) - (with-syntax ([(content ...) - (apply - append - (map (lambda (c) - (syntax-case c (#%plain-app void quote-syntax provide/doc) - [(#%plain-app void (quote-syntax (provide/doc spec ...))) - (map - (λ (x) (syntax-case x () [(docs id) #'docs])) - (filter (λ (x) - (syntax-case x () - [(stuff id) - (regexp-match reg (symbol->string (syntax-e #'id)))])) - (syntax->list #'(spec ...))))] - [_ null])) - (syntax->list #'(content ...))))] - [(req ...) - (map - strip-context - (apply - append - (map (lambda (c) - (syntax-case c (#%require #%plain-app void quote-syntax require/doc) - [(#%require spec ...) - (let loop ([specs (syntax->list #'(spec ...))]) - (cond - [(null? specs) '()] - [else (let ([spec (car specs)]) - (syntax-case spec (for-syntax for-meta) - [(for-syntax . spec) (loop (cdr specs))] - [(for-meta . spec) (loop (cdr specs))] - [(for-template . spec) (loop (cdr specs))] - [(for-label . spec) (loop (cdr specs))] - [(just-meta . spec) (loop (cdr specs))] - [_ (cons #`(for-label #,spec) (loop (cdr specs)))]))]))] - [(#%plain-app void (quote-syntax (require/doc spec ...))) - (syntax->list #'(spec ...))] - [_ null])) - (syntax->list #'(content ...)))))] - [orig-tag (datum->syntax #f 'orig)]) - #`(begin - (#%require (for-label #,(strip-context #'lang)) - (for-label #,(strip-context #'orig-path)) - req ...) - (def-it orig-tag content) ...))])))])) + (unless (regexp? (syntax-e #'regexp-s)) + (raise-syntax-error #f "expected a literal regular expression as the second argument" stx #'regexp-s)) + #`(begin + (require (only-in orig-path [#,(datum->syntax #'orig-path 'extracted) extracted])) + (extracted regexp-s))])) (define-for-syntax (revise-context c orig-tag new-tag tag) (cond @@ -94,6 +149,7 @@ new-tag orig-tag) (revise-context (syntax-e c) orig-tag new-tag tag) + c c)] [(pair? c) (cons (revise-context (car c) orig-tag new-tag tag) (revise-context (cdr c) orig-tag new-tag tag))] @@ -109,3 +165,5 @@ #`(begin (require . #,(revise-context #'reqs orig-tag new-tag #'tag)) #,(revise-context #'doc orig-tag new-tag #'tag)))]))) + +(define-syntax-rule (drop-first a b) b) diff --git a/collects/scribble/srcdoc.ss b/collects/scribble/srcdoc.ss index 8e51d2bee8..9b32261950 100644 --- a/collects/scribble/srcdoc.ss +++ b/collects/scribble/srcdoc.ss @@ -183,7 +183,7 @@ (values #'[id contract] #'(defproc* header . desc) - #'(scribble/manual) + #'((only-in scribble/manual defproc*)) #'id))]))) (define-provide/doc-transformer parameter-doc @@ -204,7 +204,7 @@ (values #'[id (parameter/c contract)] #'(defparam id arg-id contract . desc) - #'(scribble/manual) + #'((only-in scribble/manual defparam)) #'id))]))) (define-provide/doc-transformer thing-doc @@ -220,5 +220,5 @@ (values #'[id contract] #'(defthing id contract . desc) - #'(scribble/manual) + #'((only-in scribble/manual defthing)) #'id))]))) diff --git a/collects/scribblings/framework/application.scrbl b/collects/scribblings/framework/application.scrbl index 8a6b8e83d3..08cb37eba8 100644 --- a/collects/scribblings/framework/application.scrbl +++ b/collects/scribblings/framework/application.scrbl @@ -5,4 +5,4 @@ @title{Application} -@(include-extracted (lib "main.ss" "framework") #rx"^application:") +@(include-previously-extracted "main-extracts.ss" #rx"^application:") diff --git a/collects/scribblings/framework/autosave.scrbl b/collects/scribblings/framework/autosave.scrbl index f6156bf088..874150d6f2 100644 --- a/collects/scribblings/framework/autosave.scrbl +++ b/collects/scribblings/framework/autosave.scrbl @@ -15,4 +15,4 @@ } } -@(include-extracted (lib "main.ss" "framework") #rx"^autosave:") +@(include-previously-extracted "main-extracts.ss" #rx"^autosave:") diff --git a/collects/scribblings/framework/canvas.scrbl b/collects/scribblings/framework/canvas.scrbl index 0b262ad4d8..9d59200af8 100644 --- a/collects/scribblings/framework/canvas.scrbl +++ b/collects/scribblings/framework/canvas.scrbl @@ -99,4 +99,4 @@ @defclass[canvas:delegate% (canvas:delegate-mixin canvas:basic%) ()]{} @defclass[canvas:wide-snip% (canvas:wide-snip-mixin canvas:basic%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^canvas:") +@(include-previously-extracted "main-extracts.ss" #rx"^canvas:") diff --git a/collects/scribblings/framework/color-model.scrbl b/collects/scribblings/framework/color-model.scrbl index c34ae19569..8e0b86b6ef 100644 --- a/collects/scribblings/framework/color-model.scrbl +++ b/collects/scribblings/framework/color-model.scrbl @@ -5,4 +5,4 @@ @title{Color Model} -@(include-extracted (lib "main.ss" "framework") #rx"^color-model:") +@(include-previously-extracted "main-extracts.ss" #rx"^color-model:") diff --git a/collects/scribblings/framework/color-prefs.scrbl b/collects/scribblings/framework/color-prefs.scrbl index 0984a0f434..be24bc940d 100644 --- a/collects/scribblings/framework/color-prefs.scrbl +++ b/collects/scribblings/framework/color-prefs.scrbl @@ -5,4 +5,4 @@ @title{Color Prefs} -@(include-extracted (lib "main.ss" "framework") #rx"^color-prefs:") +@(include-previously-extracted "main-extracts.ss" #rx"^color-prefs:") diff --git a/collects/scribblings/framework/color.scrbl b/collects/scribblings/framework/color.scrbl index a012b39918..2c61f6b75c 100644 --- a/collects/scribblings/framework/color.scrbl +++ b/collects/scribblings/framework/color.scrbl @@ -230,4 +230,4 @@ } @defclass[color:text-mode% (color:text-mode-mixin mode:surrogate-text%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^color:") +@(include-previously-extracted "main-extracts.ss" #rx"^color:") diff --git a/collects/scribblings/framework/comment-box.scrbl b/collects/scribblings/framework/comment-box.scrbl index a90a115ab2..518fee4370 100644 --- a/collects/scribblings/framework/comment-box.scrbl +++ b/collects/scribblings/framework/comment-box.scrbl @@ -45,4 +45,4 @@ } } -@(include-extracted (lib "main.ss" "framework") #rx"^comment-box:") +@(include-previously-extracted "main-extracts.ss" #rx"^comment-box:") diff --git a/collects/scribblings/framework/editor.scrbl b/collects/scribblings/framework/editor.scrbl index 6b1d41a6ad..00839f6cb6 100644 --- a/collects/scribblings/framework/editor.scrbl +++ b/collects/scribblings/framework/editor.scrbl @@ -455,4 +455,4 @@ } } -@(include-extracted (lib "main.ss" "framework") #rx"^editor:") +@(include-previously-extracted "main-extracts.ss" #rx"^editor:") diff --git a/collects/scribblings/framework/exit.scrbl b/collects/scribblings/framework/exit.scrbl index 3c63c25343..ee756630db 100644 --- a/collects/scribblings/framework/exit.scrbl +++ b/collects/scribblings/framework/exit.scrbl @@ -5,4 +5,4 @@ @title{Exit} -@(include-extracted (lib "main.ss" "framework") #rx"^exit:") +@(include-previously-extracted "main-extracts.ss" #rx"^exit:") diff --git a/collects/scribblings/framework/finder.scrbl b/collects/scribblings/framework/finder.scrbl index 91e3f06f4b..3f042dff9a 100644 --- a/collects/scribblings/framework/finder.scrbl +++ b/collects/scribblings/framework/finder.scrbl @@ -5,4 +5,4 @@ @title{Finder} -@(include-extracted (lib "main.ss" "framework") #rx"^finder:") +@(include-previously-extracted "main-extracts.ss" #rx"^finder:") diff --git a/collects/scribblings/framework/frame.scrbl b/collects/scribblings/framework/frame.scrbl index 69ccc94c15..bd5dd98937 100644 --- a/collects/scribblings/framework/frame.scrbl +++ b/collects/scribblings/framework/frame.scrbl @@ -1060,4 +1060,4 @@ @defclass[frame:delegate% (frame:delegate-mixin frame:searchable%) ()]{} @defclass[frame:pasteboard% (frame:pasteboard-mixin frame:open-here%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^frame:") +@(include-previously-extracted "main-extracts.ss" #rx"^frame:") diff --git a/collects/scribblings/framework/group.scrbl b/collects/scribblings/framework/group.scrbl index a0c092808a..a43a1a8a45 100644 --- a/collects/scribblings/framework/group.scrbl +++ b/collects/scribblings/framework/group.scrbl @@ -121,4 +121,4 @@ } } -@(include-extracted (lib "main.ss" "framework") #rx"^group:") +@(include-previously-extracted "main-extracts.ss" #rx"^group:") diff --git a/collects/scribblings/framework/handler.scrbl b/collects/scribblings/framework/handler.scrbl index bc320e595a..a59434f536 100644 --- a/collects/scribblings/framework/handler.scrbl +++ b/collects/scribblings/framework/handler.scrbl @@ -5,4 +5,4 @@ @title{Handler} -@(include-extracted (lib "main.ss" "framework") #rx"^handler:") +@(include-previously-extracted "main-extracts.ss" #rx"^handler:") diff --git a/collects/scribblings/framework/icon.scrbl b/collects/scribblings/framework/icon.scrbl index 6146791735..0a7b440676 100644 --- a/collects/scribblings/framework/icon.scrbl +++ b/collects/scribblings/framework/icon.scrbl @@ -5,4 +5,4 @@ @title{Icon} -@(include-extracted (lib "main.ss" "framework") #rx"^icon:") +@(include-previously-extracted "main-extracts.ss" #rx"^icon:") diff --git a/collects/scribblings/framework/keymap.scrbl b/collects/scribblings/framework/keymap.scrbl index bca27e9b0d..09ec0b9328 100644 --- a/collects/scribblings/framework/keymap.scrbl +++ b/collects/scribblings/framework/keymap.scrbl @@ -42,4 +42,4 @@ } @defclass[keymap:aug-keymap% (keymap:aug-keymap-mixin keymap%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^keymap:") +@(include-previously-extracted "main-extracts.ss" #rx"^keymap:") diff --git a/collects/scribblings/framework/main-extracts.ss b/collects/scribblings/framework/main-extracts.ss new file mode 100644 index 0000000000..9c8e329815 --- /dev/null +++ b/collects/scribblings/framework/main-extracts.ss @@ -0,0 +1,4 @@ +#lang scheme/base +(require scribble/extract) + +(provide-extracted (lib "main.ss" "framework")) diff --git a/collects/scribblings/framework/main.scrbl b/collects/scribblings/framework/main.scrbl index d169e5250c..42d536ec26 100644 --- a/collects/scribblings/framework/main.scrbl +++ b/collects/scribblings/framework/main.scrbl @@ -5,4 +5,4 @@ @title{Main} -@(include-extracted (lib "main.ss" "framework") #rx"^main:") +@(include-previously-extracted "main-extracts.ss" #rx"^main:") diff --git a/collects/scribblings/framework/menu.scrbl b/collects/scribblings/framework/menu.scrbl index b02bbd0735..09a653caf1 100644 --- a/collects/scribblings/framework/menu.scrbl +++ b/collects/scribblings/framework/menu.scrbl @@ -45,4 +45,4 @@ @defclass[menu:can-restore-checkable-menu-item% (menu:can-restore-mixin checkable-menu-item%) ()]{} @defclass[menu:can-restore-underscore-menu% (menu:can-restore-underscore-mixin menu%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^menu:") +@(include-previously-extracted "main-extracts.ss" #rx"^menu:") diff --git a/collects/scribblings/framework/mode.scrbl b/collects/scribblings/framework/mode.scrbl index 3d8461de8a..75e9f750cf 100644 --- a/collects/scribblings/framework/mode.scrbl +++ b/collects/scribblings/framework/mode.scrbl @@ -43,4 +43,4 @@ (surrogate-methods docs) ) -@(include-extracted (lib "main.ss" "framework") #rx"^mode:") +@(include-previously-extracted "main-extracts.ss" #rx"^mode:") diff --git a/collects/scribblings/framework/number-snip.scrbl b/collects/scribblings/framework/number-snip.scrbl index d4c604fc7f..0fab1b9b32 100644 --- a/collects/scribblings/framework/number-snip.scrbl +++ b/collects/scribblings/framework/number-snip.scrbl @@ -12,4 +12,4 @@ } } -@(include-extracted (lib "main.ss" "framework") #rx"^number-snip:") +@(include-previously-extracted "main-extracts.ss" #rx"^number-snip:") diff --git a/collects/scribblings/framework/panel.scrbl b/collects/scribblings/framework/panel.scrbl index cb97fc4211..2e8c5c3cdc 100644 --- a/collects/scribblings/framework/panel.scrbl +++ b/collects/scribblings/framework/panel.scrbl @@ -168,4 +168,4 @@ @defclass[panel:vertical-dragable% (panel:vertical-dragable-mixin (panel:dragable-mixin vertical-panel%)) ()]{} @defclass[panel:horizontal-dragable% (panel:horizontal-dragable-mixin (panel:dragable-mixin horizontal-panel%)) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^panel:") +@(include-previously-extracted "main-extracts.ss" #rx"^panel:") diff --git a/collects/scribblings/framework/pasteboard.scrbl b/collects/scribblings/framework/pasteboard.scrbl index cfb0c6f6a3..c55f9d153b 100644 --- a/collects/scribblings/framework/pasteboard.scrbl +++ b/collects/scribblings/framework/pasteboard.scrbl @@ -11,4 +11,4 @@ @defclass[pasteboard:backup-autosave% (editor:backup-autosave-mixin pasteboard:file%) ()]{} @defclass[pasteboard:info% (editor:info-mixin pasteboard:backup-autosave%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^pasteboard:") +@(include-previously-extracted "main-extracts.ss" #rx"^pasteboard:") diff --git a/collects/scribblings/framework/path-utils.scrbl b/collects/scribblings/framework/path-utils.scrbl index b3955e2a4e..dc112883b0 100644 --- a/collects/scribblings/framework/path-utils.scrbl +++ b/collects/scribblings/framework/path-utils.scrbl @@ -5,4 +5,4 @@ @title{Path Utils} -@(include-extracted (lib "main.ss" "framework") #rx"^path-utils:") +@(include-previously-extracted "main-extracts.ss" #rx"^path-utils:") diff --git a/collects/scribblings/framework/preferences.scrbl b/collects/scribblings/framework/preferences.scrbl index 9e03bb40ef..8d8b10c5f6 100644 --- a/collects/scribblings/framework/preferences.scrbl +++ b/collects/scribblings/framework/preferences.scrbl @@ -5,4 +5,4 @@ @title{Preferences} -@(include-extracted (lib "main.ss" "framework") #rx"^preferences:") +@(include-previously-extracted "main-extracts.ss" #rx"^preferences:") diff --git a/collects/scribblings/framework/scheme.scrbl b/collects/scribblings/framework/scheme.scrbl index 5f33177ef7..07ec4b51f7 100644 --- a/collects/scribblings/framework/scheme.scrbl +++ b/collects/scribblings/framework/scheme.scrbl @@ -270,4 +270,4 @@ @defclass[scheme:text% (scheme:set-mode-mixin (scheme:text-mixin (text:autocomplete-mixin (mode:host-text-mixin color:text%)))) ()]{} @defclass[scheme:text-mode% (scheme:text-mode-mixin color:text-mode%) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^scheme:") +@(include-previously-extracted "main-extracts.ss" #rx"^scheme:") diff --git a/collects/scribblings/framework/text.scrbl b/collects/scribblings/framework/text.scrbl index 1d78ada317..1ca1378dd2 100644 --- a/collects/scribblings/framework/text.scrbl +++ b/collects/scribblings/framework/text.scrbl @@ -944,4 +944,4 @@ @defclass[text:searching% (text:searching-mixin text:backup-autosave%) ()]{} @defclass[text:info% (text:info-mixin (editor:info-mixin text:searching%)) ()]{} -@(include-extracted (lib "main.ss" "framework") #rx"^text:") +@(include-previously-extracted "main-extracts.ss" #rx"^text:") diff --git a/collects/scribblings/framework/version.scrbl b/collects/scribblings/framework/version.scrbl index 6d4023e57c..6b8193e19d 100644 --- a/collects/scribblings/framework/version.scrbl +++ b/collects/scribblings/framework/version.scrbl @@ -5,4 +5,4 @@ @title{Version} -@(include-extracted (lib "main.ss" "framework") #rx"^version:") +@(include-previously-extracted "main-extracts.ss" #rx"^version:") diff --git a/collects/scribblings/tools/common.ss b/collects/scribblings/tools/common.ss index da0663b6bc..995ed8dab3 100644 --- a/collects/scribblings/tools/common.ss +++ b/collects/scribblings/tools/common.ss @@ -37,7 +37,7 @@ (string? (syntax-e #'name)) (let ([name (syntax-e #'name)]) (with-syntax ([rx (regexp (format "^drscheme:~a:" name))]) - #'(include-extracted (lib "tool-lib.ss" "drscheme") rx)))])) + #'(include-previously-extracted "tool-lib-extracts.ss" rx)))])) (provide docs-get/extend) (define-syntax (docs-get/extend stx) diff --git a/collects/scribblings/tools/tool-lib-extracts.ss b/collects/scribblings/tools/tool-lib-extracts.ss new file mode 100644 index 0000000000..a568392373 --- /dev/null +++ b/collects/scribblings/tools/tool-lib-extracts.ss @@ -0,0 +1,5 @@ +#lang scheme/base + +(require scribble/extract) + +(provide-extracted (lib "tool-lib.ss" "drscheme")) \ No newline at end of file