Compare commits
2 Commits
master
...
dev-gang-r
Author | SHA1 | Date |
---|---|---|
Matthew Butterick | e9cb0e8478 | 3 years ago |
Matthew Butterick | 5dff753c01 | 3 years ago |
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
40 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
41 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
42 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
43 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
44 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
45 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
46 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
47 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
48 file
|
@ -0,0 +1,2 @@
|
|||||||
|
#lang pollen
|
||||||
|
49 file
|
@ -0,0 +1,34 @@
|
|||||||
|
#lang br
|
||||||
|
(require racket/path
|
||||||
|
pollen/private/file-utils
|
||||||
|
racket/file)
|
||||||
|
|
||||||
|
(define sources (for/list ([p (in-directory ".")]
|
||||||
|
#:when (path-has-extension? p #"pm"))
|
||||||
|
p))
|
||||||
|
|
||||||
|
#R sources
|
||||||
|
|
||||||
|
(define temp-template (build-path "/Users/MB/Desktop/sources/template.txt"))
|
||||||
|
(define output-paths (map simplify-path (map path->complete-path (map ->output-path sources))))
|
||||||
|
#R output-paths
|
||||||
|
|
||||||
|
(define render-results
|
||||||
|
(eval (with-syntax ([MODNAME (gensym)]
|
||||||
|
[TEMPLATE-PATH-STRING (path->string temp-template)])
|
||||||
|
#`(begin
|
||||||
|
(println 'MODNAME)
|
||||||
|
(module MODNAME pollen/private/gang-helper
|
||||||
|
#:sources #,@(map path->string sources)
|
||||||
|
#:template TEMPLATE-PATH-STRING
|
||||||
|
#:result-id result)
|
||||||
|
(let ()
|
||||||
|
(local-require 'MODNAME)
|
||||||
|
result)))))
|
||||||
|
|
||||||
|
(for ([render-result (in-list render-results)]
|
||||||
|
[output-path (in-list output-paths)])
|
||||||
|
(display-to-file render-result
|
||||||
|
output-path
|
||||||
|
#:exists 'replace
|
||||||
|
#:mode (if (string? render-result) 'text 'binary)))
|
@ -0,0 +1,8 @@
|
|||||||
|
#lang br
|
||||||
|
(require racket/file)
|
||||||
|
|
||||||
|
(for ([i 50])
|
||||||
|
(display-to-file (format "#lang pollen\n~a file" i)
|
||||||
|
(string->path (format "~a.txt.pm" i))
|
||||||
|
#:exists 'replace
|
||||||
|
#:mode 'text))
|
@ -0,0 +1,6 @@
|
|||||||
|
#lang br
|
||||||
|
|
||||||
|
(module setup racket/base
|
||||||
|
(provide (all-defined-out))
|
||||||
|
#;(define render-cache-active #false)
|
||||||
|
#;(define compile-cache-active #false))
|
@ -0,0 +1 @@
|
|||||||
|
here is doc: ◊(cdr doc)
|
@ -0,0 +1,55 @@
|
|||||||
|
#lang racket/base
|
||||||
|
(require (for-syntax racket/base
|
||||||
|
syntax/strip-context
|
||||||
|
"project.rkt"
|
||||||
|
"../setup.rkt")
|
||||||
|
racket/stxparam
|
||||||
|
racket/splicing
|
||||||
|
"external/include-template.rkt"
|
||||||
|
"../cache.rkt"
|
||||||
|
"../pagetree.rkt"
|
||||||
|
"../core.rkt"
|
||||||
|
"../setup.rkt"
|
||||||
|
"../template.rkt"
|
||||||
|
"../top.rkt")
|
||||||
|
|
||||||
|
(provide (rename-out [mb #%module-begin])
|
||||||
|
(except-out (all-from-out racket/base) #%module-begin))
|
||||||
|
|
||||||
|
(define-syntax-parameter doc (λ (stx) (error 'doc-not-parameterized)))
|
||||||
|
(define-syntax-parameter metas (λ (stx) (error 'metas-not-parameterized)))
|
||||||
|
(define-syntax-parameter result (λ (stx) (error 'result-not-parameterized)))
|
||||||
|
|
||||||
|
(define-syntax (mb stx)
|
||||||
|
(syntax-case stx ()
|
||||||
|
;; markup / markdown branch
|
||||||
|
[(_ #:sources SOURCE-PATH-STRING ...
|
||||||
|
#:template TEMPLATE-PATH-STRING
|
||||||
|
#:result-id RESULT-ID)
|
||||||
|
(let ([source-path (syntax->datum (car (syntax->list #'(SOURCE-PATH-STRING ...))))])
|
||||||
|
(with-syntax ([DIRECTORY-REQUIRE-FILES
|
||||||
|
(replace-context #'here (require-directory-require-files source-path))]
|
||||||
|
[DOC-ID pollen-main-export]
|
||||||
|
[METAS-ID pollen-meta-export]
|
||||||
|
[COMMAND-CHAR (setup:command-char source-path)]
|
||||||
|
[(SUBRESULT ...) (generate-temporaries #'(SOURCE-PATH-STRING ...))])
|
||||||
|
#'(#%module-begin
|
||||||
|
DIRECTORY-REQUIRE-FILES
|
||||||
|
(splicing-syntax-parameterize
|
||||||
|
([doc (make-rename-transformer #'DOC-ID)]
|
||||||
|
[metas (make-rename-transformer #'METAS-ID)]
|
||||||
|
[result (make-rename-transformer #'RESULT-ID)])
|
||||||
|
(define SUBRESULT
|
||||||
|
(parameterize ([current-pagetree (make-project-pagetree (current-project-root))]
|
||||||
|
[current-metas (cached-metas SOURCE-PATH-STRING)])
|
||||||
|
(define doc (cached-doc SOURCE-PATH-STRING))
|
||||||
|
(define metas (current-metas))
|
||||||
|
(define here (path->pagenode
|
||||||
|
(or (select-from-metas pollen-here-path-key metas) 'unknown)))
|
||||||
|
(if (bytes? doc) ; if main export is binary, just pass it through
|
||||||
|
doc
|
||||||
|
;; allows `require` in a template
|
||||||
|
(splicing-let-syntax ([require (make-rename-transformer #'local-require)])
|
||||||
|
(include-template #:command-char COMMAND-CHAR (file TEMPLATE-PATH-STRING)))))) ...
|
||||||
|
(define result (list SUBRESULT ...))
|
||||||
|
(provide result)))))]))
|
@ -1 +1 @@
|
|||||||
1710316839
|
1656292611
|
||||||
|
Loading…
Reference in New Issue