You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pollen/scribblings/ptree.scrbl

51 lines
2.4 KiB
Plaintext

11 years ago
#lang scribble/manual
11 years ago
@(require scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world pollen/ptree txexpr sugar pollen/decode xml))
11 years ago
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/ptree))
@section{Ptrees}
@defmodule[pollen/ptree]
11 years ago
A @italic{ptree} — short for @italic{Pollen tree} — is a hierarchical list of Pollen output files. A ptree source file has the extension @code[(format ".~a" world:ptree-source-ext)]. A ptree provides a convenient way of separating the structure of the pages from the page sources, and navigating around this structure.
11 years ago
11 years ago
Books and other long documents are usually organized in a structured way — at minimum they have a sequence of pages, but more often they have sections with subsequences within. Individual Pollen source files don't know anything about how they're connected to other files. In theory, you could maintain this information within each source file. This would be a poor use of human energy. Let the ptree figure it out.
11 years ago
@defproc[
(ptree?
[v any/c])
boolean?]
11 years ago
Test whether @racket[_v] is a valid ptree: a @racket[txexpr?] whose elements are either @racket[pnode?] or @racket[ptree?]. Also, all the pnodes in a ptree must be unique. The root node is ignored.
11 years ago
@examples[#:eval my-eval
11 years ago
(ptree? '(root index.html))
(ptree? '(root index.html index.html))
(define nested-pt '(root 1.html 2.html (3.html 3a.html 3b.html)))
11 years ago
(ptree? nested-pt)
11 years ago
(ptree? `(root index.html ,nested-pt (subsection.html more.html)))
(ptree? `(root index.html ,nested-pt (subsection.html ,nested-pt)))
11 years ago
]
11 years ago
@defproc[
(pnode?
[v any/c])
boolean?]
Test whether @racket[_v] is a valid pnode. Every leaf of a ptree is a pnode. A pnode can be any @racket[stringish?] value that is both an @racket[xexpr?] and not @racket[whitespace/nbsp?] In practice, your pnodes will likely be names of output files.
@examples[#:eval my-eval
(map pnode? (list 'symbol "string" "index.html" "\n\n ah! \n\n"))
(map pnode? (list 9.999 (string->path "index.html") '(p "Hello") "\n\n"))
]
@defparam[current-ptree ptree ptree?
#:value #f]{
A parameter that defines the default ptree used by ptree navigation functions if another is not explicitly specified.}
@defparam[current-url-context dir path?
#:value world:current-project-root]{
A parameter that defines the default directory used to resolve @racket[pnode->url]. Initialized to the root directory of the current project.}