From 894ace3dbac08a1bf59a3691fe496a34583f99e5 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 30 Oct 2018 18:56:49 -0700 Subject: [PATCH] workaround --- pollen/cache.rkt | 7 ++++--- pollen/private/cache-utils.rkt | 9 +++++---- pollen/render.rkt | 11 ++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pollen/cache.rkt b/pollen/cache.rkt index 1bacd69..46f7ee4 100644 --- a/pollen/cache.rkt +++ b/pollen/cache.rkt @@ -47,10 +47,11 @@ (define ram-cache-record (hash-ref! ram-cache key get-cache-record)) (hash-ref ram-cache-record subkey)] [else - (parameterize ([current-namespace (make-base-namespace)]) + (define outer-ns (namespace-anchor->namespace cache-module-ns)) + (define new-ns (make-base-namespace)) + (namespace-attach-module outer-ns 'pollen/setup new-ns) + (parameterize ([current-namespace new-ns]) ;; brings in currently instantiated params (unlike namespace-require) - (define outer-ns (namespace-anchor->namespace cache-module-ns)) - (namespace-attach-module outer-ns 'pollen/setup) (dynamic-require path subkey))])))) (define+provide (cached-require path-string subkey) diff --git a/pollen/private/cache-utils.rkt b/pollen/private/cache-utils.rkt index 19e4398..3118c99 100644 --- a/pollen/private/cache-utils.rkt +++ b/pollen/private/cache-utils.rkt @@ -59,11 +59,12 @@ ;; the benefit of not reloading doc when you just need metas. ;; new namespace forces `dynamic-require` to re-instantiate `path` ;; otherwise it gets cached in current namespace. - (parameterize ([current-namespace (make-base-namespace)] + ;; brings in currently instantiated params (unlike namespace-require) + (define outer-ns (namespace-anchor->namespace cache-utils-module-ns)) + (define new-ns (make-base-namespace)) + (namespace-attach-module outer-ns 'pollen/setup new-ns) + (parameterize ([current-namespace new-ns] [current-directory (dirname path)]) - ;; brings in currently instantiated params (unlike namespace-require) - (define outer-ns (namespace-anchor->namespace cache-utils-module-ns)) - (namespace-attach-module outer-ns 'pollen/setup) (define doc-missing-thunk (λ () "")) (define metas-missing-thunk (λ () (hasheq))) (list doc-key (dynamic-require path doc-key doc-missing-thunk) diff --git a/pollen/render.rkt b/pollen/render.rkt index 434f812..2d7f260 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -147,7 +147,7 @@ (define template-path (or maybe-template-path (get-template-for source-path output-path))) ;; output-path and template-path may not have an extension, so check them in order with fallback - (message (format "rendering /~a" + (message (format "rendering /~a" (find-relative-path (current-project-root) source-path))) (match-define-values ((cons render-result _) _ real _) (parameterize ([current-poly-target (->symbol (or (get-ext output-path) @@ -175,11 +175,12 @@ (local-require scribble/core scribble/manual (prefix-in scribble- scribble/render)) (define source-dir (dirname source-path)) ;; make fresh namespace for scribble rendering (avoids dep/zo caching) - (parameterize ([current-namespace (make-base-namespace)] + (define outer-ns (namespace-anchor->namespace render-module-ns)) + (define new-ns (make-base-namespace)) + (namespace-attach-module outer-ns 'scribble/core new-ns) + (namespace-attach-module outer-ns 'scribble/manual new-ns) + (parameterize ([current-namespace new-ns] [current-directory (->complete-path source-dir)]) - (define outer-ns (namespace-anchor->namespace render-module-ns)) - (namespace-attach-module outer-ns 'scribble/core) - (namespace-attach-module outer-ns 'scribble/manual) ;; scribble/lp files have their doc export in a 'doc submodule, so check both locations (match (cond [(dynamic-require source-path 'doc (λ () #false))]