From 70f3d46c1fe52d4506d0099913a021000db71e9c Mon Sep 17 00:00:00 2001 From: Henry Blevins Date: Sat, 16 Jan 2016 16:42:45 -0600 Subject: [PATCH] Added markdown functions and examples. Added definition for `->source-path` function. --- scribblings/file.scrbl | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/scribblings/file.scrbl b/scribblings/file.scrbl index bf39285..857782b 100644 --- a/scribblings/file.scrbl +++ b/scribblings/file.scrbl @@ -11,12 +11,14 @@ 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{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{Null}, with file extension @code[(format ".~a" world:null-source-ext)]. @@ -36,6 +38,11 @@ boolean?] [v any/c]) boolean?] +@defproc[ +(markdown-source? +[v any/c]) +boolean?] + @defproc[ (template-source? [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 (preproc-source? "main.css.pp") (markup-source? "default.html.pm") +(markdown-source? "default.html.pmd") (template-source? "main.html.pt") (null-source? "index.html.p") (scribble-source? "file.scrbl") @@ -80,6 +88,11 @@ boolean?] [v any/c]) boolean?] +@defproc[ +(has-markdown-source? +[v any/c]) +boolean?] + @defproc[ (has-template-source? [v any/c]) @@ -112,6 +125,11 @@ boolean?] [v any/c]) boolean?] +@defproc[ +(has/is-markdown-source? +[v any/c]) +boolean?] + @defproc[ (has/is-template-source? [v any/c]) @@ -141,6 +159,11 @@ path?] [p pathish?]) path?] +@defproc[ +(->markdown-source-path +[p pathish?]) +path?] + @defproc[ (->template-source-path [p pathish?]) @@ -162,13 +185,19 @@ Convert an output path @racket[_p] into the source path of the specified type th (define name "default.html") (->preproc-source-path name) (->markup-source-path name) +(->markdown-source-path name) (->template-source-path name) (->scribble-source-path name) (->null-source-path name) ] +Convert an output path @racket[_p] into the source path of the specified type that would produce this output path. This function simply generates a path for a file — it does not ask whether the file exists. - +@defproc[ +(->source-path +[p pathish?]) +(or/c #f path?)] +Attempt to automatically convert an output path @racket[_p] into its source path. This function checks for the existence of the path with the extensions for markup, markdown, preprocessor, null, and scribble files. @defproc[ (->output-path @@ -181,4 +210,4 @@ Convert a source path @racket[_p] into its corresponding output path. This funct (->output-path "default.html.pm") (->output-path "index.html.p") (->output-path "file.scrbl") -] \ No newline at end of file +]