|
|
@ -3,69 +3,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
(provide (all-defined-out) (all-from-out pollen/world))
|
|
|
|
(provide (all-defined-out) (all-from-out pollen/world))
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (define+provide-module-begin-in-mode stx)
|
|
|
|
(define-syntax-rule (define+provide-module-begin-in-mode MODE-ARG)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(begin
|
|
|
|
[(_ mode-arg)
|
|
|
|
(provide (except-out (all-from-out racket/base) #%module-begin)
|
|
|
|
(with-syntax ([new-module-begin (format-id stx "new-module-begin")])
|
|
|
|
(rename-out [pollen-module-begin #%module-begin]))
|
|
|
|
#'(begin
|
|
|
|
(define-syntax (pollen-module-begin stx)
|
|
|
|
(provide (except-out (all-from-out racket/base) #%module-begin)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(rename-out [new-module-begin #%module-begin]))
|
|
|
|
[(_ EXPR (... ...))
|
|
|
|
(define-syntax (new-module-begin stx-arg)
|
|
|
|
(with-syntax ([DOC (datum->syntax stx (world:current-main-export))]
|
|
|
|
(syntax-case stx-arg ()
|
|
|
|
[METAS (datum->syntax stx (world:current-meta-export))]
|
|
|
|
[(_ body-exprs (... ...))
|
|
|
|
[META (datum->syntax stx (world:current-meta-tag-name))]
|
|
|
|
(with-syntax ([local-meta-tag-name (format-id stx-arg (symbol->string (world:current-meta-tag-name)))]
|
|
|
|
[INNER (datum->syntax stx ''inner)])
|
|
|
|
[local-doc-export-name (format-id stx-arg (symbol->string (world:current-main-export)))]
|
|
|
|
#'(#%module-begin
|
|
|
|
[local-metas-export-name (format-id stx-arg (symbol->string (world:current-meta-export)))])
|
|
|
|
(module inner pollen/doclang-raw
|
|
|
|
(syntax-protect
|
|
|
|
;; doclang_raw is a version of scribble/doclang with the decoder disabled
|
|
|
|
#'(#%module-begin
|
|
|
|
;; first three lines are positional arguments for doclang-raw
|
|
|
|
(module inner pollen/doclang-raw
|
|
|
|
doc-raw ; id of export
|
|
|
|
;; doclang_raw is a version of scribble/doclang with the decoder disabled
|
|
|
|
(λ(x) x) ; post-process function
|
|
|
|
;; first three lines are positional arguments for doclang-raw
|
|
|
|
() ; prepended exprs
|
|
|
|
doc-raw ; id of export
|
|
|
|
|
|
|
|
(λ(x) x) ; post-process function
|
|
|
|
;; Change behavior of undefined identifiers with #%top
|
|
|
|
() ; prepended exprs
|
|
|
|
;; Get project values from world
|
|
|
|
|
|
|
|
(require pollen/top pollen/world)
|
|
|
|
;; Change behavior of undefined identifiers with #%top
|
|
|
|
(provide (all-defined-out) (all-from-out pollen/top pollen/world))
|
|
|
|
;; Get project values from world
|
|
|
|
EXPR (... ...))
|
|
|
|
(require pollen/top pollen/world)
|
|
|
|
|
|
|
|
(provide (all-defined-out) (all-from-out pollen/top pollen/world))
|
|
|
|
(require INNER 'inner pollen/metas) ; import inner twice: INNER for external use, 'inner for internal
|
|
|
|
|
|
|
|
|
|
|
|
body-exprs (... ...))
|
|
|
|
;; in an inline module, reader-here-path and parser-mode are undefined
|
|
|
|
|
|
|
|
;; (because there's no reader)
|
|
|
|
(require 'inner racket/list pollen/metas)
|
|
|
|
;; but they'll become tag functions courtesy of #%top
|
|
|
|
|
|
|
|
;; so that's how we can detect if they are undefined
|
|
|
|
;; in an inline module, reader-here-path and parser-mode are undefined
|
|
|
|
(define here-path (if (procedure? inner:reader-here-path)
|
|
|
|
;; (because there's no reader)
|
|
|
|
"anonymous-module"
|
|
|
|
;; but they'll become tag functions courtesy of #%top
|
|
|
|
inner:reader-here-path))
|
|
|
|
;; so that's how we can detect if they are undefined
|
|
|
|
(define parser-mode (if (procedure? inner:parser-mode)
|
|
|
|
(define here-path (if (procedure? inner:reader-here-path)
|
|
|
|
MODE-ARG
|
|
|
|
"anonymous-module"
|
|
|
|
inner:parser-mode))
|
|
|
|
inner:reader-here-path))
|
|
|
|
|
|
|
|
(define parser-mode (if (procedure? inner:parser-mode)
|
|
|
|
;; set up the DOC export
|
|
|
|
mode-arg
|
|
|
|
(define doc-elements (if (list? doc-raw) ; discard all newlines at front of file
|
|
|
|
inner:parser-mode))
|
|
|
|
((dynamic-require 'racket/list 'dropf) doc-raw (λ(i) (equal? i "\n")))
|
|
|
|
|
|
|
|
doc-raw)) ; single line
|
|
|
|
(define doc-with-metas
|
|
|
|
(define doc-with-metas (list* 'placeholder-root `(META (here-path ,here-path)) doc-elements))
|
|
|
|
`(placeholder-root
|
|
|
|
(define-values (doc-without-metas METAS) (split-metas-to-hash doc-with-metas))
|
|
|
|
,@(cons `(local-meta-tag-name (here-path ,here-path))
|
|
|
|
(define DOC
|
|
|
|
(if (list? doc-raw)
|
|
|
|
(let ([proc (cond
|
|
|
|
(dropf doc-raw (λ(i) (equal? i "\n"))) ; discard all newlines at front of file
|
|
|
|
[(equal? parser-mode world:mode-pagetree)
|
|
|
|
doc-raw))))
|
|
|
|
(λ xs ((dynamic-require 'pollen/pagetree 'decode-pagetree) xs))]
|
|
|
|
(define-values (doc-without-metas metas) (split-metas-to-hash doc-with-metas)) ; split out the metas
|
|
|
|
;; 'root is the hook for the decoder function.
|
|
|
|
|
|
|
|
;; If it's not a defined identifier, it just hits #%top and becomes `(root ,@body ...)
|
|
|
|
;; set up the 'doc export
|
|
|
|
[(equal? parser-mode world:mode-markup) root]
|
|
|
|
(require pollen/decode)
|
|
|
|
[(equal? parser-mode world:mode-markdown)
|
|
|
|
(define doc (apply (cond
|
|
|
|
(λ xs (apply root (apply (compose1 (dynamic-require 'markdown 'parse-markdown) string-append)
|
|
|
|
[(equal? parser-mode world:mode-pagetree) (λ xs ((dynamic-require 'pollen/pagetree 'decode-pagetree) xs))]
|
|
|
|
(map (dynamic-require 'pollen/decode 'to-string) xs))))]
|
|
|
|
;; 'root is the hook for the decoder function.
|
|
|
|
;; for preprocessor output, just make a string.
|
|
|
|
;; If it's not a defined identifier, it just hits #%top and becomes `(root ,@body ...)
|
|
|
|
[else (λ xs (apply string-append (map (dynamic-require 'pollen/decode 'to-string) xs)))])]
|
|
|
|
[(equal? parser-mode world:mode-markup) root]
|
|
|
|
[doc-elements-without-metas (cdr doc-without-metas)])
|
|
|
|
[(equal? parser-mode world:mode-markdown) (λ xs (apply root (apply (compose1 (dynamic-require 'markdown 'parse-markdown) string-append) (map to-string xs))))]
|
|
|
|
(apply proc doc-elements-without-metas)))
|
|
|
|
;; for preprocessor output, just make a string.
|
|
|
|
|
|
|
|
[else (λ xs (apply string-append (map to-string xs)))]) ; default mode is preprocish
|
|
|
|
;; hide the exports that were only for internal use.
|
|
|
|
(cdr doc-without-metas))) ;; cdr strips placeholder-root tag
|
|
|
|
(provide DOC METAS (except-out (all-from-out INNER) doc-raw #%top))))]))))
|
|
|
|
|
|
|
|
|
|
|
|
;; hide the exports that were only for internal use.
|
|
|
|
|
|
|
|
(provide (rename-out [metas local-metas-export-name])
|
|
|
|
|
|
|
|
(rename-out [doc local-doc-export-name])
|
|
|
|
|
|
|
|
(except-out (all-from-out 'inner) doc-raw #%top)))))]))))]))
|
|
|
|
|
|
|
|