From bbbd68b3c229728c01da2bddf5a6dce140fe9485 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 30 Dec 2015 06:54:51 -0600 Subject: [PATCH] declare-exporting: allow escaped module-path expressions --- .../scribblings/scribble/manual.scrbl | 20 ++++++++++++------- scribble-lib/scribble/private/manual-mod.rkt | 7 +++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/scribble-doc/scribblings/scribble/manual.scrbl b/scribble-doc/scribblings/scribble/manual.scrbl index 1417c6fc..f700675b 100644 --- a/scribble-doc/scribblings/scribble/manual.scrbl +++ b/scribble-doc/scribblings/scribble/manual.scrbl @@ -683,18 +683,23 @@ The @tech{decode}d @racket[pre-flow]s introduce the module, but need not include all of the module content.} -@defform/subs[(declare-exporting module-path ... maybe-pkgs maybe-sources) - ([maybe-pkgs code:blank - (code:line #:packages (pkg-expr ...))] - [maybe-sources code:blank - (code:line #:use-sources (module-path ...))])]{ +@defform[#:literals (unquote) + (declare-exporting module-path/escape ... maybe-pkgs maybe-sources) + #:grammar ([maybe-pkgs code:blank + (code:line #:packages (pkg-expr ...))] + [maybe-sources code:blank + (code:line #:use-sources (module-path/escape ...))] + [module-path/escape module-path + ,module-path-expr])]{ Associates the @racket[module-path]s to all bindings defined within the enclosing section, except as overridden by other @racket[declare-exporting] declarations in nested sub-sections. The list of @racket[module-path]s before @racket[#:use-sources] is shown, for example, when the user hovers the mouse over one of the bindings -defined within the section. +defined within the section. A @racket[unquote]-escaped +@racket[,module-path-expr] can be used in place of a +@racket[module-path] to compute the module path dynamically. More significantly, the first @racket[module-path] before @racket[#:use-sources] plus the @racket[module-path]s after @@ -767,7 +772,8 @@ per section, since the declaration applies to the entire section, although overriding @racket[declare-exporting] forms can appear in sub-sections. -@history[#:changed "1.1" @elem{Added @racket[#:packages] clause.}]} +@history[#:changed "1.1" @elem{Added @racket[#:packages] clause.} + #:changed "1.17" @elem{Added support for @racket[,module-path-expr].}]} @defform*[[(defmodulelang one-or-multi maybe-sources option ... pre-flow ...) (defmodulelang one-or-multi #:module-path module-path diff --git a/scribble-lib/scribble/private/manual-mod.rkt b/scribble-lib/scribble/private/manual-mod.rkt index 65eff134..cb15a029 100644 --- a/scribble-lib/scribble/private/manual-mod.rkt +++ b/scribble-lib/scribble/private/manual-mod.rkt @@ -302,11 +302,14 @@ #'#f)]) (let ([libs (syntax->list #'(lib ... plib ...))]) (for ([l libs]) - (unless (module-path? (syntax->datum l)) + (unless (or (syntax-case l (unquote) + [(unquote _) #t] + [_ #f]) + (module-path? (syntax->datum l))) (raise-syntax-error #f "not a module path" stx l))) (when (null? libs) (raise-syntax-error #f "need at least one module path" stx)) - #'(*declare-exporting '(lib ...) '(plib ...) packages)))])) + #'(*declare-exporting `(lib ...) `(plib ...) packages)))])) (define (*declare-exporting libs source-libs in-pkgs) (define pkgs (or in-pkgs