diff --git a/pollen/core.rkt b/pollen/core.rkt index b68f266..eab3914 100644 --- a/pollen/core.rkt +++ b/pollen/core.rkt @@ -85,12 +85,15 @@ (define (convert+validate-path pagenode-or-path caller) - (let* ([path (if (pagenode? pagenode-or-path) - (build-path (current-project-root) (symbol->string pagenode-or-path)) - pagenode-or-path)] - [path (or (get-source path) path)]) - (unless (file-exists? path) - (raise-argument-error caller "existing Pollen source, or name of its output path" path)) + (let ([path (get-source (if (pagenode? pagenode-or-path) + (build-path (current-project-root) (symbol->string pagenode-or-path)) + pagenode-or-path))]) + (unless path + ;; use `pagenode-or-path` in error message because at this point `path` is #f + (raise + (make-exn:fail:filesystem + (format "~a: no source found for '~a' in directory ~a" caller pagenode-or-path (current-directory)) + (current-continuation-marks)))) path)) diff --git a/pollen/private/reader-base.rkt b/pollen/private/reader-base.rkt index 5771f38..e359fab 100644 --- a/pollen/private/reader-base.rkt +++ b/pollen/private/reader-base.rkt @@ -88,6 +88,10 @@ (my-make-drracket-buttons my-command-char)])] [(drracket:indentation) (dynamic-require 'scribble/private/indentation 'determine-spaces)] + [(drracket:default-extension) + "pm"] + [(drracket:default-filters) + '(["Pollen Sources" "*.p;*.pp;*.pmd;*.pm;*.ptree"])] [else default])))) (define-syntax-rule (reader-module-begin mode expr-to-ignore ...) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index e6488bd..aece7ea 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1513201569 +1513026723 diff --git a/pollen/scribblings/formats.scrbl b/pollen/scribblings/formats.scrbl index 4bc31a3..3b14aac 100644 --- a/pollen/scribblings/formats.scrbl +++ b/pollen/scribblings/formats.scrbl @@ -1,6 +1,6 @@ #lang scribble/manual -@(require scribble/eval pollen/render "mb-tools.rkt" pollen/setup (for-label pollen/core pollen/cache (except-in pollen/top #%top def/c) racket (except-in pollen #%module-begin) pollen/setup sugar pollen/pagetree)) +@(require scribble/eval pollen/render "mb-tools.rkt" pollen/setup (for-label pollen/cache (except-in pollen/top #%top def/c) racket (except-in pollen #%module-begin) pollen/setup sugar pollen/pagetree)) @(define my-eval (make-base-eval)) @(my-eval `(require pollen pollen/file)) @@ -48,13 +48,13 @@ By default, every Pollen source file exports two identifiers: @item{@id{metas} is a hashtable of key–value pairs with extra information that is extracted from the source. These @id{metas} will always contain the key @id{'here-path}, which returns a string representation of the full path to the source file. Beyond that, the only @id{metas} are the ones that are specified within the source file (see the source formats below for more detail on how to specify metas).} ] -As usual, you can use @racket[require], @racket[local-require], or @racket[dynamic-require] to retrieve these values. But within a Pollen project, the faster way is to use @racket[get-doc] and @racket[get-metas]. +As usual, you can use @racket[require], @racket[local-require], or @racket[dynamic-require] to retrieve these values. But within a Pollen project, the faster way is to use @racket[cached-doc] and @racket[cached-metas]. Pollen source files also make the @id{metas} hashtable available through a submodule, unsurprisingly called @id{metas}. So rather than importing a source file with @racket[(require "source.html.pm")], you can @racket[(require (submod "source.html.pm" metas))]. Accessing the metas this way avoids fully compiling the source file, and thus will usually be faster. The names @@id{doc} and @@id{metas} can be changed for a project by overriding @racket[default-main-export] and @racket[default-meta-export]. -@margin-note{The Pollen rendering system relies on these two exported identifiers, but otherwise doesn't care how they're generated. Thus, the code inside your Pollen source file could be written in @tt{#lang racket} or @tt{#lang whatever}. As long as you @racket[provide] those two identifiers and follow Pollen's file-naming conventions, your source file will be renderable.} +@margin-note{The Pollen rendering system relies on these two identifiers, but otherwise doesn't care how they're generated. Meaning, the code inside your Pollen source file could be @tt{#lang racket} or @tt{#lang whatever}. As long as you manually @racket[provide] those two identifiers and follow the usual file-naming convention, your source file will be renderable.} @bold{How is this different from Racket?} In Racket, you must explicitly @racket[define] and then @racket[provide] any values you want to export. diff --git a/pollen/scribblings/quick.scrbl b/pollen/scribblings/quick.scrbl index d334310..933564b 100644 --- a/pollen/scribblings/quick.scrbl +++ b/pollen/scribblings/quick.scrbl @@ -392,6 +392,6 @@ Now you've seen the key features of Pollen. What do you think? ] -But don't take my word for it. The rest of this documentation will show you the useful and sophisticated things you can do with Pollen. If there's another tool that suits you better, great. Keep in mind that I didn't make Pollen because I'm a programmer pushing some abstract fantasy of how writers ought to work. Rather, I'm a writer who wants to make electronic books that are better than the ones we have now. And for that, I needed a better tool. +But don't take my word for it. The rest of this documentation will show you the useful and sophisticated things you can do with Pollen. If there's another tool that suits you better, great. Keep in mind that I didn't make Pollen because I'm a programmer. I'm a writer who wants to make electronic books that are better than the ones we have now. And for that, I needed a better tool. Now I have it.