rote 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +1 -1
- data/{README → README.md} +46 -36
- data/Rakefile +56 -48
- data/bin/rote +19 -16
- data/doc/layouts/page.html +2 -2
- data/doc/pages/COMMON.rb +3 -5
- data/doc/pages/guide/COMMON.rb +1 -1
- data/doc/pages/guide/index.html +139 -421
- data/doc/pages/index.html +11 -31
- data/doc/pages/license.html +1 -1
- data/lib/rote.rb +3 -3
- data/lib/rote/app.rb +4 -4
- data/lib/rote/cache.rb +9 -8
- data/lib/rote/extratasks.rb +11 -3
- data/lib/rote/filters.rb +1 -1
- data/lib/rote/filters/base.rb +1 -1
- data/lib/rote/filters/bluecloth.rb +1 -1
- data/lib/rote/filters/rdoc.rb +5 -6
- data/lib/rote/filters/redcloth.rb +3 -5
- data/lib/rote/filters/syntax.rb +1 -1
- data/lib/rote/filters/tidy.rb +2 -2
- 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 +4 -4
- data/lib/rote/project/Rakefile +1 -1
- data/lib/rote/rotetasks.rb +3 -3
- data/test/test_cache.rb +3 -0
- data/test/test_filters.rb +2 -2
- metadata +106 -117
data/doc/layouts/page.html
CHANGED
@@ -41,9 +41,9 @@
|
|
41
41
|
<%= @content_for_layout %>
|
42
42
|
</div>
|
43
43
|
|
44
|
-
<div class='copyright'><strong>© 2005 Ross Bamford</strong><br/>
|
44
|
+
<div class='copyright'><strong>© 2005-2013 Ross Bamford & Contributors</strong><br/>
|
45
45
|
Managed with <a href='http://ruby-lang.org'>Ruby</a> + <a href='http://rake.rubyforge.org'>Rake</a> + <a href='http://rote.rubyforge.org/'>Rote</a><br/>
|
46
|
-
Hosting & development services provided by <a href='http://rubyforge.org/'>RubyForge.org</a><br/>
|
46
|
+
Hosting & development services provided by <a href='http://github.com'>GitHub</a> & <a href='http://rubyforge.org/'>RubyForge.org</a><br/>
|
47
47
|
[<a href='http://validator.w3.org/check?uri=referer'>Validate</a>]
|
48
48
|
<p/>
|
49
49
|
</div>
|
data/doc/pages/COMMON.rb
CHANGED
@@ -17,11 +17,9 @@
|
|
17
17
|
{:title => 'RDoc',
|
18
18
|
:url => '/rdoc/'},
|
19
19
|
{:title => 'Issue tracker',
|
20
|
-
:url => '
|
21
|
-
{:title => '
|
22
|
-
:url => 'http://
|
23
|
-
{:title => 'Browse CVS',
|
24
|
-
:url => 'http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote'},
|
20
|
+
:url => 'https://github.com/roscopeco/rote/issues'},
|
21
|
+
{:title => 'Source Code',
|
22
|
+
:url => 'http://github.com/roscopeco/rote'},
|
25
23
|
{:title => 'Licence',
|
26
24
|
:url => '/license.html'}
|
27
25
|
]
|
data/doc/pages/guide/COMMON.rb
CHANGED
data/doc/pages/guide/index.html
CHANGED
@@ -1,37 +1,25 @@
|
|
1
1
|
<% @page_title = 'User guide' %>
|
2
2
|
|
3
|
-
p{color:red}. *The guide is still under construction*
|
4
|
-
|
5
3
|
<a name='top'></a>
|
6
4
|
|
7
|
-
It is assumed that you have installed Rote already. If not, please
|
8
|
-
consult the "README":<%= link_rel '/rdoc/files/README.html' %>
|
9
|
-
for installation instructions.
|
5
|
+
It is assumed that you have installed Rote already. If not, please consult the "README":<%= link_rel '/index.html' %> for installation instructions.
|
10
6
|
|
11
7
|
<%= section 3, 'Conventions', false %>
|
12
8
|
|
13
|
-
*Task names* - Rote's standard tasks are always referred to with the base-name
|
14
|
-
_doc_ , e.g. @doc_pages@, @doc_clean@, and just plain @doc@. This is the prefix
|
15
|
-
used by the built-in Rakefile, but since it can be changed when using Rote in
|
16
|
-
your own Rake builds you should of course substitute whatever is appropriate
|
17
|
-
if you have chosen to modify it.
|
9
|
+
*Task names* - Rote's standard tasks are always referred to with the base-name _doc_ , e.g. @doc_pages@, @doc_clean@, and just plain @doc@. This is the prefix used by the built-in Rakefile, but since it can be changed when using Rote in your own Rake builds you should of course substitute whatever is appropriate if you have chosen to modify it.
|
18
10
|
|
19
11
|
<%= section 3, 'Starting out with Rote' %>
|
20
12
|
|
13
|
+
|
21
14
|
<%= section 4, 'Creating a project', false %>
|
22
15
|
|
23
|
-
To get started quickly, we'll use the built-in project template, which provides
|
24
|
-
a standard Rote directory tree with a single page, and Rakefile ready for
|
25
|
-
customisation. The template gives a convenient way to get started on a new
|
26
|
-
Rote project. To invoke it, just type:
|
16
|
+
To get started quickly, we'll use the built-in project template, which provides a standard Rote directory tree with a single page, and Rakefile ready for customisation. The template gives a convenient way to get started on a new Rote project. To invoke it, just type:
|
27
17
|
|
28
18
|
<p><pre><code> rote create someproject</code></pre></p>
|
29
19
|
|
30
|
-
If all goes well, you should see a single line (@cp_r ...@) indicating that
|
31
|
-
Rote copied the template to your specified directory (@someproject@ in this
|
32
|
-
case). This directory will have the following layout:
|
20
|
+
If all goes well, you should see a single line (@cp_r ...@) indicating that Rote copied the template to your specified directory (@someproject@ in this case). This directory will have the following layout:
|
33
21
|
|
34
|
-
<p><code
|
22
|
+
<p><pre><code>
|
35
23
|
someproject
|
36
24
|
|
|
37
25
|
|--> Rakefile
|
@@ -49,53 +37,38 @@ case). This directory will have the following layout:
|
|
49
37
|
| |--> index.thtml
|
50
38
|
| |--> index.rb
|
51
39
|
|
52
|
-
</pre></
|
40
|
+
</code></pre></p>
|
53
41
|
|
54
|
-
Template sources under the 'pages' directory may have any extension (except
|
55
|
-
@rb@), and will be rendered to the same base-name under the output directory,
|
56
|
-
with their file extension supplied by the original, possible via an
|
57
|
-
<%= section_link 'extension_mappings', 'extension mapping' %>
|
42
|
+
Template sources under the 'pages' directory may have any extension (except @rb@), and will be rendered to the same base-name under the output directory, with their file extension supplied by the original, possible via an <%= section_link 'extension_mappings', 'extension mapping' %>
|
58
43
|
See the section on Layouts below for details on layout name resolution.
|
59
44
|
|
60
|
-
Ruby source is optional, and allows you to define instance variables and
|
61
|
-
|
62
|
-
directory. See <%= section_link 'creating templates', 'the section on templates' %>
|
63
|
-
for more information on the specifics.
|
45
|
+
Ruby source is optional, and allows you to define instance variables and methods on a Page instance. COMMON.rb is applied to all pages in a given
|
46
|
+
directory. See <%= section_link 'creating templates', 'the section on templates' %> for more information on the specifics.
|
64
47
|
|
65
|
-
To build the sample page, simply type @rote@ or @rake@ from the top-level
|
66
|
-
directory. This will start the default @doc@ task to transform all
|
48
|
+
To build the sample page, simply type @rote@ or @rake@ from the top-level directory. This will start the default @doc@ task to transform all
|
67
49
|
modified pages / resources (everything, in this case).
|
68
50
|
|
69
|
-
The README included with the project template has further information
|
70
|
-
about build options and available tasks, as well as pointers to possible
|
51
|
+
The README included with the project template has further information about build options and available tasks, as well as pointers to possible
|
71
52
|
next steps.
|
72
53
|
|
73
54
|
<%= section 4, 'From the command-line' %>
|
74
55
|
|
75
|
-
If you are generating a standalone documentation set (i.e. not as part of
|
76
|
-
|
77
|
-
you can use the built-in build via the @rote@ command. This works with
|
78
|
-
the standard directory layout above, and wraps invocation of @rake@ on a
|
56
|
+
If you are generating a standalone documentation set (i.e. not as part of some wider build) and you don't want to worry maintaining a @Rakefile@,
|
57
|
+
you can use the built-in build via the @rote@ command. This works with the standard directory layout above, and wraps invocation of @rake@ on a
|
79
58
|
built-in version of the standard Rakefile.
|
80
59
|
|
81
60
|
Given the above layout, you can generate the documentation set by running:
|
82
61
|
|
83
62
|
<p><pre><code> rote</code></pre></p>
|
84
63
|
|
85
|
-
from the top-level directory (@project@ in the example above), you should get
|
86
|
-
a 'html' directory created with the (transformed) templates, and any
|
64
|
+
from the top-level directory (@project@ in the example above), you should get a 'html' directory created with the (transformed) templates, and any
|
87
65
|
resources should be copied as necessary.
|
88
66
|
|
89
|
-
Being based on Rake, Rote supports last-modified checking, and provides an
|
90
|
-
|
91
|
-
|
92
|
-
immediately, since all output is up to date. If you change a file, and run
|
93
|
-
rote again, then just that file will be updated. Even dependencies that are
|
94
|
-
determined dynamically (such as layout files) can be tracked for incremental
|
95
|
-
build purposes.
|
67
|
+
Being based on Rake, Rote supports last-modified checking, and provides an individual file task for each page in your doc set. For example, running
|
68
|
+
the 'rote' command again with no options will cause it to exit almost immediately, since all output is up to date. If you change a file, and run
|
69
|
+
rote again, then just that file will be updated. Even dependencies that are determined dynamically (such as layout files) can be tracked for incremental build purposes.
|
96
70
|
|
97
|
-
The file tasks are named for the target files, so for example to generate
|
98
|
-
just the top-level index.html (regardless of whether it's been modified)
|
71
|
+
The file tasks are named for the target files, so for example to generate just the top-level index.html (regardless of whether it's been modified)
|
99
72
|
you'd run:
|
100
73
|
|
101
74
|
<p><pre><code> rote html/index.html</code></pre></p>
|
@@ -113,245 +86,146 @@ Further command-line usage information is available with:
|
|
113
86
|
|
114
87
|
<p><pre><code> rote --usage</code></pre></p>
|
115
88
|
|
116
|
-
and Unix installations performed with @install.rb@ should also make a
|
117
|
-
manpage available for the @rote@ command.
|
89
|
+
and Unix installations performed with @install.rb@ should also make a manpage available for the @rote@ command.
|
118
90
|
|
119
91
|
<div class='note'>
|
120
|
-
*Note* That, for most purposes, you should prefer to use a Rakefile based
|
121
|
-
|
122
|
-
|
123
|
-
is not guaranteed to remain supported in 1.0.
|
124
|
-
|
125
|
-
If you do choose to use a Rakefile approach, do *not* use the 'rote'
|
126
|
-
command to build documentation, since it will ignore your local Rakefile
|
127
|
-
and can result in inconsistent behaviour.
|
92
|
+
*Note* That, for most purposes, you should prefer to use a Rakefile based build, as created by the @rote create@ command. The command-wrapper functionality in Rote is maintained only as a quick start option, and is not guaranteed to remain supported in 1.0.
|
93
|
+
|
94
|
+
If you do choose to use a Rakefile approach, do *not* use the 'rote' command to build documentation, since it will ignore your local Rakefile and can result in inconsistent behaviour.
|
128
95
|
</div>
|
129
96
|
|
130
97
|
<%= section 4, 'From your Rakefile' %>
|
131
98
|
|
132
|
-
If you are wanting to build documentation as part of a larger build process, or
|
133
|
-
commandline setup, then you'll want to get started on integrating Rote with
|
134
|
-
your own (existing) @Rakefile@. If you bootstrap a project with the
|
135
|
-
@rote create@ command, you'll get a Rakefile which you can modify to suit
|
136
|
-
your requirements.
|
99
|
+
If you are wanting to build documentation as part of a larger build process, or commandline setup, then you'll want to get started on integrating Rote with your own (existing) @Rakefile@. If you bootstrap a project with the @rote create@ command, you'll get a Rakefile which you can modify to suit your requirements.
|
137
100
|
|
138
|
-
There is nothing special about this Rakefile, and it can use any of the other
|
139
|
-
Rake tasks, or indeed any other Ruby code. It is run with a command like:
|
101
|
+
There is nothing special about this Rakefile, and it can use any of the other Rake tasks, or indeed any other Ruby code. It is run with a command like:
|
140
102
|
|
141
103
|
<pre><code> rake doc</code></pre>
|
142
104
|
|
143
|
-
If all goes well, you should see each command and transformation output to your
|
144
|
-
console as Rote runs.
|
105
|
+
If all goes well, you should see each command and transformation output to your console as Rote runs.
|
145
106
|
|
146
|
-
See the main Rote @Rakefile@ for an example of integrating Rote with your
|
147
|
-
|
148
|
-
<%= section_link 'Rake task configuration' %> section has more information
|
149
|
-
on the options supported by Rote's task library.
|
107
|
+
See the main Rote @Rakefile@ for an example of integrating Rote with your software project, including linking to Rdoc generation and so on. The
|
108
|
+
<%= section_link 'Rake task configuration' %> section has more information on the options supported by Rote's task library.
|
150
109
|
|
151
110
|
<%= section 3, 'Creating templates' %>
|
152
111
|
|
153
|
-
p=. *Wherever directories and files are mentioned, they refer to the appropriate
|
154
|
-
*
|
155
|
-
*In all cases the default settings can be seen in the layout created by the*
|
156
|
-
*@rote create foo@ command.*
|
112
|
+
p=. *Wherever directories and files are mentioned, they refer to the appropriate path/name/etc supplied during <%= section_link 'rake task configuration' %>*.
|
113
|
+
*In all cases the default settings can be seen in the layout created by the @rote create foo@ command.*
|
157
114
|
|
158
115
|
<%= section 4, 'The Basics', false %>
|
159
116
|
|
160
|
-
As mentioned, templates are simply files in the specifed pages directory
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
<%= section_link '
|
172
|
-
see the <%= section_link 'Rake task configuration' %> section for details.
|
173
|
-
|
174
|
-
Each page and layout template used by Rote may have associated with it an
|
175
|
-
optional Ruby source file, allowing variables to be defined for use in ERB
|
176
|
-
code, and supporting interaction with Rote via the methods of the
|
177
|
-
"@Rote::Page@":<%= link_rel '/rdoc/classes/Rote/Page.html' %> class. Page
|
178
|
-
and layout code is loaded from a @rb@ file alongside the template itself.
|
179
|
-
Code can also be applied across multiple pages based on filesystem hierarchy
|
180
|
-
by placing it in @COMMON.rb@ files in the *pages* tree. The order of evaluation
|
181
|
-
of these files travels down from the most remote COMMON.rb to the page code
|
182
|
-
itself, and this provides a simple yet fairly powerful way to apply various
|
183
|
-
configuration options, filtering, and user variables across your pages.
|
184
|
-
See <%= section_link 'template code and erb' %> for more information on the
|
185
|
-
search path and evaluation order for page code.
|
186
|
-
|
187
|
-
Rote additionally allows a variety of formatting and postprocessing options
|
188
|
-
thanks to it's support for <%= section_link 'filters' %> - little bits of Ruby
|
189
|
-
that perform some text transformation, macro expansion, or postprocessing
|
190
|
-
during page rendering. Rote provides standard filters to support Textile
|
191
|
-
and Markdown formatting, syntax highlighting, processing with HTMLTidy, and
|
192
|
-
more.
|
117
|
+
As mentioned, templates are simply files in the specifed pages directory (@doc/pages@ by default) that match the supplied glob (default: all files,
|
118
|
+
though ruby source is implicitly excluded). The directory layout beneath the page root is retained when transforming pages, and is also used to provide hierarchical structure to the common page code.
|
119
|
+
|
120
|
+
The default behaviour is to transform all matched <%= section_link 'template code and erb', 'templates' %> pages with ERB, and optionally apply a second render pass with a <%= section_link 'layout' %>, before writing to the same base filename beneath the output directory. You can customise this behaviour by specifying <%= section_link 'extension mappings' %> for specific file extensions - see the <%= section_link 'Rake task configuration' %> section for details.
|
121
|
+
|
122
|
+
Each page and layout template used by Rote may have associated with it an optional Ruby source file, allowing variables to be defined for use in ERB code, and supporting interaction with Rote via the methods of the "@Rote::Page@":<%= link_rel '/rdoc/classes/Rote/Page.html' %> class. Page and layout code is loaded from a @rb@ file alongside the template itself.
|
123
|
+
|
124
|
+
Code can also be applied across multiple pages based on filesystem hierarchy by placing it in @COMMON.rb@ files in the *pages* tree. The order of evaluation of these files travels down from the most remote COMMON.rb to the page code itself, and this provides a simple yet fairly powerful way to apply various configuration options, filtering, and user variables across your pages.
|
125
|
+
|
126
|
+
See <%= section_link 'template code and erb' %> for more information on the search path and evaluation order for page code.
|
127
|
+
|
128
|
+
Rote additionally allows a variety of formatting and postprocessing options thanks to it's support for <%= section_link 'filters' %> - little bits of Ruby that perform some text transformation, macro expansion, or postprocessing during page rendering. Rote provides standard filters to support Textile and Markdown formatting, syntax highlighting, processing with HTMLTidy, and more.
|
193
129
|
|
194
130
|
<%= section 4, 'Template code and ERB' %>
|
195
131
|
|
196
|
-
All templates may contain embedded Ruby code (ERB), delimited by the standard
|
197
|
-
<% ... %> (for executed code) and <%= ... %> (for
|
198
|
-
output) tags. Any (valid) Ruby code may be placed in the templates, and
|
199
|
-
variables may be defined to allow information to be passed into templates.
|
200
|
-
There are four places where you might define such variables. The following
|
201
|
-
is in order of evaluation:
|
132
|
+
All templates may contain embedded Ruby code (ERB), delimited by the standard <% ... %> (for executed code) and <%= ... %> (for output) tags. Any (valid) Ruby code may be placed in the templates, and variables may be defined to allow information to be passed into templates. There are four places where you might define such variables. The following is in order of evaluation:
|
202
133
|
|
203
|
-
* A block supplied to the <%= section_link 'extension mappings', 'extension mapping' %>
|
204
|
-
that matched this page (if any).
|
134
|
+
* A block supplied to the <%= section_link 'extension mappings', 'extension mapping' %> that matched this page (if any).
|
205
135
|
* Any COMMON.rb files from the filesystem root down to this directory.
|
206
136
|
* This page's ruby code, _basename_.rb.
|
207
137
|
* In the template itself (via ERB).
|
208
138
|
|
209
|
-
When a @Page@ instance is created, Rote looks for these, and if found evaluates
|
210
|
-
them, in order, in the same binding as the template is later rendered in (i.e.
|
211
|
-
the @Page@ instance binding). Therefore, you can define instance variables to
|
212
|
-
pass data around, or even helper methods if you wish.
|
139
|
+
When a @Page@ instance is created, Rote looks for these, and if found evaluates them, in order, in the same binding as the template is later rendered in (i.e. the @Page@ instance binding). Therefore, you can define instance variables to pass data around, or even helper methods if you wish.
|
213
140
|
|
214
|
-
Additionally, when <%= section_link 'layout' %> is used the following evaluation
|
215
|
-
takes place *after rendering the template text* and can be used to make variables
|
216
|
-
available for the layout pass(es):
|
141
|
+
Additionally, when <%= section_link 'layout' %> is used the following evaluation takes place *after rendering the template text* and can be used to make variables available for the layout pass(es):
|
217
142
|
|
218
143
|
* This layout's ruby code, _layout_basename_.rb.
|
219
144
|
* In the layout itself (again, with ERB).
|
220
145
|
|
221
|
-
Template code is used to support a great deal of flexibility in Rote, from
|
222
|
-
selecting layouts to mixing in format helpers to controlling the filter chain.
|
223
|
-
You can find details of the methods available in the
|
224
|
-
"@Rote::Page@ RDoc":<%= link_rel '/rdoc/classes/Rote/Page.html' %>
|
146
|
+
Template code is used to support a great deal of flexibility in Rote, from selecting layouts to mixing in format helpers to controlling the filter chain. You can find details of the methods available in the "@Rote::Page@ RDoc":<%= link_rel '/rdoc/classes/Rote/Page.html' %>
|
225
147
|
|
226
148
|
<%= section 4, 'Plaintext Formatting' %>
|
227
149
|
|
228
|
-
If you are using Rote to generate HTML, you'll probably want to utilise some
|
229
|
-
|
230
|
-
Textile, Markdown, and RDoc formatting, which can be applied to any page using
|
231
|
-
standard <%= section_link 'filters' %>.
|
150
|
+
If you are using Rote to generate HTML, you'll probably want to utilise some kind of _plain-text formatting_. Rote has out-of-the-box support for
|
151
|
+
Textile, Markdown, and RDoc formatting, which can be applied to any page using standard <%= section_link 'filters' %>.
|
232
152
|
|
233
|
-
These filters can be applied to any page directly from page or common code,
|
234
|
-
and if you are using the built-in Rakefile (either using the @rote@ command to
|
235
|
-
build, or with a @rake@ build created with the @rote create@ command) then
|
236
|
-
the following extension mappings are defined by default, allowing the filters
|
237
|
-
to be applied without resorting to page code:
|
153
|
+
These filters can be applied to any page directly from page or common code, and if you are using the built-in Rakefile (either using the @rote@ command to build, or with a @rake@ build created with the @rote create@ command) then the following extension mappings are defined by default, allowing the filters to be applied without resorting to page code:
|
238
154
|
|
239
155
|
.mhtml or .markdown => Markdown formatting, .html output
|
240
156
|
.thtml or .textile => Textile formatting, .html output
|
241
157
|
.rdhtml or .rdoc => RDoc formatting, .html output
|
242
158
|
|
243
|
-
Each of these filters is covered (along with further usage instructions) in
|
244
|
-
the <%= section_link 'filters' %> section.
|
159
|
+
Each of these filters is covered (along with further usage instructions) in the <%= section_link 'filters' %> section.
|
245
160
|
|
246
161
|
<%= section 4, 'Layout' %>
|
247
162
|
|
248
|
-
_Layouts_ allow common template to be applied across several pages.
|
249
|
-
This is handled via multiple render passes, with each layout responsible
|
163
|
+
_Layouts_ allow common template to be applied across several pages. This is handled via multiple render passes, with each layout responsible
|
250
164
|
for including the previously rendered content (via ERB).
|
251
165
|
|
252
|
-
Layouts are stored under the @doc/layouts@ directory (by default). They may
|
253
|
-
|
254
|
-
|
255
|
-
@Rote::Page.layout@ method from code applied to that page, passing the
|
256
|
-
base-name (and path, relative to @layouts@, if used). If no extension is
|
257
|
-
specified, then the same extension as the page itself is assumed. Examples:
|
166
|
+
Layouts are stored under the @doc/layouts@ directory (by default). They may be organised into subdirectories, but this hierarchy is not connected to
|
167
|
+
the hierarchy in @pages@. To apply a layout to a page, simply call the @Rote::Page.layout@ method from code applied to that page, passing the
|
168
|
+
base-name (and path, relative to @layouts@, if used). If no extension is specified, then the same extension as the page itself is assumed. Examples:
|
258
169
|
|
259
170
|
* layout 'one'
|
260
171
|
* layout 'main/wide'
|
261
172
|
* layout 'dark.txt'
|
262
173
|
* <% layout 'my' %>
|
263
174
|
|
264
|
-
_*Note* the absence of the = sign in the ERB tag in the last example,_
|
265
|
-
_indicating that this is code to be executed rather than code that should_
|
266
|
-
_generate output._
|
175
|
+
_*Note* the absence of the = sign in the ERB tag in the last example, indicating that this is code to be executed rather than code that should generate output._
|
267
176
|
|
268
|
-
With that done, Rote would first render the template text (including textile)
|
269
|
-
and set the Page instance variable @\@content_for_layout@ before rendering
|
270
|
-
the layout (in which textile is currently not supported). The layout is
|
271
|
-
responsible for inserting the rendered template where appropriate, with
|
272
|
-
e.g.:
|
177
|
+
With that done, Rote would first render the template text (including textile) and set the Page instance variable @\@content_for_layout@ before rendering the layout (in which textile is currently not supported). The layout is responsible for inserting the rendered template where appropriate, with e.g.:
|
273
178
|
|
274
179
|
* <%= @content_for_layout %>
|
275
180
|
|
276
|
-
This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate
|
277
|
-
HTML, despite the appearance from the ERB tags - any (textual) format can
|
181
|
+
This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate HTML, despite the appearance from the ERB tags - any (textual) format can
|
278
182
|
be templated and laid out.
|
279
183
|
|
280
184
|
h5. Layout code
|
281
185
|
|
282
|
-
Like page templates, each layout may have associated with it some layout
|
283
|
-
code, which is executed just prior to rendering the layout, in the same
|
186
|
+
Like page templates, each layout may have associated with it some layout code, which is executed just prior to rendering the layout, in the same
|
284
187
|
way as the page code.
|
285
188
|
|
286
189
|
There is no equivalent of @COMMON.rb@ for layout templates, however.
|
287
190
|
|
288
191
|
h5. Nested layout
|
289
192
|
|
290
|
-
Layout code (see above) may call the @Page#layout@ method (i.e. to apply
|
291
|
-
a layout
|
292
|
-
passed (via <code>@content_for_layout</code>) to the specified layout
|
293
|
-
in a further render pass. In all respects this is no different from the
|
294
|
-
initial layout pass - layout code is executed, and rendering performed.
|
295
|
-
Obviously, this may result in additional layouts being applied to the page.
|
193
|
+
Layout code (see above) may call the @Page#layout@ method (i.e. to apply a layout). This will result in the result of the current rendering being
|
194
|
+
passed (via <code>@content_for_layout</code>) to the specified layout in a further render pass. In all respects this is no different from the initial layout pass - layout code is executed, and rendering performed. Obviously, this may result in additional layouts being applied to the page.
|
296
195
|
|
297
196
|
<div class='note'>
|
298
|
-
Layouts can only be nested by calling @layout@ again from *layout code*
|
299
|
-
|
300
|
-
@COMMON.rb@ or page code will result in consistent page code behaviour,
|
301
|
-
i.e. any previously-specified layout will be overriden.
|
197
|
+
Layouts can only be nested by calling @layout@ again from *layout code* (or ERB in the layout template itself). Multiple calls to @layout@ from
|
198
|
+
@COMMON.rb@ or page code will result in consistent page code behaviour, i.e. any previously-specified layout will be overriden.
|
302
199
|
</div>
|
303
200
|
|
304
|
-
There are no special requirements for layouts that are used in this way -
|
305
|
-
from the user point of view a layout simply needs to include the
|
306
|
-
<code>@content_for_layout</code> where appropriate.
|
201
|
+
There are no special requirements for layouts that are used in this way - from the user point of view a layout simply needs to include the <code>@content_for_layout</code> where appropriate.
|
307
202
|
|
308
203
|
All layouts are rendered prior to post filtering.
|
309
204
|
|
310
205
|
<%= section 4, 'Filters' %>
|
311
206
|
|
312
|
-
As well as rendering ERB and applying layout (both universal features of @Page@),
|
313
|
-
Rote provides the ability to apply custom _filters_ to a page or set of pages.
|
314
|
-
Along with this ability, a number of filters are provided as standard:
|
207
|
+
As well as rendering ERB and applying layout (both universal features of @Page@), Rote provides the ability to apply custom _filters_ to a page or set of pages. Along with this ability, a number of filters are provided as standard:
|
315
208
|
|
316
|
-
For example If you're generating HTML, you'll probably want to use some plaintext
|
317
|
-
formatting, rather than writing HTML by hand. Rote directly supports this
|
318
|
-
(thanks to "RedCloth":http://whytheluckystiff.net/ruby/redcloth and
|
319
|
-
"BlueCloth":http://www.deveiate.org/projects/BlueCloth) via _filters_, with
|
320
|
-
Textile, RDoc and Markdown support out of the box (assuming those libraries are
|
321
|
-
available on your machine). See the <%= section_link 'plaintext formatting' %>
|
322
|
-
for more details on this.
|
209
|
+
For example If you're generating HTML, you'll probably want to use some plaintext formatting, rather than writing HTML by hand. Rote directly supports this (thanks to "RedCloth":http://whytheluckystiff.net/ruby/redcloth and "BlueCloth":http://www.deveiate.org/projects/BlueCloth) via _filters_, with Textile, RDoc and Markdown support out of the box (assuming those libraries are available on your machine). See the <%=section_link 'plaintext formatting' %> for more details on this.
|
323
210
|
|
324
211
|
h5. Filter chaining
|
325
212
|
|
326
|
-
In order to filter a given page, filter instances are added to that page's
|
327
|
-
filter chain. There are actually two separate chains, for _page filtering_
|
213
|
+
In order to filter a given page, filter instances are added to that page's filter chain. There are actually two separate chains, for _page filtering_
|
328
214
|
and _post filtering_.
|
329
215
|
|
330
|
-
* *Page filtering* takes place on the page content itself, after any
|
331
|
-
ERB is executed, but before the layout pass is applied. Most of the
|
332
|
-
standard filters are pre-filters.
|
216
|
+
* *Page filtering* takes place on the page content itself, after any ERB is executed, but before the layout pass is applied. Most of the standard filters are pre-filters.
|
333
217
|
|
334
|
-
* *Post filtering* takes place on the final output of the render pass,
|
335
|
-
after layout is applied. The @Filters::Tidy@ filter is a post filter.
|
218
|
+
* *Post filtering* takes place on the final output of the render pass, after layout is applied. The @Filters::Tidy@ filter is a post filter.
|
336
219
|
|
337
|
-
Adding filters to a page's chain can be done anywhere you can call that page's filter-chain
|
338
|
-
|
339
|
-
|
340
|
-
<%= section_link 'extension mappings', 'extension mapping' %> block. Bear in mind that the
|
341
|
-
order in which filters are added *is* important, since each filters output becomes input
|
342
|
-
for the next. You must ensure that filters are applied in a compatible order - should you
|
343
|
-
need to prepend filters or otherwise modify the chain prior to rendering you may do so by
|
344
|
-
directly accessing the @page_filters@ and @post_filters@ array attributes.
|
345
|
-
|
346
|
-
See <%= section_link 'template code and erb', 'the section on template code' %>
|
347
|
-
for more information on adding code to your pages.
|
220
|
+
Adding filters to a page's chain can be done anywhere you can call that page's filter-chain methods. This could be page code, COMMON.rb, or even inside the template itself. Filters can also be applied to all files with a matching extension by adding filters inside an <%= section_link 'extension mappings', 'extension mapping' %> block. Bear in mind that the order in which filters are added *is* important, since each filters output becomes input for the next. You must ensure that filters are applied in a compatible order - should you need to prepend filters or otherwise modify the chain prior to rendering you may do so by directly accessing the @page_filters@ and @post_filters@ array attributes.
|
221
|
+
|
222
|
+
See <%= section_link 'template code and erb', 'the section on template code' %> for more information on adding code to your pages.
|
348
223
|
|
349
224
|
h5. Standard filters
|
350
225
|
|
351
226
|
Rote supplies the following filters 'out of the box':
|
352
227
|
|
353
|
-
h6. *"Filters::BlueCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* -
|
354
|
-
Supports conversion of plain-text (Markdown) formatting to HTML.
|
228
|
+
h6. *"Filters::BlueCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* - Supports conversion of plain-text (Markdown) formatting to HTML.
|
355
229
|
|
356
230
|
This is a text filter, and should be applied in the _page filter chain_:
|
357
231
|
|
@@ -360,9 +234,7 @@ This is a text filter, and should be applied in the _page filter chain_:
|
|
360
234
|
page_filter Filters::BlueCloth.new
|
361
235
|
#:code#
|
362
236
|
|
363
|
-
h6. *"Filters::Exec":<%= link_rel '/rdoc/classes/Rote/Filters/Exec.html' %>* -
|
364
|
-
Pipes the macro body to an external command, and replaces the macro with
|
365
|
-
the output of that command.
|
237
|
+
h6. *"Filters::Exec":<%= link_rel '/rdoc/classes/Rote/Filters/Exec.html' %>* - Pipes the macro body to an external command, and replaces the macro with the output of that command.
|
366
238
|
|
367
239
|
This is a macro filter, and should be applied in the _page filter chain_:
|
368
240
|
|
@@ -379,9 +251,7 @@ Code can then be inserted in the page like:
|
|
379
251
|
#:exec#
|
380
252
|
#:code#
|
381
253
|
|
382
|
-
h6. *"Filters::Eval":<%= link_rel '/rdoc/classes/Rote/Filters/Eval.html' %>* -
|
383
|
-
Evaluates the macro body as Ruby code, capturing standard output and using it as
|
384
|
-
the macro replacement.
|
254
|
+
h6. *"Filters::Eval":<%= link_rel '/rdoc/classes/Rote/Filters/Eval.html' %>* - Evaluates the macro body as Ruby code, capturing standard output and using it as the macro replacement.
|
385
255
|
|
386
256
|
This is a macro filter, and should be applied in the _page filter chain_:
|
387
257
|
|
@@ -398,9 +268,7 @@ Code can then be inserted in the page like:
|
|
398
268
|
#:eval#
|
399
269
|
#:code#
|
400
270
|
|
401
|
-
h6. *"Filters::RDoc":<%= link_rel '/rdoc/classes/Rote/Filters/RDoc.html' %>* -
|
402
|
-
Supports RDoc formatting with optional custom markup, to any supported output format
|
403
|
-
(defaults to HTML).
|
271
|
+
h6. *"Filters::RDoc":<%= link_rel '/rdoc/classes/Rote/Filters/RDoc.html' %>* - Supports RDoc formatting with optional custom markup, to any supported output format (defaults to HTML).
|
404
272
|
|
405
273
|
This is a text filter, and should be applied in the _page filter chain_:
|
406
274
|
|
@@ -409,8 +277,7 @@ This is a text filter, and should be applied in the _page filter chain_:
|
|
409
277
|
page_filter Filters::RDoc.new
|
410
278
|
#:code#
|
411
279
|
|
412
|
-
h6. *"Filters::RedCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* -
|
413
|
-
Supports conversion of plain-text (Textile) formatting to HTML.
|
280
|
+
h6. *"Filters::RedCloth":<%= link_rel '/rdoc/classes/Rote/Filters/RedCloth.html' %>* - Supports conversion of plain-text (Textile) formatting to HTML.
|
414
281
|
|
415
282
|
This is a text filter, and should be applied in the _page filter chain_:
|
416
283
|
|
@@ -419,10 +286,7 @@ This is a text filter, and should be applied in the _page filter chain_:
|
|
419
286
|
page_filter Filters::RedCloth.new
|
420
287
|
#:code#
|
421
288
|
|
422
|
-
h6. *"Filters::Syntax":<%= link_rel '/rdoc/classes/Rote/Filters/Syntax.html' %>* -
|
423
|
-
Supports @code@ <%= section_link 'macros' %> with pluggable syntax highlighting
|
424
|
-
(via the "Syntax library":http://syntax.rubyforge.org/) and Ruby-code support
|
425
|
-
out of the box.
|
289
|
+
h6. *"Filters::Syntax":<%= link_rel '/rdoc/classes/Rote/Filters/Syntax.html' %>* - Supports @code@ <%= section_link 'macros' %> with pluggable syntax highlighting (via the "Syntax library":http://syntax.rubyforge.org/) and Ruby-code support out of the box.
|
426
290
|
|
427
291
|
This is a macro filter, and should be applied in the _page filter chain_:
|
428
292
|
|
@@ -431,15 +295,8 @@ This is a macro filter, and should be applied in the _page filter chain_:
|
|
431
295
|
page_filter Filters::Syntax.new
|
432
296
|
#:code#
|
433
297
|
|
434
|
-
This filter uses the "Syntax":http://syntax.rubyforge.org/ library, passing the
|
435
|
-
|
436
|
-
box). The output is wrapped in
|
437
|
-
<pre class='[language]'><code> ... </code></pre>
|
438
|
-
for output, with highlighting handled by <span> tags, allowing syntax colours and
|
439
|
-
styles to be applied via CSS. You can find a full list of the Ruby highlight classes
|
440
|
-
in the "Syntax documentation":http://syntax.rubyforge.org/chapter-2.html
|
441
|
-
but you will need to experiment with the highlighter to find the XML and YAML
|
442
|
-
classes.
|
298
|
+
This filter uses the "Syntax":http://syntax.rubyforge.org/ library, passing the macro argument as the language ('ruby', 'xml' and 'yaml' are supported out of the box). The output is wrapped in <pre class='[language]'><code> ... </code></pre> for output, with highlighting handled by <span> tags, allowing syntax colours and styles to be applied via CSS. You can find a full list of the Ruby highlight classes
|
299
|
+
in the "Syntax documentation":http://syntax.rubyforge.org/chapter-2.html but you will need to experiment with the highlighter to find the XML and YAML classes.
|
443
300
|
|
444
301
|
Code to be highlighted is inserted into pages like so:
|
445
302
|
|
@@ -452,19 +309,12 @@ Code to be highlighted is inserted into pages like so:
|
|
452
309
|
#:code#
|
453
310
|
|
454
311
|
<div class='note'>
|
455
|
-
Note that the closing tag in the above example is missing a closing '#' - this works
|
456
|
-
around a limitation of the current Syntax filter (and macro implementation in general),
|
457
|
-
which means that a macro cannot contain it's own end-tag.
|
312
|
+
Note that the closing tag in the above example is missing a closing '#' - this works around a limitation of the current Syntax filter (and macro implementation in general), which means that a macro cannot contain it's own end-tag.
|
458
313
|
</div>
|
459
314
|
|
460
|
-
Since macros are rendered separately from the page text, you don't have to worry much
|
461
|
-
about spacing and so forth - your code will not be touched by any of the formatting
|
462
|
-
filters.
|
315
|
+
Since macros are rendered separately from the page text, you don't have to worry much about spacing and so forth - your code will not be touched by any of the formatting filters.
|
463
316
|
|
464
|
-
h6. *"Filters::Tidy":<%= link_rel '/rdoc/classes/Rote/Filters/Tidy.html' %>* -
|
465
|
-
Post filter that corrects markup and semantic errors in HTML markup to produce
|
466
|
-
valid HTML or XHTML using the "HTML Tidy":http://tidy.sourceforge.net/ command-line
|
467
|
-
tool.
|
317
|
+
h6. *"Filters::Tidy":<%= link_rel '/rdoc/classes/Rote/Filters/Tidy.html' %>* - Post filter that corrects markup and semantic errors in HTML markup to produce valid HTML or XHTML using the "HTML Tidy":http://tidy.sourceforge.net/ command-line tool.
|
468
318
|
|
469
319
|
This is a *post filter*. It should be applied in the appropriate filter chain:
|
470
320
|
|
@@ -473,49 +323,33 @@ This is a *post filter*. It should be applied in the appropriate filter chain:
|
|
473
323
|
post_filter Filters::Tidy.new
|
474
324
|
#:code#
|
475
325
|
|
476
|
-
h6. *"Filters::TOC":<%= link_rel '/rdoc/classes/Rote/Filters/TOC.html' %>* -
|
477
|
-
Supports automatic generation of basic navigation from headings in documents.
|
478
|
-
See the RDoc for more details. It should be applied as a page filter, and
|
479
|
-
a reference is usually required for use in the layout:
|
326
|
+
h6. *"Filters::TOC":<%= link_rel '/rdoc/classes/Rote/Filters/TOC.html' %>* - Supports automatic generation of basic navigation from headings in documents. See the RDoc for more details. It should be applied as a page filter, and a reference is usually required for use in the layout:
|
480
327
|
|
481
328
|
#:code#ruby#
|
482
329
|
# in page code or common.rb
|
483
330
|
post_filter @toc = Filters::TOC.new
|
484
331
|
#:code#
|
485
332
|
|
486
|
-
Some of the filters support various options to change the way they operate, and
|
487
|
-
many support different arguments (the second part of the #macro#args# tags) to
|
488
|
-
those shown above - see the RDoc for the individual macros (linked from the headings
|
489
|
-
above) for more details.
|
333
|
+
Some of the filters support various options to change the way they operate, and many support different arguments (the second part of the #macro#args# tags) to those shown above - see the RDoc for the individual macros (linked from the headings above) for more details.
|
490
334
|
|
491
|
-
Filters are of course very simple to write. See the 'Writing filters' subsection
|
492
|
-
(in <%= section_link 'Extending Rote' %>) for details, including how to implement
|
493
|
-
your own macro filters.
|
335
|
+
Filters are of course very simple to write. See the 'Writing filters' subsection (in <%= section_link 'Extending Rote' %>) for details, including how to implement your own macro filters.
|
494
336
|
|
495
337
|
<%= section 4, 'Format helpers' %>
|
496
338
|
|
497
339
|
p{color:red}. *TODO* This section is under construction.
|
498
|
-
Please see "@Rote::Format::HTML@":<%= link_rel '/rdoc/classes/Rote/Format/HTML.html' %>
|
499
|
-
for currently available information.
|
340
|
+
Please see "@Rote::Format::HTML@":<%= link_rel '/rdoc/classes/Rote/Format/HTML.html' %> for currently available information.
|
500
341
|
|
501
342
|
<%= section 3, 'Resources' %>
|
502
343
|
|
503
|
-
Of course, you're likely to have resources for your site (images, sounds, etc)
|
504
|
-
and you'll need to copy them over to the target too. Such resources should be
|
505
|
-
placed under @doc/res@ (with the commandline setup) or in your specified @res@
|
506
|
-
directory (from a Rakefile).
|
344
|
+
Of course, you're likely to have resources for your site (images, sounds, etc) and you'll need to copy them over to the target too. Such resources should be placed under @doc/res@ (with the commandline setup) or in your specified @res@ directory (from a Rakefile).
|
507
345
|
|
508
|
-
As you'd expect, the directory layout beneath @res@ should mirror that of the
|
509
|
-
output, and will be preserved during the copy. Resources are copied only if
|
510
|
-
necessary (determined by existence and last-modified timestamp), in a similar
|
511
|
-
way to pages.
|
346
|
+
As you'd expect, the directory layout beneath @res@ should mirror that of the output, and will be preserved during the copy. Resources are copied only if necessary (determined by existence and last-modified timestamp), in a similar way to pages.
|
512
347
|
|
513
348
|
<%= section 3, 'Rake task configuration' %>
|
514
349
|
|
515
350
|
<%= section 4, 'Reference Rakefile' %>
|
516
351
|
|
517
|
-
The following Rakefile demonstrates most of the methods you can use to customise
|
518
|
-
Rote's rake task configuration.
|
352
|
+
The following Rakefile demonstrates most of the methods you can use to customise Rote's rake task configuration.
|
519
353
|
|
520
354
|
#:code#ruby#
|
521
355
|
# Rakefile
|
@@ -560,17 +394,13 @@ ws = Rote::DocTask.new(:doc) do |doc|
|
|
560
394
|
end
|
561
395
|
#:code#
|
562
396
|
|
563
|
-
Please refer to the "RDoc":<%= link_rel '/rdoc/classes/Rote/DocTask.html' %> for specific
|
564
|
-
information on each method.
|
397
|
+
Please refer to the "RDoc":<%= link_rel '/rdoc/classes/Rote/DocTask.html' %> for specific information on each method.
|
565
398
|
|
566
399
|
<%= section 4, 'Extension mappings' %>
|
567
400
|
|
568
|
-
The default behaviour when transforming pages is to make each filename
|
569
|
-
matched by the @pages.include@ glob relative to the output directory, using
|
570
|
-
the same extension as the input file.
|
401
|
+
The default behaviour when transforming pages is to make each filename matched by the @pages.include@ glob relative to the output directory, using the same extension as the input file.
|
571
402
|
|
572
|
-
If you want to change this behaviour, you may supply an _extension mapping_
|
573
|
-
as demonstrated above. The general form is:
|
403
|
+
If you want to change this behaviour, you may supply an _extension mapping_ as demonstrated above. The general form is:
|
574
404
|
|
575
405
|
#:code#ruby#
|
576
406
|
# Define an extension mapping
|
@@ -581,14 +411,9 @@ doc.ext_mapping(/regexp/, 'replacement') do |page|
|
|
581
411
|
end
|
582
412
|
#:code#
|
583
413
|
|
584
|
-
The regexp is matched against processed page extensions (not resources) and
|
585
|
-
the replacement supplies the output extension. The optional block is executed
|
586
|
-
*for each matching page* during instantiation, before any COMMON or page
|
587
|
-
code. Note that you *must not* include the leading '.' in either the regexp or
|
588
|
-
replacement - doing so will fail to match the desired extensions.
|
414
|
+
The regexp is matched against processed page extensions (not resources) and the replacement supplies the output extension. The optional block is executed *for each matching page* during instantiation, before any COMMON or page code. Note that you *must not* include the leading '.' in either the regexp or replacement - doing so will fail to match the desired extensions.
|
589
415
|
|
590
|
-
For more advanced mappings, you can supply a capturing regexp, and use the
|
591
|
-
@$n@ notation in the replacement to extract the captures. As shown in the
|
416
|
+
For more advanced mappings, you can supply a capturing regexp, and use the @$n@ notation in the replacement to extract the captures. As shown in the
|
592
417
|
(contrived) example below:
|
593
418
|
|
594
419
|
#:code#ruby#
|
@@ -599,8 +424,7 @@ doc.ext_mapping(/(html)/, '$1') do |page|
|
|
599
424
|
end
|
600
425
|
#:code#
|
601
426
|
|
602
|
-
Extension mappings also support per-extension output directories, which
|
603
|
-
can be supplied as a third parameter to the @ext_mapping@ method:
|
427
|
+
Extension mappings also support per-extension output directories, which can be supplied as a third parameter to the @ext_mapping@ method:
|
604
428
|
|
605
429
|
doc.output_dir = 'html'
|
606
430
|
|
@@ -612,65 +436,31 @@ doc.ext_mapping(/ttxt/, 'txt', 'plaintext') do |page|
|
|
612
436
|
end
|
613
437
|
#:code#
|
614
438
|
|
615
|
-
Where no output directory is supplied, the default output directory will
|
616
|
-
be used.
|
439
|
+
Where no output directory is supplied, the default output directory will be used.
|
617
440
|
|
618
441
|
<%= section 4, 'Defining additional tasks' %>
|
619
442
|
|
620
|
-
The command-line build will automatically look for a file in the top-level
|
621
|
-
|
622
|
-
|
623
|
-
build. This can be used to define an <%= section_link 'auto refresh task' %>
|
624
|
-
for the <%= section_link 'source monitoring', 'monitor' %> feature, for example,
|
625
|
-
or to define tasks to publish your site (most likely using one of Rake's
|
626
|
-
directory publishers).
|
443
|
+
The command-line build will automatically look for a file in the top-level directory (above @doc@) named @local.rf@. If found, this file will be
|
444
|
+
evaluated by Rake, making any tasks defined within it available to your build. This can be used to define an <%= section_link 'auto refresh task' %>
|
445
|
+
for the <%= section_link 'source monitoring', 'monitor' %> feature, for example, or to define tasks to publish your site (most likely using one of Rake's directory publishers).
|
627
446
|
|
628
447
|
<%= section 3, 'Source monitoring' %>
|
629
448
|
|
630
|
-
When making changes to a documentation set, you frequently need to render out
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
have been modified. It will of course take notice of any custom file or directory
|
640
|
-
dependencies you add to the doc task (e.g. to generate RDoc as part of a
|
641
|
-
website), and in turn monitor their dependent files too (for example rebuilding
|
642
|
-
the RDoc if you modify a source file). It does *not* however attempt to track
|
643
|
-
format-specific dependencies _between_ resources (such as which pages use which
|
644
|
-
CSS), since this would imply some knowledge of the format in use. In practice
|
645
|
-
this means that you may need to trigger a clean build after updating such
|
646
|
-
resources, although it is actually fairly easy to set up this kind of
|
647
|
-
relationship by specifying that certain file-tasks relating to pages depend
|
648
|
-
on the appropriate file-tasks representing the resources (for instance).
|
649
|
-
|
650
|
-
By default, @monitor@ checks for updates approximately once
|
651
|
-
per second, but you can specify a custom value _when using a Rakefile_ by
|
652
|
-
setting @monitor_interval@ in the block passed to @DocTask.new@.
|
653
|
-
|
654
|
-
*Note* that the monitor functionality is deliberately kept simple with respect
|
655
|
-
to IO and concurrency, reflecting the fact that output files are rarely
|
656
|
-
anything more than that - it would be almost pointless to complicate the
|
657
|
-
way monitoring works with any kind of semaphore or file-locking scheme.
|
658
|
-
Of course if this does cause problems in your particular scenario, let me know
|
659
|
-
because it just might make me reconsider.
|
660
|
-
|
661
|
-
When you're done with Rote simply hit CTRL-C (or use @kill@) to stop monitoring
|
662
|
-
and exit.
|
449
|
+
When making changes to a documentation set, you frequently need to render out your changes to check formatting or ensure something works correctly. In this situation it's inconvenient to keep dropping out to your shell to run @rote@ (or @rake@) manually, particularly when making a lot of incremental changes.
|
450
|
+
|
451
|
+
Fortunately, Rote provides a simple mechanism for monitoring your documentation source and automatically performing updates as needed. Simply specify the @doc_monitor@ task and Rote will go into a loop, periodically running the top-level _doc_ task which will transform / copy any pages or resources that have been modified. It will of course take notice of any custom file or directory dependencies you add to the doc task (e.g. to generate RDoc as part of a website), and in turn monitor their dependent files too (for example rebuilding the RDoc if you modify a source file). It does *not* however attempt to track format-specific dependencies _between_ resources (such as which pages use which CSS), since this would imply some knowledge of the format in use. In practice this means that you may need to trigger a clean build after updating such resources, although it is actually fairly easy to set up this kind of relationship by specifying that certain file-tasks relating to pages depend on the appropriate file-tasks representing the resources (for instance).
|
452
|
+
|
453
|
+
By default, @monitor@ checks for updates approximately once per second, but you can specify a custom value _when using a Rakefile_ by setting @monitor_interval@ in the block passed to @DocTask.new@.
|
454
|
+
|
455
|
+
*Note* that the monitor functionality is deliberately kept simple with respect to IO and concurrency, reflecting the fact that output files are rarely anything more than that - it would be almost pointless to complicate the way monitoring works with any kind of semaphore or file-locking scheme. Of course if this does cause problems in your particular scenario, let me know because it just might make me reconsider.
|
456
|
+
|
457
|
+
When you're done with Rote simply hit CTRL-C (or use @kill@) to stop monitoring and exit.
|
663
458
|
|
664
459
|
<%= section 4, 'Auto refresh task' %>
|
665
460
|
|
666
|
-
When using Source monitoring, it's often handy to be able to inform some other
|
667
|
-
program that something has changed. For example, you may want to automatically
|
668
|
-
refresh your browser after changed HTML is rendered. Rote supports this via
|
669
|
-
the @doc_refresh@ task, which is triggered whenever @doc_monitor@ finds changes
|
670
|
-
in your source set (_after_ rendering, of course).
|
461
|
+
When using Source monitoring, it's often handy to be able to inform some other program that something has changed. For example, you may want to automatically refresh your browser after changed HTML is rendered. Rote supports this via the @doc_refresh@ task, which is triggered whenever @doc_monitor@ finds changes in your source set (_after_ rendering, of course).
|
671
462
|
|
672
|
-
The following (Mac) example uses OSA script to refresh the Safari browser when
|
673
|
-
your rendered documentation changes:
|
463
|
+
The following (Mac) example uses OSA script to refresh the Safari browser when your rendered documentation changes:
|
674
464
|
|
675
465
|
#:code#ruby#
|
676
466
|
require 'osx/aeosa'
|
@@ -680,48 +470,29 @@ your rendered documentation changes:
|
|
680
470
|
end
|
681
471
|
#:code#ruby#
|
682
472
|
|
683
|
-
As with all rake tasks, multiple actions can be associated, and you can of course
|
684
|
-
add prerequisites to the @refresh@ task as with any other Rake task.
|
473
|
+
As with all rake tasks, multiple actions can be associated, and you can of course add prerequisites to the @refresh@ task as with any other Rake task.
|
685
474
|
|
686
475
|
<%= section 3, 'Publishing' %>
|
687
476
|
|
688
|
-
Rote does not provide any direct support for publishing your site at present,
|
689
|
-
relying on you to configure an appropriate publish task if required, using
|
690
|
-
the publishers supplied with Rake (in @rake/contrib@), or your own. This
|
691
|
-
allows maximum flexibility, and allows Rote to concentrate on creating your
|
692
|
-
documents.
|
477
|
+
Rote does not provide any direct support for publishing your site at present, relying on you to configure an appropriate publish task if required, using the publishers supplied with Rake (in @rake/contrib@), or your own. This allows maximum flexibility, and allows Rote to concentrate on creating your documents.
|
693
478
|
|
694
|
-
See the section <%= section_link 'Defining additional tasks' %> for details on
|
695
|
-
how to supply your publish tasks.
|
479
|
+
See the section <%= section_link 'Defining additional tasks' %> for details on how to supply your publish tasks.
|
696
480
|
|
697
481
|
See the <%= section_link 'rake task configuration' %> section for more details.
|
698
482
|
|
699
483
|
<%= section 3, 'Extending Rote' %>
|
700
484
|
|
701
|
-
Although Rote is designed to be as quick and easy to use as possible,
|
702
|
-
with sensible default configuration and reasonable convention throughout,
|
703
|
-
it also has ample flexibility when it comes to generating more complex
|
704
|
-
documentation sets. Thanks to it's 'option for every default' and simple
|
705
|
-
extension points, Rote should scale to even complex documentation sets
|
706
|
-
quite easily.
|
485
|
+
Although Rote is designed to be as quick and easy to use as possible, with sensible default configuration and reasonable convention throughout, it also has ample flexibility when it comes to generating more complex documentation sets. Thanks to it's 'option for every default' and simple extension points, Rote should scale to even complex documentation sets quite easily.
|
707
486
|
|
708
487
|
<%= section 4, 'Writing filters' %>
|
709
488
|
|
710
|
-
*Filters* do exactly what they say on the tin - they filter the output of
|
711
|
-
a page, perhaps rendering markup or inserting additional text. Filters
|
712
|
-
can be divided into two general categories: *Text filters* and *Macro filters*.
|
713
|
-
Either type can be a page or post filter - it depends only on the design
|
714
|
-
of the filter and the job it will perform as to which chain it should
|
715
|
-
be used with.
|
489
|
+
*Filters* do exactly what they say on the tin - they filter the output of a page, perhaps rendering markup or inserting additional text. Filters can be divided into two general categories: *Text filters* and *Macro filters*. Either type can be a page or post filter - it depends only on the design of the filter and the job it will perform as to which chain it should be used with.
|
716
490
|
|
717
491
|
h5. Text Filters
|
718
492
|
|
719
|
-
Text filters process the text in a page, with all macros replaced by a
|
720
|
-
standard plain-text marker. The purpose of this is to allow macros
|
721
|
-
to coexist with plain-text formatting without causing markup clashes.
|
493
|
+
Text filters process the text in a page, with all macros replaced by a standard plain-text marker. The purpose of this is to allow macros to coexist with plain-text formatting without causing markup clashes.
|
722
494
|
|
723
|
-
Most of the standard filters are text filters. The RedCloth filter
|
724
|
-
is representative:
|
495
|
+
Most of the standard filters are text filters. The RedCloth filter is representative:
|
725
496
|
|
726
497
|
#:code#ruby#
|
727
498
|
class RedCloth < TextFilter
|
@@ -739,18 +510,13 @@ class RedCloth < TextFilter
|
|
739
510
|
end
|
740
511
|
#:code#
|
741
512
|
|
742
|
-
(again, this example is slightly simplified with respect to auxiliary
|
743
|
-
functionality for the sake of clarity).
|
513
|
+
(again, this example is slightly simplified with respect to auxiliary functionality for the sake of clarity).
|
744
514
|
|
745
|
-
As mentioned above, @TextFilter@ also provides help with writing non-macro
|
746
|
-
filters that removes much of the headache of working around macros (which
|
747
|
-
must not be modified by any filter except that which handles the macro).
|
515
|
+
As mentioned above, @TextFilter@ also provides help with writing non-macro filters that removes much of the headache of working around macros (which must not be modified by any filter except that which handles the macro).
|
748
516
|
|
749
517
|
Text filters can optionally access the macro data using the @macros@ array.
|
750
518
|
|
751
|
-
If you want to implement a one-off filter quickly, there's no need to
|
752
|
-
create a new subclass - you can supply a block directly to TextFilter,
|
753
|
-
which is executed to render the textual content:
|
519
|
+
If you want to implement a one-off filter quickly, there's no need to create a new subclass - you can supply a block directly to TextFilter, which is executed to render the textual content:
|
754
520
|
|
755
521
|
#:code#ruby#
|
756
522
|
page.page_filter Rote::Filters::TextFilter.new { |page, text|
|
@@ -758,8 +524,7 @@ page.page_filter Rote::Filters::TextFilter.new { |page, text|
|
|
758
524
|
}
|
759
525
|
#:code#
|
760
526
|
|
761
|
-
For text filters, a convenience in the implementation of @page_filter@
|
762
|
-
allows the above to be shortened to:
|
527
|
+
For text filters, a convenience in the implementation of @page_filter@ allows the above to be shortened to:
|
763
528
|
|
764
529
|
#:code#ruby#
|
765
530
|
page.page_filter do |page, text|
|
@@ -767,18 +532,13 @@ page.page_filter do |page, text|
|
|
767
532
|
end
|
768
533
|
#:code#
|
769
534
|
|
770
|
-
Note the curly braces in the first example, which cause the block to bind
|
771
|
-
to the filter rather than the method. If @do..end@ were used, the second
|
772
|
-
form would actually be called and a new filter created. The block filter you
|
773
|
-
supplied would be discarded.
|
535
|
+
Note the curly braces in the first example, which cause the block to bind to the filter rather than the method. If @do..end@ were used, the second form would actually be called and a new filter created. The block filter you supplied would be discarded.
|
774
536
|
|
775
537
|
The @post_filter@ method supports the same convenience.
|
776
538
|
|
777
539
|
h5. Macro Filters
|
778
540
|
|
779
|
-
The standard Syntax filter is a typical macro filter. The following is
|
780
|
-
slightly simplified for brevity (the actual one allows custom macro tags
|
781
|
-
to be supplied):
|
541
|
+
The standard Syntax filter is a typical macro filter. The following is slightly simplified for brevity (the actual one allows custom macro tags to be supplied):
|
782
542
|
|
783
543
|
#:code#ruby#
|
784
544
|
class Syntax < MacroFilter
|
@@ -789,13 +549,9 @@ class Syntax < MacroFilter
|
|
789
549
|
end
|
790
550
|
#:code#
|
791
551
|
|
792
|
-
As you can see, a macro filter simply inherits @Rote::Filters::MacroFilter@
|
793
|
-
and implements one or more @macro_XXXX@ methods, which is passed the arguments
|
794
|
-
supplied to the macro (used here to indicate the code language) and the
|
795
|
-
raw macro body.
|
552
|
+
As you can see, a macro filter simply inherits @Rote::Filters::MacroFilter@ and implements one or more @macro_XXXX@ methods, which is passed the arguments supplied to the macro (used here to indicate the code language) and the raw macro body.
|
796
553
|
|
797
|
-
If you want to implement a macro quickly, perhaps across a section or set of
|
798
|
-
pages, you can use @MacroFilter@ itself, supplying a block:
|
554
|
+
If you want to implement a macro quickly, perhaps across a section or set of pages, you can use @MacroFilter@ itself, supplying a block:
|
799
555
|
|
800
556
|
#:code#ruby#
|
801
557
|
page.page_filter Rote::Filters::MacroFilter.new([:foomacro]) { |tag, args, body
|
@@ -803,83 +559,49 @@ page.page_filter Rote::Filters::MacroFilter.new([:foomacro]) { |tag, args, body
|
|
803
559
|
}
|
804
560
|
#:code#
|
805
561
|
|
806
|
-
This can be done from any page code, a COMMON.rb (see
|
807
|
-
<%= section_link 'Template code and ERB' %>), or on a per-extension basis
|
808
|
-
with <%= section_link 'extension mappings' %>.
|
562
|
+
This can be done from any page code, a COMMON.rb (see <%= section_link 'Template code and ERB' %>), or on a per-extension basis with <%= section_link 'extension mappings' %>.
|
809
563
|
|
810
|
-
*Note* that macro data is passed raw, and excluded from rendering by
|
811
|
-
<%= section_link 'text filters' %>. The output, however, *will* be processed
|
812
|
-
by any filters that follow the macro filter in the chain.
|
564
|
+
*Note* that macro data is passed raw, and excluded from rendering by <%= section_link 'text filters' %>. The output, however, *will* be processed by any filters that follow the macro filter in the chain.
|
813
565
|
|
814
566
|
h5. Duck Filters
|
815
567
|
|
816
|
-
This being Ruby, you don't _have_ to inherit one of the above filters to create
|
817
|
-
your own - a filter is just an object with a @filter(text,page)@ method.
|
568
|
+
This being Ruby, you don't _have_ to inherit one of the above filters to create your own - a filter is just an object with a @filter(text,page)@ method.
|
818
569
|
|
819
570
|
The standard TOC filter takes this route.
|
820
571
|
|
821
572
|
<%= section 4, 'Rake Extensions' %>
|
822
573
|
|
823
|
-
Rote supplies a number of non-intrusive extensions a number of the Rake classes,
|
824
|
-
in order to support dynamic dependency caching, caching dependency-based block
|
825
|
-
memoize, and task reset for use in monitor mode. These features are very new, and
|
826
|
-
only lightly documented at present. You are advised to see the
|
827
|
-
"RDoc":<%= link_rel '/rdoc' %> and source if you want to find out more.
|
574
|
+
Rote supplies a number of non-intrusive extensions a number of the Rake classes, in order to support dynamic dependency caching, caching dependency-based block memoize, and task reset for use in monitor mode. These features are very new, and only lightly documented at present. You are advised to see the "RDoc":<%= link_rel '/rdoc' %> and source if you want to find out more.
|
828
575
|
|
829
576
|
These extensions were almost exclusively contributed by Jonathan Paisley.
|
830
577
|
|
831
578
|
h5. Dynamic dependency caching
|
832
579
|
|
833
|
-
Since layout files are specified in Ruby code, and may be calculated dynamically,
|
834
|
-
it's not possible to determine the layout files upon which a given page depends
|
835
|
-
without running that page's code (including all COMMON.rb files that apply to it,
|
836
|
-
extension mapping blocks, and so forth). This would have (or, had) an adverse
|
837
|
-
impact on Rote's incremental build functionality, especially from the point of
|
838
|
-
view of source monitoring.
|
580
|
+
Since layout files are specified in Ruby code, and may be calculated dynamically, it's not possible to determine the layout files upon which a given page depends without running that page's code (including all COMMON.rb files that apply to it, extension mapping blocks, and so forth). This would have (or, had) an adverse impact on Rote's incremental build functionality, especially from the point of view of source monitoring.
|
839
581
|
|
840
|
-
This problem is addressed by a small Rake extension that adds the ability to
|
841
|
-
dynamically register dependencies on the current task, and to have those
|
842
|
-
dependencies cached when Rake exits. Internally, Rote automatically registers
|
843
|
-
any layouts loaded by a page, and you can easily register additional dependencies
|
844
|
-
from any Ruby code, by calling methods on the @Rake@ module.
|
582
|
+
This problem is addressed by a small Rake extension that adds the ability to dynamically register dependencies on the current task, and to have those dependencies cached when Rake exits. Internally, Rote automatically registers any layouts loaded by a page, and you can easily register additional dependencies from any Ruby code, by calling methods on the @Rake@ module.
|
845
583
|
|
846
|
-
*Note* that this extension is intended, and tested, for Rote - it is not designed
|
847
|
-
to be a general extension (though one could easily be extracted from it). In
|
848
|
-
particular it takes advantage of other extended functionality provided by Rote,
|
849
|
-
and takes no account, for example, of parallel task execution.
|
584
|
+
*Note* that this extension is intended, and tested, for Rote - it is not designed to be a general extension (though one could easily be extracted from it). In particular it takes advantage of other extended functionality provided by Rote, and takes no account, for example, of parallel task execution.
|
850
585
|
|
851
|
-
By default, the cache is maintained in the project root, in a directory named
|
852
|
-
@.rake_cache@. This is managed by Rote, so for the most part can be ignored,
|
853
|
-
though you can of course supply an alternate path if you wish (via @Rake.cache_dir=@).
|
586
|
+
By default, the cache is maintained in the project root, in a directory named @.rake_cache@. This is managed by Rote, so for the most part can be ignored, though you can of course supply an alternate path if you wish (via @Rake.cache_dir=@).
|
854
587
|
|
855
588
|
h6. Caching and clean builds
|
856
589
|
|
857
|
-
When performing a clean build, the cache will also be removed (as part of the
|
858
|
-
@clobber@ task), and all dependencies will be re-evaluated and cached afresh.
|
859
|
-
Caching exists only to allow accurate dependency resolution during incremental
|
860
|
-
builds.
|
590
|
+
When performing a clean build, the cache will also be removed (as part of the @clobber@ task), and all dependencies will be re-evaluated and cached afresh. Caching exists only to allow accurate dependency resolution during incremental builds.
|
861
591
|
|
862
592
|
h6. Disabling the cache
|
863
593
|
|
864
|
-
There may be occasions when you want to disable use of the cache (for example when
|
865
|
-
diagnosing unexpected dependency chains). This can be accomplished by setting
|
866
|
-
an environment variable, NO_RAKE_CACHE prior to invoking Rote (or Rake). For a
|
867
|
-
single invocation, the easiest way to do this is from the command-line:
|
594
|
+
There may be occasions when you want to disable use of the cache (for example when diagnosing unexpected dependency chains). This can be accomplished by setting an environment variable, NO_RAKE_CACHE prior to invoking Rote (or Rake). For a single invocation, the easiest way to do this is from the command-line:
|
868
595
|
|
869
596
|
<pre><code>
|
870
597
|
rake clobber doc NO_RAKE_CACHE=true
|
871
598
|
</code></pre>
|
872
599
|
|
873
|
-
Specifying this option (or setting the variable) will completely disable use of
|
874
|
-
the cache, causing any existing cache to be ignored and all dependencies determined
|
875
|
-
during the run to be discarded.
|
600
|
+
Specifying this option (or setting the variable) will completely disable use of the cache, causing any existing cache to be ignored and all dependencies determined during the run to be discarded.
|
876
601
|
|
877
602
|
h5. Dependency-based block memoize
|
878
603
|
|
879
|
-
Somewhat related to dependency caching, Rote also provides the ability to memoize
|
880
|
-
Ruby block results, caching them to disk, and only execute the block during
|
881
|
-
incremental builds. This is handy if, for example, you want to incorporate information
|
882
|
-
derived from external commands, for example, or index large files in your documentation.
|
604
|
+
Somewhat related to dependency caching, Rote also provides the ability to memoize Ruby block results, caching them to disk, and only execute the block during incremental builds. This is handy if, for example, you want to incorporate information derived from external commands, for example, or index large files in your documentation.
|
883
605
|
|
884
606
|
The following (OSX-specific) example illustrates usage of this feature:
|
885
607
|
|
@@ -899,10 +621,6 @@ The following (OSX-specific) example illustrates usage of this feature:
|
|
899
621
|
|
900
622
|
<%= section 3, 'Final notes' %>
|
901
623
|
|
902
|
-
Rake is a *very* flexible tool, and supports a wide variety of configuration
|
903
|
-
options and advanced features you can use to fit Rote to your needs. Such
|
904
|
-
configuration is (far) beyond the scope of this manual - see
|
905
|
-
"Rake's Documentation":http://rake.rubyforge.org/ for information on the
|
906
|
-
features supported by Rake.
|
624
|
+
Rake is a *very* flexible tool, and supports a wide variety of configuration options and advanced features you can use to fit Rote to your needs. Such configuration is (far) beyond the scope of this manual - see "Rake's Documentation":http://rake.rubyforge.org/ for information on the features supported by Rake.
|
907
625
|
|
908
626
|
[<%= section_link 'Top' %>]
|