From e34cf22278c83db6909e91848ca57b68bb2df3c6 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 11 Feb 2014 10:01:49 -0700 Subject: [PATCH] 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 --- .../scribble/private/manual-defaults.rkt | 5 +-- .../scribble/private/manual-scheme.rkt | 3 +- .../scribble-test/tests/scribble/exe.rkt | 33 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 pkgs/scribble-pkgs/scribble-test/tests/scribble/exe.rkt diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-defaults.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-defaults.rkt index 8daf1add..6750ac14 100644 --- a/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-defaults.rkt +++ b/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-defaults.rkt @@ -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)))) diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-scheme.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-scheme.rkt index 9406b3f6..1e870729 100644 --- a/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-scheme.rkt +++ b/pkgs/scribble-pkgs/scribble-lib/scribble/private/manual-scheme.rkt @@ -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))])) diff --git a/pkgs/scribble-pkgs/scribble-test/tests/scribble/exe.rkt b/pkgs/scribble-pkgs/scribble-test/tests/scribble/exe.rkt new file mode 100644 index 00000000..a36018e1 --- /dev/null +++ b/pkgs/scribble-pkgs/scribble-test/tests/scribble/exe.rkt @@ -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)