From 109844424ea7e2b0ae9fd6b7e8ff0b133c7643bf Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 25 May 2020 23:48:54 -0700 Subject: [PATCH] downgrade certain configurable setup values --- pollen/scribblings/setup.scrbl | 19 ---------- pollen/scribblings/version-history.scrbl | 4 +++ pollen/setup.rkt | 45 +++++++++++++++--------- pollen/test/test-override.rkt | 44 ----------------------- 4 files changed, 32 insertions(+), 80 deletions(-) delete mode 100644 pollen/test/test-override.rkt diff --git a/pollen/scribblings/setup.scrbl b/pollen/scribblings/setup.scrbl index 2d10473..e9d74c0 100644 --- a/pollen/scribblings/setup.scrbl +++ b/pollen/scribblings/setup.scrbl @@ -55,24 +55,10 @@ Every @racket[setup:]@racket[_name] function will resolve the current value of t Determines the default HTTP port for the project server.} -@defoverridable[main-export symbol?]{The main X-expression exported from a compiled Pollen source file.} - -@defoverridable[meta-export symbol?]{The meta hashtable exported from a compiled Pollen source file.} @defoverridable[extension-escape-char char?]{Character for escaping output-file extensions within source-file names.} -@deftogether[( -@defoverridable[preproc-source-ext symbol?] -@defoverridable[markup-source-ext symbol?] -@defoverridable[markdown-source-ext symbol?] -@defoverridable[null-source-ext symbol?] -@defoverridable[pagetree-source-ext symbol?] -@defoverridable[template-source-ext symbol?] -@defoverridable[scribble-source-ext symbol?] -)]{File extensions for Pollen source files.} - - @defoverridable[main-pagetree string?]{Pagetree that Pollen dashboard loads by default in each directory.} @@ -89,8 +75,6 @@ Determines the default HTTP port for the project server.} @defoverridable[command-char char?]{The magic character that indicates a Pollen command, function, or variable.} -@defoverridable[template-prefix string?]{Prefix of the default template.} - @deftogether[( @(defoverridable newline string?) @@ -147,9 +131,6 @@ Both the names and the values of environment variables are case-insensitive, so @history[#:added "1.1"]} -@defoverridable[poly-source-ext symbol?]{Extension that indicates a source file can target multiple output types.} - - @defoverridable[poly-targets (listof symbol?)]{List of symbols that denotes the possible targets of a @racket['poly] source file.} diff --git a/pollen/scribblings/version-history.scrbl b/pollen/scribblings/version-history.scrbl index 8c8cf86..73b5708 100644 --- a/pollen/scribblings/version-history.scrbl +++ b/pollen/scribblings/version-history.scrbl @@ -24,6 +24,10 @@ Beyond keeping the commit history available, I make no promise to maintain the p @section{Changelog} +@subsection{Version 3.0} + +Downgraded the following @racket[pollen/setup] values from configurable to fixed: @racket[splicing-tag], @racket[preproc-source-ext], @racket[markup-source-ext], @racket[markdown-source-ext], @racket[null-source-ext], @racket[pagetree-source-ext], @racket[template-source-ext], @racket[scribble-source-ext], @racket[poly-source-ext], @racket[cache-dir-name], @racket[cache-subdir-name], @racket[template-prefix], @racket[fallback-template-prefix], @racket[template-meta-key], @racket[main-export], @racket[meta-export], @racket[meta-tag-name], @racket[define-meta-name]. + @subsection{Version 2.2} Added @racket[--null] and @racket[--dry-run] switches to @secref["raco_pollen_render" #:doc '(lib "pollen/scribblings/pollen.scrbl")]. diff --git a/pollen/setup.rkt b/pollen/setup.rkt index bc9662e..06cbc7f 100644 --- a/pollen/setup.rkt +++ b/pollen/setup.rkt @@ -55,16 +55,27 @@ 'NAME (λ () DEFAULT-NAME))))))])) +(define-syntax (define-settable-not stx) + (syntax-case stx () + [(_ NAME DEFAULT-VALUE) + (with-syntax ([DEFAULT-NAME (format-id stx "default-~a" #'NAME)] + [NAME-THUNKED (format-id stx "~a" #'NAME)]) + #'(begin + (provide (prefix-out setup: NAME-THUNKED) DEFAULT-NAME) + (define DEFAULT-NAME DEFAULT-VALUE) + ;; can take a dir argument that sets start point for (get-path-to-override) search. + (define (NAME-THUNKED [dir #false]) DEFAULT-NAME)))])) + (define-settable cache-watchlist null) (define-settable envvar-watchlist null) -(define-settable preproc-source-ext 'pp) -(define-settable markup-source-ext 'pm) -(define-settable markdown-source-ext 'pmd) -(define-settable null-source-ext 'p) -(define-settable pagetree-source-ext 'ptree) -(define-settable template-source-ext 'pt) -(define-settable scribble-source-ext 'scrbl) +(define-settable-not preproc-source-ext 'pp) +(define-settable-not markup-source-ext 'pm) +(define-settable-not markdown-source-ext 'pmd) +(define-settable-not null-source-ext 'p) +(define-settable-not pagetree-source-ext 'ptree) +(define-settable-not template-source-ext 'pt) +(define-settable-not scribble-source-ext 'scrbl) ;; these are deliberately not settable because they're just internal signalers, no effect on external interface (define+provide default-mode-auto 'auto) @@ -75,8 +86,8 @@ (define+provide default-mode-template 'template) (define-settable old-cache-names '("pollen.cache" "pollen-cache")) -(define-settable cache-dir-name "compiled") -(define-settable cache-subdir-name "pollen") +(define-settable-not cache-dir-name "compiled") +(define-settable-not cache-subdir-name "pollen") (define+provide default-cache-names (list* (cache-dir-name) (old-cache-names))) (define-settable decodable-extensions (list (markup-source-ext) (pagetree-source-ext))) @@ -88,14 +99,14 @@ (define-settable command-char #\◊) (define-settable template-command-char #\∂) -(define-settable template-prefix "template") -(define-settable fallback-template-prefix "fallback") -(define-settable template-meta-key "template") +(define-settable-not template-prefix "template") +(define-settable-not fallback-template-prefix "fallback") +(define-settable-not template-meta-key "template") -(define-settable main-export 'doc) ; don't forget to change fallback template too -(define-settable meta-export 'metas) -(define-settable meta-tag-name 'meta) -(define-settable define-meta-name 'define-meta) +(define-settable-not main-export 'doc) ; don't forget to change fallback template too +(define-settable-not meta-export 'metas) +(define-settable-not meta-tag-name 'meta) +(define-settable-not define-meta-name 'define-meta) ;; tags from https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements (define-settable block-tags (cons (main-root-node) '(address article aside blockquote body canvas dd div dl fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr li main nav noscript ol output p pre section table tfoot ul video))) @@ -141,7 +152,7 @@ (define-settable here-path-key 'here-path) -(define-settable poly-source-ext 'poly) ; extension that signals source can be used for multiple output targets +(define-settable-not poly-source-ext 'poly) ; extension that signals source can be used for multiple output targets (define-settable poly-targets '(html)) ; current target applied to multi-output source files (define+provide current-poly-target (make-parameter (car (poly-targets)))) diff --git a/pollen/test/test-override.rkt b/pollen/test/test-override.rkt deleted file mode 100644 index 902f797..0000000 --- a/pollen/test/test-override.rkt +++ /dev/null @@ -1,44 +0,0 @@ -#lang at-exp racket/base -(require rackunit racket/port racket/system racket/runtime-path compiler/find-exe pollen/setup) - -;; define-runtime-path only allowed at top level -(define-runtime-path override-dir "data/override") -(define-runtime-path test.ptree "data/override/test.ptree") -(define-runtime-path test.html.pm "data/override/test.html.pm") -(define-runtime-path test.html.pmd "data/override/test.html.pmd") -(define-runtime-path test.html.pp "data/override/test.html.pp") - -(define-runtime-path test.ptreeover "data/override/test.ptreeover") -(define-runtime-path test.html.pmover "data/override/test.html.pmover") -(define-runtime-path test.html.pmdover "data/override/test.html.pmdover") -(define-runtime-path test.html.ppover "data/override/test.html.ppover") -(define-runtime-path test-cmd.html.ppover "data/override/test-cmd.html.ppover") -(define-runtime-path test-exports.html.ppover "data/override/test-exports.html.ppover") -(define-runtime-path test-require.html.pmover "data/override/test-require.html.pmover") - - -;; `find-exe` avoids reliance on $PATH of the host system -(define racket-path (find-exe)) -;; parameterize needed to pick up override file -(parameterize ([current-directory override-dir] - [current-project-root override-dir]) - (when racket-path - (define (run path) - (define cmd-string (format "'~a' ~a" racket-path path)) - (with-output-to-string (λ () (system cmd-string)))) - ;; raco is in same dir as racket - (define path-to-raco (path->string (simplify-path (build-path (find-exe) 'up "raco")))) - ;; files with ordinary extensions will not be recognized in override dir, and thus behave like preproc - (check-equal? (run test.ptree) "test\n====") - (check-equal? (run test.html.pm) "test\n====") - (check-equal? (run test.html.pmd) "test\n====") - (check-equal? (run test.html.pp) "test\n====") - - (check-equal? (run test.ptreeover) "'(pagetree-root test ====)") - (check-equal? (run test.html.pmover) "'(rootover \"test\" \"\\n\" \"====\")") - (check-equal? (run test.html.pmdover) "'(rootover (h1 ((id \"test\")) \"test\"))") - (check-equal? (run test.html.ppover) "test\n====") -(check-equal? (run test-cmd.html.ppover) "2") - (check-equal? (dynamic-require test-exports.html.ppover 'docover) "2") - (check-equal? (hash-ref (dynamic-require test-exports.html.ppover 'metasover) 'dog) "Roxy") - (check-equal? (dynamic-require test-require.html.pmover 'docover) '(rootover "foobar"))))