|
|
|
@ -152,11 +152,18 @@
|
|
|
|
|
(reset-mod-date-hash!)
|
|
|
|
|
(define expanded-source-paths
|
|
|
|
|
(let loop ([paths paths-in] [acc null])
|
|
|
|
|
(match (and (pair? paths) (->complete-path (car paths)))
|
|
|
|
|
[#false (sort (remove-duplicates acc) string<? #:key path->string)]
|
|
|
|
|
[(? pagetree-source? pt) (loop (append (pagetree->paths pt) (cdr paths)) acc)]
|
|
|
|
|
[(app ->source-path (and (not #false) (? file-exists?) sp)) (loop (cdr paths) (cons sp acc))]
|
|
|
|
|
[_ (loop (cdr paths) acc)])))
|
|
|
|
|
(match paths
|
|
|
|
|
[(? null?) (sort (remove-duplicates acc) string<? #:key path->string)]
|
|
|
|
|
[(cons path rest)
|
|
|
|
|
(match (->complete-path path)
|
|
|
|
|
[(? pagetree-source? pt)
|
|
|
|
|
(loop (append (pagetree->paths pt) rest) acc)]
|
|
|
|
|
[(app ->source-path (and (not #false) (? file-exists?) sp))
|
|
|
|
|
(loop rest (cons sp acc))]
|
|
|
|
|
[(or (? file-exists?) (? directory-exists?)) (loop rest acc)]
|
|
|
|
|
[unknown (raise-user-error 'render-batch
|
|
|
|
|
"~a is not a source path, directory, or output path"
|
|
|
|
|
unknown)])])))
|
|
|
|
|
(cond
|
|
|
|
|
[(null? expanded-source-paths) (message "[no paths to render]")]
|
|
|
|
|
[wants-dry-run? (for-each message expanded-source-paths)]
|
|
|
|
@ -196,7 +203,7 @@
|
|
|
|
|
(define output-path (cond
|
|
|
|
|
[maybe-output-path]
|
|
|
|
|
[(->output-path source-path)]
|
|
|
|
|
[else (raise-argument-error caller "valid output path" output-path)]))
|
|
|
|
|
[else (raise-argument-error caller "valid output path" maybe-output-path)]))
|
|
|
|
|
(define template-path (cond
|
|
|
|
|
[maybe-template-path]
|
|
|
|
|
[(get-template-for source-path output-path)]
|
|
|
|
@ -320,17 +327,16 @@
|
|
|
|
|
(cond
|
|
|
|
|
[maybe-output-path]
|
|
|
|
|
[(->output-path source-path)]
|
|
|
|
|
[else (raise-argument-error 'render-markup-or-markdown-source "valid output path" output-path)]))
|
|
|
|
|
[else (raise-argument-error 'render-markup-or-markdown-source "valid output path" maybe-output-path)]))
|
|
|
|
|
(define template-path
|
|
|
|
|
(cond
|
|
|
|
|
[maybe-template-path]
|
|
|
|
|
[(get-template-for source-path output-path)]
|
|
|
|
|
[else (raise-argument-error 'render-markup-or-markdown-source
|
|
|
|
|
(format "valid template path~a"
|
|
|
|
|
[else (raise-user-error 'render-markup-or-markdown-source
|
|
|
|
|
"couldn't find template~a"
|
|
|
|
|
(if (has-inner-poly-ext? source-path)
|
|
|
|
|
(format " for target ~a" (current-poly-target))
|
|
|
|
|
""))
|
|
|
|
|
template-path)]))
|
|
|
|
|
(format " for target .~a" (current-poly-target))
|
|
|
|
|
""))]))
|
|
|
|
|
|
|
|
|
|
;; use a temp file so that multiple (possibly parallel) renders
|
|
|
|
|
;; do not compete for write access to the same template
|
|
|
|
|