A utility module that provides functions for working with Pollen source and output files. The tests rely on file extensions specified in @racket[pollen/world].
A utility module that provides functions for working with Pollen source and output files. The tests rely on file extensions specified in @racket[pollen/world].
Pollen handles six kinds of source files:
Pollen handles seven kinds of source files:
@bold{Preprocessor}, with file extension @code[(format ".~a" world:preproc-source-ext)].
@bold{Preprocessor}, with file extension @code[(format ".~a" world:preproc-source-ext)].
@bold{Markup}, with file extension @code[(format ".~a" world:markup-source-ext)].
@bold{Markup}, with file extension @code[(format ".~a" world:markup-source-ext)].
@bold{Markdown}, with file extension @code[(format ".~a" world:markdown-source-ext)].
@bold{Template}, with file extension @code[(format ".~a" world:template-source-ext)].
@bold{Template}, with file extension @code[(format ".~a" world:template-source-ext)].
@bold{Null}, with file extension @code[(format ".~a" world:null-source-ext)].
@bold{Null}, with file extension @code[(format ".~a" world:null-source-ext)].
@ -36,6 +38,11 @@ boolean?]
[v any/c])
[v any/c])
boolean?]
boolean?]
@defproc[
(markdown-source?
[v any/c])
boolean?]
@defproc[
@defproc[
(template-source?
(template-source?
[v any/c])
[v any/c])
@ -61,6 +68,7 @@ Test whether @racket[_v] is a path representing a source file of the specified t
@examples[#:eval my-eval
@examples[#:eval my-eval
(preproc-source? "main.css.pp")
(preproc-source? "main.css.pp")
(markup-source? "default.html.pm")
(markup-source? "default.html.pm")
(markdown-source? "default.html.pmd")
(template-source? "main.html.pt")
(template-source? "main.html.pt")
(null-source? "index.html.p")
(null-source? "index.html.p")
(scribble-source? "file.scrbl")
(scribble-source? "file.scrbl")
@ -80,6 +88,11 @@ boolean?]
[v any/c])
[v any/c])
boolean?]
boolean?]
@defproc[
(has-markdown-source?
[v any/c])
boolean?]
@defproc[
@defproc[
(has-template-source?
(has-template-source?
[v any/c])
[v any/c])
@ -112,6 +125,11 @@ boolean?]
[v any/c])
[v any/c])
boolean?]
boolean?]
@defproc[
(has/is-markdown-source?
[v any/c])
boolean?]
@defproc[
@defproc[
(has/is-template-source?
(has/is-template-source?
[v any/c])
[v any/c])
@ -141,6 +159,11 @@ path?]
[p pathish?])
[p pathish?])
path?]
path?]
@defproc[
(->markdown-source-path
[p pathish?])
path?]
@defproc[
@defproc[
(->template-source-path
(->template-source-path
[p pathish?])
[p pathish?])
@ -162,12 +185,53 @@ Convert an output path @racket[_p] into the source path of the specified type th
(define name "default.html")
(define name "default.html")
(->preproc-source-path name)
(->preproc-source-path name)
(->markup-source-path name)
(->markup-source-path name)
(->markdown-source-path name)
(->template-source-path name)
(->template-source-path name)
(->scribble-source-path name)
(->scribble-source-path name)
(->null-source-path name)
(->null-source-path name)
]
]
@deftogether[
(@defproc[
(get-preproc-source
[p pathish?])
(or/c #f path?)]
@defproc[
(get-markup-source
[p pathish?])
(or/c #f path?)]
@defproc[
(get-markdown-source
[p pathish?])
(or/c #f path?)]
@defproc[
(get-template-source
[p pathish?])
(or/c #f path?)]
@defproc[
(get-null-source
[p pathish?])
(or/c #f path?)]
@defproc[
(get-scribble-source
[p pathish?])
(or/c #f path?)]
)]
Find an existing source path of the specified type that would produce the output path @racket[_p]. If there is no source of the specified type, return @racket[#f].
@defproc[
(get-source
[p pathish?])
(or/c #f path?)]
Find an existing source path that would produce the output path @racket[_p]. Check source formats in this order: @racket[get-markup-source], @racket[get-markdown-source], @racket[get-preproc-source], @racket[get-null-source], @racket[get-scribble-source]. If there is no corresponding source, return @racket[#f].
@defproc[
@defproc[
@ -181,4 +245,4 @@ Convert a source path @racket[_p] into its corresponding output path. This funct
@ -84,6 +84,29 @@ As the input contract suggests, this function can take either a single @racket[x
]
]
@defproc[
(get-doc
[doc-source (or/c pagenode? pathish?)])
(or/c txexpr? string?)]
Retrieve the @racket[doc] export from @racket[_doc-source], which can be either a path, path string, or pagenode that can be resolved into a source path. If @racket[_doc-source] cannot be resolved, raise an error.
If @racket[_doc-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
If @racket[world:current-main-export] is set to an identifier name other than @racket[doc], then that identifier is retrieved instead.
@defproc[
(get-metas
[meta-source (or/c pagenode? pathish?)])
hash?]
Retrieve the @racket[metas] export from @racket[_meta-source], which can be either a path, path string, or pagenode that can be resolved into a source path. If @racket[_meta-source] cannot be resolved, raise an error.
If @racket[_meta-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
If @racket[world:current-meta-export] is set to an identifier name other than @racket[metas], then that identifier is retrieved instead.
@deftogether[(
@deftogether[(
@defproc[
@defproc[
@ -139,7 +162,6 @@ Note that if @racket[_meta-source] is a relative path or pagenode, it is treated
]
]
@defproc[
@defproc[
(select-from-doc
(select-from-doc
[key symbolish?]
[key symbolish?]
@ -160,6 +182,9 @@ Note that if @racket[_doc-source] is a relative path or pagenode, it is treated