scribble/manual: delay expressions that require collection-based files

This changed make `(require scribble/manual)` work in an executable,
although actually rendering documents requires the "scribble"
collection.

original commit: 9ca0aa52250c18dd05c2a19bea654ca770aecf0c
This commit is contained in:
Matthew Flatt 2014-02-11 10:01:49 -07:00
parent 1bac8f0057
commit e34cf22278
3 changed files with 38 additions and 3 deletions

View File

@ -1,7 +1,8 @@
#lang scheme/base
(require scribble/core
scribble/html-properties
"defaults.rkt")
"defaults.rkt"
"on-demand.rkt")
(provide post-process
manual-doc-style)
@ -20,5 +21,5 @@
(scribble-file "manual-racket.css")))
#t))
(define manual-doc-style
(define-on-demand manual-doc-style
(part-style (post-process (part #f null #f plain null null null))))

View File

@ -7,6 +7,7 @@
(only-in "../core.rkt" style style-properties)
"manual-style.rkt"
"manual-utils.rkt" ;; used via datum->syntax
"on-demand.rkt"
(for-syntax racket/base)
(for-label racket/base))
@ -211,7 +212,7 @@
(*as-modname-link s e indirect?)
e))
(define indirect-module-link-color
(define-on-demand indirect-module-link-color
(struct-copy style module-link-color
[properties (cons 'indirect-link
(style-properties module-link-color))]))

View File

@ -0,0 +1,33 @@
#lang racket/base
(require racket/file
compiler/embed
racket/system)
;; Check that `scribble/manual` can be embedded in an executable
(define src (make-temporary-file))
(define exe (make-temporary-file))
(call-with-output-file src
#:exists 'truncate
(lambda (o)
(write '(module m racket/base
(require scribble/manual))
o)))
(define mod-sym (string->symbol
(format "~a"
(let-values ([(base name dir?)
(split-path src)])
(path->bytes (path-replace-suffix name #""))))))
(create-embedding-executable exe
#:cmdline '("-U")
#:collects-path null
#:modules `((#f ,src))
#:configure-via-first-module? #t
#:literal-expression
(parameterize ([current-namespace (make-base-namespace)])
(compile `(namespace-require '',mod-sym))))
(system* exe)