rote 0.3.0.2 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTORS +1 -0
- data/DONE +6 -0
- data/LICENSE +1 -1
- data/README +10 -3
- data/Rakefile +1 -3
- data/TODO +18 -11
- data/doc/pages/guide/index.html +291 -87
- data/doc/res/stylesheets/normal.css +46 -4
- data/lib/rote.rb +2 -2
- data/lib/rote/app.rb +1 -1
- data/lib/rote/cache.rb +144 -0
- data/lib/rote/filters.rb +20 -4
- data/lib/rote/filters/base.rb +1 -1
- data/lib/rote/filters/bluecloth.rb +40 -0
- data/lib/rote/filters/eval.rb +58 -0
- data/lib/rote/filters/exec.rb +42 -0
- data/lib/rote/filters/rdoc.rb +1 -1
- data/lib/rote/filters/redcloth.rb +11 -9
- data/lib/rote/filters/syntax.rb +1 -1
- data/lib/rote/filters/tidy.rb +1 -1
- data/lib/rote/filters/toc.rb +1 -1
- data/lib/rote/format.rb +1 -1
- data/lib/rote/format/html.rb +1 -1
- data/lib/rote/page.rb +68 -41
- data/lib/rote/project/Rakefile +4 -5
- data/lib/rote/rotetasks.rb +1 -1
- data/test/layouts/nestme.rb +2 -0
- data/test/layouts/nestme.txt +1 -0
- data/test/pages/nestedlayout.rb +5 -0
- data/test/pages/nestedlayout.txt +1 -0
- data/test/test_cache.rb +67 -0
- data/test/{test_formatting.rb → test_filters.rb} +82 -4
- data/test/test_html_page.rb +1 -5
- data/test/test_page.rb +26 -8
- metadata +13 -8
- data/test/pages/markdown.txt +0 -8
- data/test/pages/rdoc.txt +0 -6
- data/test/pages/textile.rb +0 -3
- data/test/pages/textile.txt +0 -1
data/CONTRIBUTORS
CHANGED
data/DONE
CHANGED
@@ -20,3 +20,9 @@ being implemented.
|
|
20
20
|
** RDoc
|
21
21
|
** TOC
|
22
22
|
** Tidy
|
23
|
+
* Nested layouts
|
24
|
+
* Rake dependency caching for incremental builds, cache
|
25
|
+
layout and transient deps (contrib).
|
26
|
+
* Macro/method to run external commands and capture the output.
|
27
|
+
** (Covers Ruby eval via ruby command)
|
28
|
+
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)2005 Ross Bamford (and contributors). All rights reserved.
|
1
|
+
Copyright (c)2005, 2006 Ross Bamford (and contributors). All rights reserved.
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
4
|
this software and associated documentation files (the "Software"), to deal in
|
data/README
CHANGED
@@ -12,12 +12,19 @@ layout, and general documentation / website build tasks.
|
|
12
12
|
|
13
13
|
== Prerequisites
|
14
14
|
|
15
|
-
Rote
|
15
|
+
Rote requires the following (versions are as per my development environment,
|
16
16
|
you may find you can use older versions, you may not).
|
17
17
|
|
18
|
-
* Ruby 1.8.x
|
18
|
+
* Ruby 1.8.x (http://ruby-lang.org/)
|
19
19
|
* Rake 0.6.2 ('gem install rake')
|
20
|
-
|
20
|
+
|
21
|
+
The following optional dependencies will be used if present:
|
22
|
+
|
23
|
+
* RubyGems 0.8.11 (http://rubygems.rubyforge.org/)
|
24
|
+
* RedCloth 3.0.4 ('gem install RedCloth') (_Only required if Textile formatting is used_)
|
25
|
+
* BlueCloth 1.0.0 ('gem install BlueCloth') (_Only required if Markdown or formatting is used_)
|
26
|
+
* Syntax 1.0.0 ('gem install syntax') (_Only required if syntax highlighting formatting is used_)
|
27
|
+
* HTMLTidy (http://tidy.sourceforge.net/) (_Only required if Tidy filter is used_)
|
21
28
|
|
22
29
|
RubyGems [http://rubyforge.org/frs/?group_id=126] is *highly recommended*,
|
23
30
|
and makes for not only an easier install but a cleaner library path.
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# This Rakefile is heavily based on Rake's own Rakefile.
|
7
7
|
# Portions copyright (c)2003, 2004 Jim Weirich (jim <AT> weirichhouse.org)
|
8
8
|
#
|
9
|
-
# $Id: Rakefile
|
9
|
+
# $Id: Rakefile 128 2005-12-12 02:45:24 +0000 (Mon, 12 Dec 2005) roscopeco $
|
10
10
|
#
|
11
11
|
|
12
12
|
begin
|
@@ -204,8 +204,6 @@ else
|
|
204
204
|
s.executables = ["rote"]
|
205
205
|
s.default_executable = "rote"
|
206
206
|
|
207
|
-
s.autorequire = 'rote'
|
208
|
-
|
209
207
|
#### Documentation and testing.
|
210
208
|
|
211
209
|
s.has_rdoc = true
|
data/TODO
CHANGED
@@ -5,17 +5,24 @@ Send any suggestions or patches (preferably as/with tests) to:
|
|
5
5
|
|
6
6
|
rosco <at> roscopeco <dot> co <dot> uk
|
7
7
|
|
8
|
+
== For 0.3.x
|
9
|
+
* Plugins, maybe allow pseudo-sections to be created
|
10
|
+
in COMMON.rb, that get their pages from some supplied code.
|
11
|
+
Anything else then stays out of Rote, which is what's needed.
|
12
|
+
|
13
|
+
== For 0.3.x or 0.4
|
14
|
+
* Ability to have multiple views of a section, e.g. user guide (separate
|
15
|
+
pages) and user guide (one page) generated from same source.
|
16
|
+
* Ability to have standard sets of files (chosen by glob) treated
|
17
|
+
as sections and handled in some common way, e.g. apply a
|
18
|
+
template and highlighting to a set of Ruby files to make
|
19
|
+
a 'source xref' section with appropriate navigation and
|
20
|
+
stuff.
|
21
|
+
* If layout isn't found with source ext, try with target ext too
|
22
|
+
before failing.
|
23
|
+
|
8
24
|
== For 1.0
|
9
25
|
* CSS / XML / etc, maybe with the existing builders (integrated with
|
10
26
|
Format::CSS, Format::XML, so on)
|
11
|
-
*
|
12
|
-
|
13
|
-
in COMMON.rb, that get their pages from some supplied code.
|
14
|
-
Anything else then stays out of Rote, which is what's needed.
|
15
|
-
* Ability to have multiple views of a section, e.g. user guide (separate
|
16
|
-
pages) and user guide (one page) generated from same source.
|
17
|
-
** Maybe in concert with plugins?
|
18
|
-
* (maybe?) Rant integration
|
19
|
-
* Macro that evaluates it's body
|
20
|
-
* Macro/method to run external commands and capture the output.
|
21
|
-
* Deprecate 'rote' command supporting Rake tasks.
|
27
|
+
* As much compatibility between Page and ActionController as poss,
|
28
|
+
allowing ActionView helpers to be optionally mixed in.
|
data/doc/pages/guide/index.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
p{color:red}. *The guide is still under construction*
|
4
4
|
|
5
5
|
p. It has not yet been fully updated to cover all new features in 0.3.x.
|
6
|
-
Although most features are mentioned, in
|
6
|
+
Although most features are mentioned, in some cases the documentation consists
|
7
7
|
soley of a link to the relevant "RDoc":<%= link_rel '/rdoc/index.html' %>
|
8
8
|
|
9
9
|
<a name='top'></a>
|
@@ -46,17 +46,19 @@ case). This directory will have the following layout:
|
|
46
46
|
| | |--> rote-tiny.png
|
47
47
|
| |
|
48
48
|
| |--> layouts
|
49
|
-
| | |--> normal.
|
49
|
+
| | |--> normal.thtml
|
50
50
|
| |
|
51
51
|
| |--> pages
|
52
52
|
| |--> COMMON.rb
|
53
|
-
| |--> index.
|
53
|
+
| |--> index.thtml
|
54
54
|
| |--> index.rb
|
55
55
|
|
56
56
|
</pre></code></p>
|
57
57
|
|
58
58
|
Template sources under the 'pages' directory may have any extension (except
|
59
|
-
@rb@), and will be rendered to
|
59
|
+
@rb@), and will be rendered to the same base-name under the output directory,
|
60
|
+
with their file extension supplied by the original, possible via an
|
61
|
+
<%= section_link 'extension_mappings', 'extension mapping' %>
|
60
62
|
See the section on Layouts below for details on layout name resolution.
|
61
63
|
|
62
64
|
Ruby source is optional, and allows you to define instance variables and
|
@@ -75,13 +77,12 @@ next steps.
|
|
75
77
|
<%= section 4, 'From the command-line' %>
|
76
78
|
|
77
79
|
If you are generating a standalone documentation set (i.e. not as part of
|
78
|
-
some wider build)
|
80
|
+
some wider build) and you don't want to worry maintaining a @Rakefile@,
|
79
81
|
you can use the built-in build via the @rote@ command. This works with
|
80
|
-
|
81
|
-
|
82
|
+
the standard directory layout above, and wraps invocation of @rake@ on a
|
83
|
+
built-in version of the standard Rakefile.
|
82
84
|
|
83
|
-
|
84
|
-
configuration. To generate an entire documentation set, simply run:
|
85
|
+
Given the above layout, you can generate the documentation set by running:
|
85
86
|
|
86
87
|
<p><pre><code> rote</code></pre></p>
|
87
88
|
|
@@ -93,8 +94,9 @@ Being based on Rake, Rote supports last-modified checking, and provides an
|
|
93
94
|
individual file task for each page in your doc set. For example, running
|
94
95
|
the 'rote' command again with no options will cause it to exit almost
|
95
96
|
immediately, since all output is up to date. If you change a file, and run
|
96
|
-
rote again, then just that file will be updated.
|
97
|
-
|
97
|
+
rote again, then just that file will be updated. Even dependencies that are
|
98
|
+
determined dynamically (such as layout files) can be tracked for incremental
|
99
|
+
build purposes.
|
98
100
|
|
99
101
|
The file tasks are named for the target files, so for example to generate
|
100
102
|
just the top-level index.html (regardless of whether it's been modified)
|
@@ -118,6 +120,17 @@ Further command-line usage information is available with:
|
|
118
120
|
and Unix installations performed with @install.rb@ should also make a
|
119
121
|
manpage available for the @rote@ command.
|
120
122
|
|
123
|
+
<div class='note'>
|
124
|
+
*Note* That, for most purposes, you should prefer to use a Rakefile based
|
125
|
+
build, as created by the @rote create@ command. The command-wrapper
|
126
|
+
functionality in Rote is maintained only as a quick start option, and
|
127
|
+
is not guaranteed to remain supported in 1.0.
|
128
|
+
|
129
|
+
If you do choose to use a Rakefile approach, do *not* use the 'rote'
|
130
|
+
command to build documentation, since it will ignore your local Rakefile
|
131
|
+
and can result in inconsistent behaviour.
|
132
|
+
</div>
|
133
|
+
|
121
134
|
<%= section 4, 'From your Rakefile' %>
|
122
135
|
|
123
136
|
If you are wanting to build documentation as part of a larger build process, or
|
@@ -157,9 +170,9 @@ hierarchical structure to the common page code.
|
|
157
170
|
The default behaviour is to transform all matched pages with ERB, and
|
158
171
|
optionally apply a second render pass with a <%= section_link 'layout' %>,
|
159
172
|
before writing to the same base filename beneath the output directory.
|
160
|
-
You can customise this behaviour by specifying
|
161
|
-
|
162
|
-
section for details.
|
173
|
+
You can customise this behaviour by specifying
|
174
|
+
<%= section_link 'extension mappings' %> for specific file extensions -
|
175
|
+
see the <%= section_link 'Rake task configuration' %> section for details.
|
163
176
|
|
164
177
|
<%= section 4, 'Template code and ERB' %>
|
165
178
|
|
@@ -170,8 +183,8 @@ variables may be defined to allow information to be passed into templates.
|
|
170
183
|
There are five places where you might define such variables. The following
|
171
184
|
is in order of evaluation:
|
172
185
|
|
173
|
-
* A block supplied to <%= section_link 'extension mappings'
|
174
|
-
this page.
|
186
|
+
* A block supplied to the <%= section_link 'extension mappings', 'extension mapping' %>
|
187
|
+
that matched this page (if any).
|
175
188
|
* Any COMMON.rb files from the filesystem root down to this directory.
|
176
189
|
* This page's ruby code, _basename_.rb
|
177
190
|
* In the template itself
|
@@ -188,6 +201,10 @@ You can find details of the methods available in the
|
|
188
201
|
|
189
202
|
<%= section 4, 'Layout' %>
|
190
203
|
|
204
|
+
_Layouts_ do exactly what you'd expect - they allow common template to be
|
205
|
+
applied across several pages. This is handled via multiple render passes,
|
206
|
+
|
207
|
+
|
191
208
|
Layouts are stored under the @doc/layouts@ directory (by default). They may
|
192
209
|
be organised into subdirectories, but this hierarchy is not connected to
|
193
210
|
the hierarchy in @pages@. To apply a layout to a page, simply call the
|
@@ -216,6 +233,29 @@ This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate
|
|
216
233
|
HTML, despite the appearance from the ERB tags - any (textual) format can
|
217
234
|
be templated and laid out.
|
218
235
|
|
236
|
+
h5. Layout code
|
237
|
+
|
238
|
+
Like page templates, each layout may have associated with it some layout
|
239
|
+
code, which is executed just prior to rendering the layout, in the same
|
240
|
+
way as the page code.
|
241
|
+
|
242
|
+
There is no equivalent of @COMMON.rb@ for layout templates, however.
|
243
|
+
|
244
|
+
h5. Nested layout
|
245
|
+
|
246
|
+
Layout code (see above) may call the @Page#layout@ method (i.e. to apply
|
247
|
+
a layout). This will result in the result of the current rendering being
|
248
|
+
passed (via <code>@content_for_layout</code>) to the specified layout
|
249
|
+
in a further render pass. In all respects this is no different from the
|
250
|
+
initial layout pass - layout code is executed, and rendering performed.
|
251
|
+
Obviously, this may result in additional layouts being applied to the page.
|
252
|
+
|
253
|
+
There are no special requirements for layouts that are used in this way -
|
254
|
+
from the user point of view a layout simply needs to include the
|
255
|
+
<code>@content_for_layout</code> where appropriate.
|
256
|
+
|
257
|
+
All layouts are rendered prior to post filtering.
|
258
|
+
|
219
259
|
<%= section 4, 'Filters' %>
|
220
260
|
|
221
261
|
As well as rendering ERB and applying layout (both universal features of @Page@),
|
@@ -224,9 +264,10 @@ Along with this ability, a number of filters are provided as standard:
|
|
224
264
|
|
225
265
|
For example If you're generating HTML, you'll probably want to use some plaintext
|
226
266
|
formatting, rather than writing HTML by hand. Rote directly supports this
|
227
|
-
(thanks
|
228
|
-
|
229
|
-
|
267
|
+
(thanks to "RedCloth":http://whytheluckystiff.net/ruby/redcloth and
|
268
|
+
"BlueCloth":http://www.deveiate.org/projects/BlueCloth) via _filters_, with both
|
269
|
+
Textile and Markdown support out of the box (assuming those libraries are
|
270
|
+
available on your machine).
|
230
271
|
|
231
272
|
h5. Filter chaining
|
232
273
|
|
@@ -241,60 +282,163 @@ and _post filtering_.
|
|
241
282
|
* *Post filtering* takes place on the final output of the render pass,
|
242
283
|
after layout is applied. The @Filters::Tidy@ filter is a post filter.
|
243
284
|
|
244
|
-
h5. Standard filters
|
245
|
-
|
246
|
-
Rote supplies the following filters 'out of the box':
|
247
|
-
|
248
|
-
* *"Filters::RDoc":<%= link_rel '/rdoc/classes/Rote/Filters/RDoc.html' %>* -
|
249
|
-
Supports RDoc formatting with optional custom markup, to any supported output format
|
250
|
-
(defaults to HTML).
|
251
|
-
|
252
|
-
* *"Filters::RedCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* -
|
253
|
-
Supports both Textile and Markdown to HTML.
|
254
|
-
|
255
|
-
* *"Filters::Syntax":<%= link_rel '/rdoc/classes/Rote/Filters/Syntax.html' %>* -
|
256
|
-
Supports @code@ <%= section_link 'macros' %> with pluggable syntax highlighting
|
257
|
-
(via the "Syntax library":http://syntax.rubyforge.org/) and Ruby-code support
|
258
|
-
out of the box.
|
259
|
-
|
260
|
-
* *"Filters::Tidy":<%= link_rel '/rdoc/classes/Rote/Filters/Tidy.html' %>* -
|
261
|
-
Post filter that corrects markup and semantic errors in HTML markup to produce
|
262
|
-
valid HTML or XHTML using the "HTML Tidy":http://tidy.sourceforge.net/ command-line
|
263
|
-
tool.
|
264
|
-
|
265
|
-
* *"Filters::TOC":<%= link_rel '/rdoc/classes/Rote/Filters/TOC.html' %>* -
|
266
|
-
Supports automatic generation of navigation from headings in documents.
|
267
|
-
|
268
|
-
The first three are page filters, while the The latter two are not. Tidy is a simple
|
269
|
-
post filter (since HTML Tidy operates on full HTML documents), and should be used
|
270
|
-
with the @post_filter@ chain. TOC operates somewhat differently, requiring two
|
271
|
-
render passes - first to enumerate the sections and second to output the TOC. In practice
|
272
|
-
this means that the TOC is currently generated from layout at present.
|
273
|
-
|
274
285
|
Adding filters to a page's chain can be done anywhere you can call that page's filter-chain
|
275
286
|
methods. This could be page code, COMMON.rb, or even inside the template itself. Filters
|
276
287
|
can also be applied to all files with a matching extension by adding filters inside an
|
277
|
-
<%= section_link 'extension mapping' %> block. Bear in mind that the
|
278
|
-
are added *is* important, since each filters output becomes input
|
279
|
-
must ensure that filters are applied in a compatible order - should you
|
280
|
-
filters or otherwise modify the chain prior to rendering you may do so by
|
281
|
-
accessing the @page_filters@ and @post_filters@ array attributes.
|
288
|
+
<%= section_link 'extension mappings', 'extension mapping' %> block. Bear in mind that the
|
289
|
+
order in which filters are added *is* important, since each filters output becomes input
|
290
|
+
for the next. You must ensure that filters are applied in a compatible order - should you
|
291
|
+
need to prepend filters or otherwise modify the chain prior to rendering you may do so by
|
292
|
+
directly accessing the @page_filters@ and @post_filters@ array attributes.
|
282
293
|
|
283
294
|
See <%= section_link 'template code and erb', 'the section on template code' %>
|
284
295
|
for more information on adding code to your pages.
|
296
|
+
|
297
|
+
h5. Standard filters
|
285
298
|
|
286
|
-
|
287
|
-
|
299
|
+
Rote supplies the following filters 'out of the box':
|
300
|
+
|
301
|
+
h6. *"Filters::BlueCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* -
|
302
|
+
Supports conversion of plain-text (Markdown) formatting to HTML.
|
303
|
+
|
304
|
+
This is a text filter, and should be applied in the _page filter chain_:
|
305
|
+
|
306
|
+
#:code#ruby#
|
307
|
+
# in page code or common.rb
|
308
|
+
page_filter Filters::BlueCloth.new
|
309
|
+
#:code#
|
310
|
+
|
311
|
+
h6. *"Filters::Exec":<%= link_rel '/rdoc/classes/Rote/Filters/Exec.html' %>* -
|
312
|
+
Pipes the macro body to an external command, and replaces the macro with
|
313
|
+
the output of that command.
|
314
|
+
|
315
|
+
This is a macro filter, and should be applied in the _page filter chain_:
|
316
|
+
|
317
|
+
#:code#ruby#
|
318
|
+
# in page code or common.rb
|
319
|
+
page_filter Filters::Exec.new
|
320
|
+
#:code#
|
321
|
+
|
322
|
+
Code can then be inserted in the page like:
|
323
|
+
|
324
|
+
#:code#
|
325
|
+
#:exec#python#
|
326
|
+
print "Hello, World"
|
327
|
+
#:exec#
|
328
|
+
#:code#
|
329
|
+
|
330
|
+
h6. *"Filters::Eval":<%= link_rel '/rdoc/classes/Rote/Filters/Eval.html' %>* -
|
331
|
+
Evaluates the macro body as Ruby code, capturing standard output and using it as
|
332
|
+
the macro replacement.
|
333
|
+
|
334
|
+
This is a macro filter, and should be applied in the _page filter chain_:
|
335
|
+
|
336
|
+
#:code#ruby#
|
337
|
+
# in page code or common.rb
|
338
|
+
page_filter Filters::Eval.new
|
339
|
+
#:code#
|
340
|
+
|
341
|
+
Code can then be inserted in the page like:
|
342
|
+
|
343
|
+
#:code#
|
344
|
+
#:eval#
|
345
|
+
puts "Hello, World"
|
346
|
+
#:eval#
|
347
|
+
#:code#
|
348
|
+
|
349
|
+
h6. *"Filters::RDoc":<%= link_rel '/rdoc/classes/Rote/Filters/RDoc.html' %>* -
|
350
|
+
Supports RDoc formatting with optional custom markup, to any supported output format
|
351
|
+
(defaults to HTML).
|
352
|
+
|
353
|
+
This is a text filter, and should be applied in the _page filter chain_:
|
354
|
+
|
355
|
+
#:code#ruby#
|
356
|
+
# in page code or common.rb
|
357
|
+
page_filter Filters::RDoc.new
|
358
|
+
#:code#
|
359
|
+
|
360
|
+
h6. *"Filters::RedCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* -
|
361
|
+
Supports conversion of plain-text (Textile) formatting to HTML.
|
362
|
+
|
363
|
+
This is a text filter, and should be applied in the _page filter chain_:
|
364
|
+
|
365
|
+
#:code#ruby#
|
366
|
+
# in page code or common.rb
|
367
|
+
page_filter Filters::RedCloth.new
|
368
|
+
#:code#
|
369
|
+
|
370
|
+
h6. *"Filters::Syntax":<%= link_rel '/rdoc/classes/Rote/Filters/Syntax.html' %>* -
|
371
|
+
Supports @code@ <%= section_link 'macros' %> with pluggable syntax highlighting
|
372
|
+
(via the "Syntax library":http://syntax.rubyforge.org/) and Ruby-code support
|
373
|
+
out of the box.
|
374
|
+
|
375
|
+
This is a macro filter, and should be applied in the _page filter chain_:
|
376
|
+
|
377
|
+
#:code#ruby#
|
378
|
+
# in page code or common.rb
|
379
|
+
page_filter Filters::Syntax.new
|
380
|
+
#:code#
|
381
|
+
|
382
|
+
This filter uses the "Syntax":http://syntax.rubyforge.org/ library, passing the
|
383
|
+
macro argument as the language ('ruby', 'xml' and 'yaml' are supported out of the
|
384
|
+
box). The output is wrapped in <pre class='[language]'><code> ... </code></pre>
|
385
|
+
for output, with highlighting handled by <span> tags, allowing syntax colours and
|
386
|
+
styles to be applied via CSS. You can find a full list of the Ruby highlight classes
|
387
|
+
in the
|
388
|
+
"Syntax documentation":http://syntax.rubyforge.org/chapter-2.html
|
389
|
+
but you will need to experiment with the highlighter to find the XML and YAML
|
390
|
+
classes.
|
391
|
+
|
392
|
+
Code to be highlighted is inserted into pages like so:
|
393
|
+
|
394
|
+
#:code#
|
395
|
+
#:code#[language]#
|
396
|
+
def amethod
|
397
|
+
"some code"
|
398
|
+
end
|
399
|
+
# :code#
|
400
|
+
#:code#
|
288
401
|
|
289
|
-
|
402
|
+
<div class='note'>
|
403
|
+
*Note* that in the above example, the end tag has an extra whitespace to work around
|
404
|
+
a limitation of the Syntax plugin (and macros in general) - a macro cannot contain
|
405
|
+
it's own end tag!
|
406
|
+
</div>
|
407
|
+
|
408
|
+
Since macros are rendered separately from the page text, you don't have to worry much
|
409
|
+
about spacing and so forth - your code will not be touched by any of the formatting
|
410
|
+
filters.
|
411
|
+
|
412
|
+
h6. *"Filters::Tidy":<%= link_rel '/rdoc/classes/Rote/Filters/Tidy.html' %>* -
|
413
|
+
Post filter that corrects markup and semantic errors in HTML markup to produce
|
414
|
+
valid HTML or XHTML using the "HTML Tidy":http://tidy.sourceforge.net/ command-line
|
415
|
+
tool.
|
416
|
+
|
417
|
+
This is a *post filter*. It should be applied in the appropriate filter chain:
|
418
|
+
|
419
|
+
#:code#ruby#
|
420
|
+
# in page code or common.rb
|
421
|
+
post_filter Filters::Tidy.new
|
422
|
+
#:code#
|
423
|
+
|
424
|
+
h6. *"Filters::TOC":<%= link_rel '/rdoc/classes/Rote/Filters/TOC.html' %>* -
|
425
|
+
Supports automatic generation of basic navigation from headings in documents.
|
426
|
+
See the RDoc for more details. It should be applied as a page filter, and
|
427
|
+
a reference is usually required for use in the layout:
|
428
|
+
|
429
|
+
#:code#ruby#
|
430
|
+
# in page code or common.rb
|
431
|
+
post_filter @toc = Filters::TOC.new
|
432
|
+
#:code#
|
290
433
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
434
|
+
Some of the filters support various options to change the way they operate, and
|
435
|
+
many support different arguments (the second part of the #macro#args# tags) to
|
436
|
+
those shown above - see the RDoc for the individual macros (linked from the headings
|
437
|
+
above) for more details.
|
295
438
|
|
296
|
-
|
297
|
-
|
439
|
+
Filters are of course very simple to write. See the 'Writing filters' subsection
|
440
|
+
(in <%= section_link 'Extending Rote' %>) for details, including how to implement
|
441
|
+
your own macro filters.
|
298
442
|
|
299
443
|
<%= section 4, 'Format helpers' %>
|
300
444
|
|
@@ -328,7 +472,7 @@ include Rote
|
|
328
472
|
|
329
473
|
# This defines all our Rake tasks. The symbol we supply here (:doc is
|
330
474
|
# default) gives the base-prefix for the tasks that are generated.
|
331
|
-
ws = Rote::DocTask.new(:doc)
|
475
|
+
ws = Rote::DocTask.new(:doc) do |doc|
|
332
476
|
# Output directory and layout sources
|
333
477
|
doc.output_dir = 'html'
|
334
478
|
doc.layout_dir = 'doc/layouts'
|
@@ -361,7 +505,7 @@ ws = Rote::DocTask.new(:doc) { |doc|
|
|
361
505
|
# To valid xhtml with Tidy postfilter
|
362
506
|
page.post_filter Filters::Tidy
|
363
507
|
end
|
364
|
-
|
508
|
+
end
|
365
509
|
#:code#
|
366
510
|
|
367
511
|
Please refer to the "RDoc":<%= link_rel '/rdoc/classes/Rote/DocTask.html' %> for specific
|
@@ -370,7 +514,7 @@ information on each method.
|
|
370
514
|
<%= section 4, 'Extension mappings' %>
|
371
515
|
|
372
516
|
The default behaviour when transforming pages is to make each filename
|
373
|
-
matched by the @pages.include@
|
517
|
+
matched by the @pages.include@ glob relative to the output directory, using
|
374
518
|
the same extension as the input file.
|
375
519
|
|
376
520
|
If you want to change this behaviour, you may supply an _extension mapping_
|
@@ -380,22 +524,27 @@ as demonstrated above. The general form is:
|
|
380
524
|
# Define an extension mapping
|
381
525
|
doc.ext_mapping(/regexp/, 'replacement') do |page|
|
382
526
|
|
383
|
-
|
527
|
+
# call page methods
|
384
528
|
|
385
529
|
end
|
386
530
|
#:code#
|
387
531
|
|
388
532
|
The regexp is matched against processed page extensions (not resources) and
|
389
533
|
the replacement supplies the output extension. The optional block is executed
|
390
|
-
for each page
|
391
|
-
Note that you must not include the '.' in either the regexp or
|
534
|
+
*for each matching page* during instantiation, before any COMMON or page
|
535
|
+
code. Note that you *must not* include the leading '.' in either the regexp or
|
536
|
+
replacement - doing so will fail to match the desired extensions.
|
392
537
|
|
393
538
|
For more advanced mappings, you can supply a capturing regexp, and use the
|
394
|
-
@$n@ notation in the replacement to extract the
|
395
|
-
(contrived) example
|
539
|
+
@$n@ notation in the replacement to extract the captures. As shown in the
|
540
|
+
(contrived) example below:
|
396
541
|
|
397
542
|
#:code#ruby#
|
398
543
|
doc.ext_mapping(/(html)/, '$1') do |page|
|
544
|
+
|
545
|
+
# do stuff
|
546
|
+
|
547
|
+
end
|
399
548
|
#:code#
|
400
549
|
|
401
550
|
<%= section 4, 'Defining additional tasks' %>
|
@@ -474,6 +623,9 @@ the publishers supplied with Rake (in @rake/contrib@), or your own. This
|
|
474
623
|
allows maximum flexibility, and allows Rote to concentrate on creating your
|
475
624
|
documents.
|
476
625
|
|
626
|
+
See the section <%= section_link 'Defining additional tasks' %> for details on
|
627
|
+
how to supply your publish tasks.
|
628
|
+
|
477
629
|
See the <%= section_link 'rake task configuration' %> section for more details.
|
478
630
|
|
479
631
|
<%= section 3, 'Extending Rote' %>
|
@@ -494,7 +646,7 @@ Either type can be a page or post filter - it depends only on the design
|
|
494
646
|
of the filter and the job it will perform as to which chain it should
|
495
647
|
be used with.
|
496
648
|
|
497
|
-
h5. Text
|
649
|
+
h5. Text Filters
|
498
650
|
|
499
651
|
Text filters process the text in a page, with all macros replaced by a
|
500
652
|
standard plain-text marker. The purpose of this is to allow macros
|
@@ -549,12 +701,12 @@ end
|
|
549
701
|
|
550
702
|
Note the curly braces in the first example, which cause the block to bind
|
551
703
|
to the filter rather than the method. If @do..end@ were used, the second
|
552
|
-
form would actually be called and a new filter created. The filter you
|
704
|
+
form would actually be called and a new filter created. The block filter you
|
553
705
|
supplied would be discarded.
|
554
706
|
|
555
707
|
The @post_filter@ method supports the same convenience.
|
556
708
|
|
557
|
-
h5. Macro
|
709
|
+
h5. Macro Filters
|
558
710
|
|
559
711
|
The standard Syntax filter is a typical macro filter. The following is
|
560
712
|
slightly simplified for brevity (the actual one allows custom macro tags
|
@@ -591,30 +743,82 @@ with <%= section_link 'extension mappings' %>.
|
|
591
743
|
<%= section_link 'text filters' %>. The output, however, *will* be processed
|
592
744
|
by any filters that follow the macro filter in the chain.
|
593
745
|
|
594
|
-
h5. Duck
|
746
|
+
h5. Duck Filters
|
595
747
|
|
596
748
|
This being Ruby, you don't _have_ to inherit one of the above filters to create
|
597
749
|
your own - a filter is just an object with a @filter(text,page)@ method.
|
598
750
|
|
599
751
|
The standard TOC filter takes this route.
|
600
752
|
|
601
|
-
<%= section
|
753
|
+
<%= section 4, 'Rake Extensions' %>
|
602
754
|
|
603
|
-
|
755
|
+
Rote supplies a number of non-intrusive extensions a number of the Rake classes,
|
756
|
+
in order to support dynamic dependency caching, caching dependency-based block
|
757
|
+
memoize, and task reset for use in monitor mode. These features are very new, and
|
758
|
+
only lightly documented at present. You are advised to see the
|
759
|
+
"RDoc":<%= link_rel '/rdoc' %> and source if you want to find out more.
|
604
760
|
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
761
|
+
These extensions were almost exclusively contributed by Jonathan Paisley.
|
762
|
+
|
763
|
+
h5. Dynamic dependency caching
|
764
|
+
|
765
|
+
Since layout files are specified in Ruby code, and may be calculated dynamically,
|
766
|
+
it's not possible to determine the layout files upon which a given page depends
|
767
|
+
without running that page's code (including all COMMON.rb files that apply to it,
|
768
|
+
extension mapping blocks, and so forth). This would have (or, had) an adverse
|
769
|
+
impact on Rote's incremental build functionality, especially from the point of
|
770
|
+
view of source monitoring.
|
771
|
+
|
772
|
+
This problem is addressed by a small Rake extension that adds the ability to
|
773
|
+
dynamically register dependencies on the current task, and to have those
|
774
|
+
dependencies cached when Rake exits. Internally, Rote automatically registers
|
775
|
+
any layouts loaded by a page, and you can easily register additional dependencies
|
776
|
+
from any Ruby code, by calling methods on the @Rake@ module.
|
777
|
+
|
778
|
+
*Note* that this extension is intended, and tested, for Rote - it is not designed
|
779
|
+
to be a general extension (though one could easily be extracted from it). In
|
780
|
+
particular it takes advantage of other extended functionality provided by Rote,
|
781
|
+
and takes no account, for example, or parallel task execution.
|
782
|
+
|
783
|
+
By default, the cache is maintained in the project root, in a directory named
|
784
|
+
@.rake_cache@. This is managed by Rote, so for the most part can be ignored,
|
785
|
+
though you can of course supply an alternate path if you wish (via @Rake.cache_dir=@).
|
786
|
+
|
787
|
+
h5. Dependency-based block memoize
|
788
|
+
|
789
|
+
Somewhat related to dependency caching, Rote also provides the ability to memoize
|
790
|
+
Ruby block results, caching them to disk, and only execute the block during
|
791
|
+
incremental builds. This is handy if, for example, you want to incorporate information
|
792
|
+
derived from external commands, for example, or index large files in your documentation.
|
793
|
+
|
794
|
+
The following (OSX-specific) example illustrates usage of this feature:
|
795
|
+
|
796
|
+
#:code#ruby#
|
797
|
+
def image_size(fn)
|
798
|
+
Rake::Task.memoize "image_size" => fn do
|
799
|
+
# This code only runs if the cache is out-of-date with
|
800
|
+
# respect to the file
|
801
|
+
puts "image_size for #{fn}"
|
802
|
+
|
803
|
+
# OSX-specific stuff here
|
804
|
+
s = `sips -g pixelWidth -g pixelHeight #{fn}`
|
805
|
+
[s[/pixelWidth: (\d+)/,1], s[/pixelHeight: (\d+)/,1]]
|
806
|
+
end
|
807
|
+
end
|
808
|
+
#:code#
|
809
|
+
|
810
|
+
h6. Caching and clean builds
|
811
|
+
|
812
|
+
When performing a clean build, the cache will also be removed (as part of the
|
813
|
+
@clobber@ task), and all dependencies will be re-evaluated and cached afresh.
|
814
|
+
Caching exists only to allow accurate dependency resolution during incremental
|
815
|
+
builds.
|
816
|
+
|
817
|
+
<%= section 3, 'Final notes' %>
|
614
818
|
|
615
819
|
Rake is a *very* flexible tool, and supports a wide variety of configuration
|
616
820
|
options and advanced features you can use to fit Rote to your needs. Such
|
617
|
-
configuration is beyond the scope of this manual - see
|
821
|
+
configuration is (far) beyond the scope of this manual - see
|
618
822
|
"Rake's Documentation":http://rake.rubyforge.org/ for information on the
|
619
823
|
features supported by Rake.
|
620
824
|
|