raco setup: render each document with a separate namespace
Rending a document can deserialize values, which can load modules that would otherwise not be loaded by Scribble, so render each document with a fresh namespace that is discarded after rendering.
This commit is contained in:
parent
5b20690876
commit
3b866db378
|
@ -21,7 +21,7 @@
|
||||||
scribble/core
|
scribble/core
|
||||||
scribble/html-properties
|
scribble/html-properties
|
||||||
scribble/tag
|
scribble/tag
|
||||||
scribble/private/manual-class-struct ; really shouldn't be here... see dynamic-require-doc
|
scribble/private/manual-class-struct ; really shouldn't be here... see make-isolated-namespace
|
||||||
scribble/private/run-pdflatex
|
scribble/private/run-pdflatex
|
||||||
setup/xref
|
setup/xref
|
||||||
scribble/xref
|
scribble/xref
|
||||||
|
@ -1460,7 +1460,9 @@
|
||||||
"render"
|
"render"
|
||||||
(with-record-error
|
(with-record-error
|
||||||
(doc-src-file doc)
|
(doc-src-file doc)
|
||||||
(lambda () (send renderer render (list v) (list dest-dir) ri))
|
(lambda ()
|
||||||
|
(parameterize ([current-namespace (make-isolated-namespace)])
|
||||||
|
(send renderer render (list v) (list dest-dir) ri)))
|
||||||
void))
|
void))
|
||||||
(unless (or latex-dest (main-doc? doc))
|
(unless (or latex-dest (main-doc? doc))
|
||||||
;; Since dest dir is the same place as pre-built documentation,
|
;; Since dest dir is the same place as pre-built documentation,
|
||||||
|
@ -1487,22 +1489,22 @@
|
||||||
(parameterize ([current-namespace (namespace-anchor->empty-namespace anchor)])
|
(parameterize ([current-namespace (namespace-anchor->empty-namespace anchor)])
|
||||||
body ...))
|
body ...))
|
||||||
|
|
||||||
(define (dynamic-require-doc mod-path)
|
(define (make-isolated-namespace)
|
||||||
;; Use a separate namespace so that we don't end up with all the
|
;; For loading documents or contexts where deserialization
|
||||||
;; documentation loaded at once.
|
;; might load additional modules.
|
||||||
;; Use a custodian to compensate for examples executed during the build
|
|
||||||
;; that may not be entirely clean (e.g., leaves a stuck thread).
|
|
||||||
(let ([p (make-empty-namespace)]
|
(let ([p (make-empty-namespace)]
|
||||||
[c (make-custodian)]
|
|
||||||
[ch (make-channel)]
|
|
||||||
[ns (namespace-anchor->empty-namespace anchor)])
|
[ns (namespace-anchor->empty-namespace anchor)])
|
||||||
(parameterize ([current-custodian c])
|
|
||||||
(namespace-attach-module ns 'scribble/base-render p)
|
(namespace-attach-module ns 'scribble/base-render p)
|
||||||
(namespace-attach-module ns 'scribble/html-render p)
|
(namespace-attach-module ns 'scribble/html-render p)
|
||||||
;; This is here for de-serialization; we need a better repair than
|
;; This is here for de-serialization; we need a better repair than
|
||||||
;; hard-wiring the "manual.rkt" library:
|
;; hard-wiring the "manual.rkt" library:
|
||||||
(namespace-attach-module ns 'scribble/private/manual-class-struct p)
|
(namespace-attach-module ns 'scribble/private/manual-class-struct p)
|
||||||
(parameterize ([current-namespace p])
|
p))
|
||||||
|
|
||||||
|
(define (dynamic-require-doc mod-path)
|
||||||
|
;; Use a separate namespace so that we don't end up with all the
|
||||||
|
;; documentation loaded at once.
|
||||||
|
(parameterize ([current-namespace (make-isolated-namespace)])
|
||||||
(call-in-nested-thread (lambda ()
|
(call-in-nested-thread (lambda ()
|
||||||
(define sub
|
(define sub
|
||||||
(if (and (pair? mod-path)
|
(if (and (pair? mod-path)
|
||||||
|
@ -1511,7 +1513,7 @@
|
||||||
`(submod ,mod-path doc)))
|
`(submod ,mod-path doc)))
|
||||||
(if (module-declared? sub #t)
|
(if (module-declared? sub #t)
|
||||||
(dynamic-require sub 'doc)
|
(dynamic-require sub 'doc)
|
||||||
(dynamic-require mod-path 'doc))))))))
|
(dynamic-require mod-path 'doc))))))
|
||||||
|
|
||||||
(define (write- latex-dest vers doc name datas prep! final!)
|
(define (write- latex-dest vers doc name datas prep! final!)
|
||||||
(let* ([filename (sxref-path latex-dest doc name)])
|
(let* ([filename (sxref-path latex-dest doc name)])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user