small clarifications; add `here-key-path`

pull/84/head
Matthew Butterick 9 years ago
parent bbab98f0a5
commit 5884bb1a49

@ -11,7 +11,7 @@
(define-syntax (*module-begin stx)
(syntax-case stx ()
[(_ . body)
(with-syntax ([id #'doc-raw]
(with-syntax ([id #'doc-raw] ; name of the main export from doclang-raw
[post-process #'(λ(x) x)]
[exprs #'()])
#'(#%module-begin

@ -9,7 +9,8 @@
(define (split-metas tree)
(define (meta-matcher x) (and (pair? x) (eq? (car x) (world:current-define-meta-name))))
(define (meta-matcher x) ; meta has form (define-meta key value)
(and (list? x) (>= (length x) 3) (eq? (first x) (world:current-define-meta-name))))
(define matches empty)
(define rest
(let loop ([x tree])
@ -22,7 +23,8 @@
(set! matches (append new-matches matches))
(map loop rest)]
[else x])))
(values matches rest))
(let ([meta-key second][meta-value third])
(values (map meta-key matches) (map meta-value matches) rest)))
(define (make-custom-read-syntax reader-mode)
@ -36,7 +38,7 @@
#:syntax? #t
#:inside? #t))
(define source-stx (read-inner path-string p))
(define-values (meta-matches meta-free-file-data) (split-metas (syntax->datum source-stx)))
(define-values (meta-keys meta-values meta-free-file-data) (split-metas (syntax->datum source-stx)))
(define reader-here-path (cond
[(symbol? path-string) (symbol->string path-string)]
[(equal? path-string "unsaved editor") path-string]
@ -51,10 +53,10 @@
[else world:mode-preproc])])
auto-computed-mode)
reader-mode))
(define meta-keys (cons 'here-path (map second meta-matches)))
(define meta-values (cons reader-here-path (map third meta-matches)))
(with-syntax ([(KEY ...) (datum->syntax source-stx meta-keys)]
[(VALUE ...) (datum->syntax source-stx meta-values)])
(define meta-keys-plus-here (cons (world:current-here-path-key) meta-keys)) ; here-path at front so it can be overridden
(define meta-values-plus-here (cons reader-here-path meta-values))
(with-syntax ([(KEY ...) (datum->syntax source-stx meta-keys-plus-here)]
[(VALUE ...) (datum->syntax source-stx meta-values-plus-here)])
(syntax-property
(replace-context source-stx
#`(module runtime-wrapper racket/base

@ -131,4 +131,6 @@ Default separators used in decoding. The first two are initialized to @racket["\
@defoverridable[compile-cache-max-size exact-positive-integer?]{Maximum size of the compile cache. Default is 10 megabytes.}
@defoverridable[unpublished-path? (path? . -> . boolean?)]{Predicate that determines whether a path is omitted from @secref{raco_pollen_publish} operations. If the predicate is @racket[#t], then the path is omitted. The default, therefore, is @racket[#f].}
@defoverridable[unpublished-path? (path? . -> . boolean?)]{Predicate that determines whether a path is omitted from @secref{raco_pollen_publish} operations. If the predicate is @racket[#t], then the path is omitted. The default, therefore, is @racket[#f].}
@defoverridable[here-path-key symbol?]{Key used to store the absolute path of the current source file in its @racket[metas] hashtable. Default is @racket['here-path].}

@ -8,7 +8,7 @@
(define/contract+provide (metas->here metas)
(hash? . -> . pagenode?)
(path->pagenode (or (select-from-metas 'here-path metas) 'unknown)))
(path->pagenode (or (select-from-metas (world:current-here-path-key) metas) 'unknown)))
(define (pagenode->path pagenode)

@ -89,4 +89,6 @@
(define-settable compile-cache-active #t)
(define-settable compile-cache-max-size (* 10 1024 1024)) ; = 10 megabytes
(define-settable unpublished-path? (λ(path) #f))
(define-settable unpublished-path? (λ(path) #f))
(define-settable here-path-key 'here-path)
Loading…
Cancel
Save