diff --git a/pollen/private/doclang-raw.rkt b/pollen/private/doclang-raw.rkt index 2b33a4d..f47f50a 100755 --- a/pollen/private/doclang-raw.rkt +++ b/pollen/private/doclang-raw.rkt @@ -10,18 +10,16 @@ (define-syntax (*module-begin stx) (syntax-case stx () - [(_ id . body) - (with-syntax ([post-process #'(λ (x) x)] - [exprs #'()]) + [(_ id post-process . body) + (with-syntax ([exprs #'()]) #'(#%module-begin (doc-begin id post-process exprs . body)))])) (define-syntax (doc-begin stx) (syntax-case stx () [(_ m-id post-process (expr ...)) - #`(begin - (define m-id (post-process (list . #,(reverse (syntax->list #'(expr ...)))))) - (provide m-id))] + ;; unlike regular doclang, don't `provide` m-id (we'll do that in main-base wrapper) + #`(define m-id (post-process (list . #,(reverse (syntax->list #'(expr ...))))))] [(_ m-id post-process exprs . body) ;; `body' probably starts with lots of string constants; it's ;; slow to trampoline on every string, so do them in a batch diff --git a/pollen/private/main-base.rkt b/pollen/private/main-base.rkt index eac9968..b87dfdb 100644 --- a/pollen/private/main-base.rkt +++ b/pollen/private/main-base.rkt @@ -1,6 +1,7 @@ #lang racket/base (require (for-syntax racket/base racket/syntax "../setup.rkt" "split-metas.rkt") - "to-string.rkt" "../pagetree.rkt" "splice.rkt" "../setup.rkt" "../core.rkt") + "to-string.rkt" "../pagetree.rkt" "splice.rkt" "../setup.rkt" "../core.rkt" + (prefix-in doclang: "doclang-raw.rkt")) (provide (except-out (all-from-out racket/base) #%module-begin) (rename-out [dialect-module-begin #%module-begin])) @@ -51,33 +52,20 @@ [METAS-ID (setup:meta-export)] [META-MOD-ID (setup:meta-export)] [ROOT-ID (setup:main-root-node)] - [DOC-ID (setup:main-export)] - ;; prevents conflicts with other imported Pollen sources - [DOC-RAW (datum->syntax #'here (syntax->datum (generate-temporary 'pollen-)))]) - #'(#%module-begin - (require pollen/top) ; we could get this via 'inner, but then we'd have to avoid exporting it - + [DOC-ID (setup:main-export)]) + #'(doclang:#%module-begin + DOC-ID ; positional arg for doclang-raw: name of export + (λ (xs) + (define parser-mode (or 'PARSER-MODE-FROM-READER PARSER-MODE-FROM-EXPANDER)) + (define proc (make-parse-proc parser-mode ROOT-ID)) + (define doc-elements (splice (strip-leading-newlines xs) (setup:splicing-tag))) + (proc doc-elements)) ; positional arg for doclang-raw: post-processor (module META-MOD-ID racket/base (provide METAS-ID) (define METAS-ID META-HASH)) - - (module inner pollen/private/doclang-raw - DOC-RAW ; positional arg for doclang-raw that sets name of export - (require pollen/top pollen/core pollen/setup (submod ".." META-MOD-ID)) - (and (current-metas METAS-ID) "\n") ; because newlines get stripped, voids don't - (provide (all-defined-out) METAS-ID) - . EXPRS-WITHOUT-METAS) - + (require pollen/top pollen/core pollen/setup (submod "." META-MOD-ID)) + (provide (all-defined-out) METAS-ID DOC-ID) (define prev-metas (current-metas)) - (require 'inner) - - (define DOC-ID - ;; parser-mode must be resolved at runtime, not compile time - (let* ([parser-mode (or 'PARSER-MODE-FROM-READER PARSER-MODE-FROM-EXPANDER)] - [proc (make-parse-proc parser-mode ROOT-ID)] - [doc-elements (strip-leading-newlines DOC-RAW)] - [doc-elements-spliced (splice doc-elements (setup:splicing-tag))]) - (proc doc-elements-spliced))) - - (current-metas prev-metas) - (provide DOC-ID (except-out (all-from-out 'inner) DOC-RAW)))))])) + (and (current-metas METAS-ID) "\n") ; because newlines get stripped, voids don't + (begin . EXPRS-WITHOUT-METAS) + (and (current-metas prev-metas) ""))))])) ; leave behind empty string, not void diff --git a/pollen/test/pollen.rkt b/pollen/test/pollen.rkt index 0181b8e..d4b942b 100644 --- a/pollen/test/pollen.rkt +++ b/pollen/test/pollen.rkt @@ -1,8 +1,15 @@ #lang racket/base +(require racket/string pollen/core) ;; This will prevent tests from littering their directory ;; with pollen-cache files. (module setup racket/base (provide (all-defined-out)) (define compile-cache-active #f) - (define render-cache-active #f)) \ No newline at end of file + (define render-cache-active #f)) + +(provide test-current-metas) +(define (test-current-metas) + (if (current-metas) + (string-join (sort (map symbol->string (hash-keys (current-metas))) string