rote 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CONTRIBUTORS ADDED
@@ -0,0 +1,14 @@
1
+ == The Contributors
2
+
3
+ Many of Rote's best bits come from contributions made by other Rubyists,
4
+ whether in the form of fully pegged-out features, patches, or suggestions.
5
+ Without the help and guidance of these people, Rote would almost certainly
6
+ suck like a hoover.
7
+
8
+ ===== Jonathan Paisley <jp-www at dcs gla ac uk>
9
+ * Auto -run tasks
10
+ * COMMON.rb inheritance (with BOC)
11
+ * Rake magic
12
+ * better resource management
13
+ * Many other suggestions for improvements
14
+
data/README CHANGED
@@ -15,17 +15,17 @@ layout, and general documentation / website build tasks.
15
15
  Rote uses 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.3 ('yum install ruby' on Fedora 4)
18
+ * Ruby 1.8.x
19
19
  * Rake 0.6.2 ('gem install rake')
20
- * RedCloth 3.0.4 ('gem install RedCloth')
20
+ * RedCloth 3.0.4 ('gem install RedCloth') (_Only required if :textile or :markdown formatting is used_)
21
21
 
22
22
  RubyGems [http://rubyforge.org/frs/?group_id=126] is *highly recommended*,
23
23
  and makes for not only an easier install but a cleaner library path.
24
24
  Rote is tested with Gems 0.8.11.
25
25
 
26
26
  Please note that Rote is written and tested on Linux - I have no facilities
27
- to test with, e.g. Windows, and would like to hear about any issues that affect
28
- usage with other OSes.
27
+ to test with, e.g. Windows, and would like very much to hear about any issues
28
+ that affect usage with other OSes.
29
29
 
30
30
  == Installation ...
31
31
 
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,v 1.9 2005/12/01 11:06:40 roscopeco Exp $
9
+ # $Id: Rakefile,v 1.10 2005/12/02 20:07:16 roscopeco Exp $
10
10
  #
11
11
 
12
12
  begin
@@ -108,7 +108,7 @@ rd = Rake::RDocTask.new("rdoc") { |rdoc|
108
108
  rdoc.template = 'doc/jamis.rb'
109
109
  rdoc.title = "Rote"
110
110
  rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
111
- rdoc.rdoc_files.include('README', 'LICENSE', 'TODO')
111
+ rdoc.rdoc_files.include('README', 'LICENSE', 'TODO', 'CONTRIBUTORS')
112
112
  rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
113
113
  rdoc.rdoc_files.exclude(/\bcontrib\b/)
114
114
  }
@@ -120,7 +120,7 @@ ws = Rote::DocTask.new(:doc) { |site|
120
120
  site.pages.dir = 'doc/pages'
121
121
  site.pages.include('**/*')
122
122
 
123
- site.res.dir = 'doc/res/'
123
+ site.res.dir = 'doc/res'
124
124
  site.res.include('**/*.png')
125
125
  site.res.include('**/*.gif')
126
126
  site.res.include('**/*.jpg')
data/TODO CHANGED
@@ -7,9 +7,10 @@ Send any suggestions (or test-driven patches) to:
7
7
 
8
8
  * More flexible markup rendering
9
9
  * Nested layouts
10
- * Integration with test reports
11
- * Automatic navigation / TOC
10
+ * Find and Integrate test run / coverage reports
12
11
  * Ability to have multiple views of a section, e.g. user guide (separate
13
12
  pages) and user guide (one page) generated from same source.
14
13
  * Index and glossary support
15
14
  * statistics
15
+ * (maybe?) Automatic navigation / TOC
16
+ * (maybe?) Rant integration
@@ -40,7 +40,8 @@
40
40
 
41
41
  <div class='copyright'><strong>&copy; 2005 Ross Bamford</strong><br/>
42
42
  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/>
43
- Hosting &amp; development services provided by <a href='http://rubyforge.org/'>RubyForge.org</a>
43
+ Hosting &amp; development services provided by <a href='http://rubyforge.org/'>RubyForge.org</a><br/>
44
+ [<a href='http://validator.w3.org/check?uri=referer'>Validate</a>]
44
45
  <p/>&nbsp;
45
46
  </div>
46
47
  </body>
data/doc/pages/COMMON.rb CHANGED
@@ -33,6 +33,6 @@ format_opts << :textile
33
33
  :url => 'http://rubyforge.org/projects/rote'},
34
34
  {:title => 'Browse CVS',
35
35
  :url => 'http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote'},
36
- {:title => 'License',
36
+ {:title => 'Licence',
37
37
  :url => '/license.html'}
38
38
  ]
@@ -9,7 +9,9 @@ for installation instructions.
9
9
  <a name='top'/>
10
10
  h3. Contents
11
11
 
12
+ * "Conventions":#conventions
12
13
  * "Getting started with Rote":#getting_started
14
+ ** "Documentation source layout":#getting_started_source_layout
13
15
  ** "From the command-line":#getting_started_command_line
14
16
  ** "From your Rakefile":#getting_started_rakefile
15
17
  * "Creating templates":#create_templates
@@ -18,19 +20,30 @@ h3. Contents
18
20
  ** "Template code & ERB":#create_templates_erb
19
21
  ** "Applying layout":#create_templates_layout
20
22
  * "Resources":#resources
23
+ * "Source monitoring":#monitor
21
24
  * "Publishing":#publishing
22
25
 
26
+ <a name='conventions'/>
27
+ h3. Conventions used in this document
28
+
29
+ *Task names* - Rote's standard tasks are always referred to with the base-name
30
+ _doc_ , e.g. @doc_pages@, @doc_clean@, and just plain @doc@. This is the prefix
31
+ used by the built-in Rakefile, but since it can be changed when using Rote in
32
+ your own Rake builds you should of course substitute whatever is appropriate
33
+ if you have chosen to modify it.
34
+
23
35
  <a name='getting_started'/>
24
36
  h3. Getting started with Rote
25
37
 
26
- h4. Setting up a project
38
+ <a name='getting_started_source_layout'/>
39
+ h4. Documentation source layout
27
40
 
28
41
  To get started quickly, we'll use the standard Rote directory layout, which
29
42
  can be used immediately with the command-line wrapper, and fits well with
30
43
  Rakefile usage too. Basically, Rote expects your documentation source to
31
44
  be laid out as follows:
32
45
 
33
- <code><pre>
46
+ <p><code><pre>
34
47
  project_root ( <- root, this can be called whatever you like)
35
48
  |
36
49
  |--> [publish.rf]
@@ -54,7 +67,7 @@ be laid out as follows:
54
67
  | | | |--> bpage.html
55
68
  | | | |--> [bpage.rb]
56
69
 
57
- </code></pre>
70
+ </pre></code></p>
58
71
 
59
72
  Template sources under the 'pages' directory may have any extension (except
60
73
  @rb@), and will be rendered to that same name under the output directory.
@@ -66,7 +79,7 @@ directory. See "the section on templates":#create_templates for more
66
79
  information on the specifics.
67
80
 
68
81
  If you've downloaded Rote, then you can see the canonical example site by
69
- looking in the =doc/= directory (where you'll find the source for this
82
+ looking in the @doc/@ directory (where you'll find the source for this
70
83
  site).
71
84
 
72
85
  ["top":#top]
@@ -83,7 +96,7 @@ setting up library dependencies and generation of appropriate tasks.
83
96
  The command-line wrapper expects the above layout, and requires no direct
84
97
  configuration. To generate an entire documentation set, simply run:
85
98
 
86
- <pre><code> rote</code></pre>
99
+ <p><pre><code> rote</code></pre></p>
87
100
 
88
101
  from the top-level directory (@project@ in the example above), you should get
89
102
  a 'html' directory created with the (transformed) templates, and any
@@ -100,20 +113,20 @@ The file tasks are named for the target files, so for example to generate
100
113
  just the top-level index.html (regardless of whether it's been modified)
101
114
  you'd run:
102
115
 
103
- <pre><code> rote html/index.html</code></pre>
116
+ <p><pre><code> rote html/index.html</code></pre></p>
104
117
 
105
- The @clean@ task supports deleting all output files to start from scratch:
118
+ The @clobber@ task supports deleting all output files to start from scratch:
106
119
 
107
- <pre><code> rote clean</code></pre>
120
+ <p><pre><code> rote clobber</code></pre></p>
108
121
 
109
122
  Of course, multiple file or task names (or a mixture) can be specified.
110
123
  You can get a list of valid tasks in the current context with:
111
124
 
112
- <pre><code> rote --tasks</code></pre>
125
+ <p><pre><code> rote --tasks</code></pre></p>
113
126
 
114
127
  Further command-line usage information is available with:
115
128
 
116
- <pre><code> rote --usage</code></pre>
129
+ <p><pre><code> rote --usage</code></pre></p>
117
130
 
118
131
  and Unix installations performed with =install.rb= should also make a
119
132
  manpage available for the @rote@ command.
@@ -166,7 +179,7 @@ h3. Creating templates
166
179
  <a name='create_templates_basics'/>
167
180
  h4. The basics
168
181
 
169
- As mentioned, templates are simply text files in the =doc/pages= directory. The
182
+ As mentioned, templates are simply text files in the @doc/pages@ directory. The
170
183
  layout below that directory is retained when transforming pages, and is
171
184
  also used to provide simple hierarchical structure to the common page code.
172
185
 
@@ -186,7 +199,7 @@ The formatting applied to a given page is controlled by that page's @format_opts
186
199
  array. All three are disabled by default - to enable formatting you must add
187
200
  appropriate symbols to the array, for example in page code or COMMON.rb:
188
201
 
189
- <pre><code> format_opts << :textile << :markdown << :rdoc</code></pre>
202
+ <p><pre><code> format_opts << :textile << :markdown << :rdoc</code></pre></p>
190
203
 
191
204
  This can be done in page code, COMMON.rb, or even inside the template itself.
192
205
  See "the section on template code":#create_templates_erb for more information
@@ -196,9 +209,10 @@ then Rdoc.
196
209
 
197
210
  *Some additional notes on formatting*
198
211
 
199
- * Although you can directly assign to @format_opts@, this isn't recommended
200
- since Ruby often interprets it as a local variable set rather than method call,
201
- resulting in much head scratching as to why your options are being ignored.
212
+ * You cannot directly assign to @format_opts@, from page code since Ruby
213
+ interprets assignments with no receiver as local variable sets rather than
214
+ method calls, resulting in much head scratching as to why your options are
215
+ being ignored. Always use the << :opt syntax.
202
216
 
203
217
  * Note that *Formatting is applied _after_ any ERB has been evaluated.*
204
218
 
@@ -224,7 +238,7 @@ you might define such variables. The following is in order of evaluation:
224
238
  * In a block passed to Page.new
225
239
  * In the template itself
226
240
 
227
- When a =Rote::Page= instance is created, Rote looks for these, and if found
241
+ When a @Rote::Page@ instance is created, Rote looks for these, and if found
228
242
  evaluates them, in order, in the same binding as the template is later rendered
229
243
  in (i.e. the @Page@ instance binding). Therefore, you can define
230
244
  instance variables to pass data around, or even helper methods if you wish.
@@ -234,27 +248,29 @@ instance variables to pass data around, or even helper methods if you wish.
234
248
  <a name='create_templates_layout'/>
235
249
  h4. Layout
236
250
 
237
- Layouts are stored under the =doc/layouts= directory (by default). They may
251
+ Layouts are stored under the @doc/layouts@ directory (by default). They may
238
252
  be organised into subdirectories, but this hierarchy is not connected to
239
253
  the hierarchy in @pages@. To apply a layout to a page, simply call the
240
- =Rote::Page.layout= method from code applied to that page, passing the
254
+ @Rote::Page.layout@ method from code applied to that page, passing the
241
255
  base-name (and path, relative to @layouts@, if used). If no extension is
242
256
  specified, then the same extension as the page itself is assumed. Examples:
243
257
 
244
- <pre>
245
- layout 'one'
246
- layout 'main/wide'
247
- layout 'dark.txt'
248
- &lt;% layout 'my' %&gt;
249
- </pre>
258
+ * layout 'one'
259
+ * layout 'main/wide'
260
+ * layout 'dark.txt'
261
+ * <&#37; layout 'my' &#37;>
262
+
263
+ _*Note* the absence of the = sign in the ERB tag in the last example,_
264
+ _indicating that this is code to be executed rather than code that should_
265
+ _generate output._
250
266
 
251
267
  With that done, Rote would first render the template text (including textile)
252
- and set the Page instance variable =@content_for_layout= before rendering
268
+ and set the Page instance variable @\@content_for_layout@ before rendering
253
269
  the layout (in which textile is currently not supported). The layout is
254
270
  responsible for inserting the rendered template where appropriate, with
255
271
  e.g.:
256
272
 
257
- <pre> &lt;%= @content_for_layout %&gt;</pre>
273
+ * <&#37;= @content_for_layout &#37;>
258
274
 
259
275
  This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate
260
276
  HTML, despite the appearance from the ERB tags - any (textual) format can
@@ -267,26 +283,64 @@ h3. Resources
267
283
 
268
284
  Of course, you're likely to have resources for your site (images, sounds, etc)
269
285
  and you'll need to copy them over to the target too. Such resources should be
270
- placed under 'res' (with the commandline setup) or in your specified @res@
271
- directory, and will be copied directly to the output directory after page
272
- rendering.
286
+ placed under @doc/res@ (with the commandline setup) or in your specified @res@
287
+ directory (from a Rakefile).
273
288
 
274
289
  As you'd expect, the directory layout beneath @res@ should mirror that of the
275
- output, and will be preserved during the copy.
290
+ output, and will be preserved during the copy. Resources are copied only if
291
+ necessary (determined by existence and last-modified timestamp), in a similar
292
+ way to pages.
276
293
 
277
294
  ["top":#top]
278
295
 
296
+ <a name='monitor'/>
297
+ h3. Source monitoring
298
+
299
+ When making changes to a documentation set, you frequently need to render out
300
+ your changes to check formatting or ensure something works correctly. In this
301
+ situation it's inconvenient to keep dropping out to your shell to run @rote@
302
+ (or @rake@) manually, particularly when making a lot of incremental changes.
303
+
304
+ Fortunately, Rote provides a simple mechanism for monitoring your documentation
305
+ source and automatically performing updates as needed. Simply specify the
306
+ @doc_monitor@ task and Rote will go into a loop, periodically running the
307
+ top-level _doc_ task which will transform / copy any pages or resources that
308
+ have been modified. It will of course take notice of any custom file or directory
309
+ dependencies you add to the doc task (e.g. to generate RDoc as part of a
310
+ website), and in turn monitor their dependent files too (for example rebuilding
311
+ the RDoc if you modify a source file). It does *not* however attempt to track
312
+ format-specific dependencies _between_ resources (such as which pages use which
313
+ CSS), since this would imply some knowledge of the format in use. In practice
314
+ this means that you may need to trigger a clean build after updating such
315
+ resources, although it is actually fairly easy to set up this kind of
316
+ relationship by specifying that certain file-tasks relating to pages depend
317
+ on the appropriate file-tasks representing the resources (for instance).
318
+
319
+ By default, @monitor@ checks for updates approximately once
320
+ per second, but you can specify a custom value _when using a Rakefile_ by
321
+ setting @monitor_interval@ in the block passed to @DocTask.new@.
322
+
323
+ *Note* that the monitor functionality is deliberately kept simple with respect
324
+ to IO and concurrency, reflecting the fact that output files are rarely
325
+ anything more than that - it would be almost pointless to complicate the
326
+ way monitoring works with any kind of semaphore or file-locking scheme.
327
+ Of course if this does cause problems in your particular scenario, let me know
328
+ because it just might make me reconsider.
329
+
330
+ When you're done with Rote simply hit CTRL-C (or use @kill@) to stop monitoring
331
+ and exit.
332
+
279
333
  <a name='publishing'/>
280
334
  h3. Publishing
281
335
 
282
336
  Rote does not provide any direct support for publishing your site at present,
283
337
  relying on you to configure an appropriate publish task if required, using
284
- the publishers supplied with Rake (in =rake/contrib=), or your own. This
338
+ the publishers supplied with Rake (in @rake/contrib@), or your own. This
285
339
  allows maximum flexibility, and allows Rote to concentrate on creating your
286
340
  documents.
287
341
 
288
342
  The command-line build will automatically look for a file in the top-level
289
- directory (above @doc@) named =publish.rf=. If found, this file will be
343
+ directory (above @doc@) named @publish.rf@. If found, this file will be
290
344
  evaluated by Rake, making any tasks defined within it available to your
291
345
  build. The most likely use case is to define a task that uses an SSH directory
292
346
  publisher to publish via SCP.
@@ -300,12 +354,12 @@ Currently, there isn't enough checking involved on source resources when
300
354
  building pages - Basically, only templates are considered when Rake decides
301
355
  what to update. If you change layouts, code or resources you'll need to run:
302
356
 
303
- <pre><code> rote clean</code></pre>
357
+ <p><pre><code> rote clobber</code></pre></p>
304
358
 
305
359
  to make sure everything gets updated. It's recommended to always run upload
306
360
  as:
307
361
 
308
- <pre><code> rote clean upload</code></pre>
362
+ <p><pre><code> rote clobber upload</code></pre></p>
309
363
 
310
364
  Please note that this isn't Rake's limitation - it's mine. It will be fixed
311
365
  in a later version of Rote.
data/doc/pages/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  easier to author and maintain non-dynamic websites and
3
3
  offline documentation.* Rote provides a simple commandline or
4
4
  "Rake":http://rake.rubyforge.org based build for your pages, with page
5
- rendering (optionally supporting Textile and Markdown with
5
+ rendering (optionally supporting RDoc formatting, Textile and Markdown with
6
6
  "RedCloth":http://redcloth.rubyforge.org/ and ruby code with
7
7
  "ERB":http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html), layout,
8
8
  and general documentation / website build tasks.
@@ -12,20 +12,20 @@ h3. Features
12
12
  Rote offers the following major features:
13
13
 
14
14
  * Simple set-up based on page templates and sections.
15
- * ERB, Textile, and Markdown supported out of the box.
15
+ * ERB, Textile, Markdown and RDoc supported out of the box.
16
16
  * Multiple configurable layouts apply boilerplate to your pages.
17
17
  * 'Scoped' Ruby code support allows fine-grained control of data available across
18
18
  all documentation, a subset, or individual pages.
19
- * Can be used standalone (from the command-line) or from within "Rake":http://rake.rubyforge.org
19
+ * Can be used standalone (from the command-line) or within "Rake":http://rake.rubyforge.org
20
20
  as a custom task library.
21
21
  * Supports any (text-based) format, while providing utilities and helpers for
22
- common formats (HTML at present).
22
+ common formats (HTML at present, integration with CSS builder etc. hoped for).
23
23
 
24
24
  Rote is somewhat similar to (though simpler than)
25
25
  "WebGen":http://webgen.rubyforge.org , which provides a richer environment
26
26
  geared more toward websites and content publishing (whereas Rote's
27
27
  implementation as an extension to Rake reflects a bias toward software
28
- documentation).
28
+ documentation and general textual templating).
29
29
 
30
30
  See the "User guide":<%= link_rel '/guide' %> and "RDoc":<%= link_rel '/rdoc' %> for usage information.
31
31
 
@@ -35,17 +35,17 @@ You can get Rote via "RubyGems":http://rubyforge.org/projects/rubygems if you ha
35
35
 
36
36
  * <strong><code>gem install -r rote</code></strong>
37
37
 
38
- Alternatively, you can download tarball / zip packages from:
38
+ Alternatively, you can download tarball / zip packages if you don't:
39
39
 
40
40
  * <strong>"http://rubyforge.org/frs/?group_id=1120":http://rubyforge.org/frs/?group_id=1120</strong>
41
41
 
42
- You can also grab the latest code from "CVS":http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote.
42
+ You can also grab the latest code from "CVS":http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote.
43
43
 
44
44
  h4. From CVS
45
45
 
46
46
  A link to the latest stable release can be found from the "project page":http://rubyforge.org/projects/rote .
47
47
 
48
- Please note that Rote is still pretty new, and while currently fairly functional, it's
49
- also still shiny and new, and liable to break down, destroy data, and run away with your spouse if
50
- given half a chance. Sound like fun? Then check out the "Project page on Rubyforge":http://rubyforge.org/projects/rote
51
- for everything you need to get going with the CVS version!
48
+ Please note that Rote is still fairly new, and though it's so far not shown itself to be particularly
49
+ anti-social, it's by no means a complete piece of kit. If that's okay with you (maybe you're
50
+ pretty happy-go-lucky in general...) then see the "Project page on Rubyforge":http://rubyforge.org/projects/rote
51
+ for everything you need to get going with the CVS version.
@@ -116,8 +116,8 @@ div.copyright {
116
116
 
117
117
  div.main {
118
118
  /* main div on front page */
119
- width: 90%;
120
- margin: 2% 2% 2% 2%;
119
+ width: 70%;
120
+ margin: 50px 12% 50px 8%;
121
121
  }
122
122
 
123
123
  img.smallrpotlogo {
@@ -138,4 +138,12 @@ img.medlogo {
138
138
  img.smalllogo {
139
139
  width: 147px;
140
140
  height: 68px;
141
- }
141
+ }
142
+
143
+ h3 {
144
+ border-bottom: thin #959595 solid;
145
+ }
146
+
147
+ h4 {
148
+ border-bottom: thin #b8c8c8 solid;
149
+ }
data/lib/rote.rb CHANGED
@@ -41,7 +41,7 @@ require 'net/ftp'
41
41
  require 'rake'
42
42
 
43
43
  # Master Rote version. Manage this from the Rake release support.
44
- ROTEVERSION = '0.2.0'
44
+ ROTEVERSION = '0.2.2'
45
45
 
46
46
  #####
47
47
  ## *Rote* is a Rake (http://rake.rubyforge.org) based build tool for page-based
data/lib/rote/builtin.rf CHANGED
@@ -5,17 +5,25 @@ require 'rake'
5
5
  require 'rake/clean'
6
6
  require 'rote'
7
7
 
8
- CLEAN.include('html')
9
-
10
- # Create a task build the website / docs
11
- ws = Rote::DocTask.new("doc") { |site|
8
+ # Create tasks to build the doc tree
9
+ #
10
+ # Creates the following tasks
11
+ #
12
+ # doc - Everything
13
+ # doc-pages - Transform all modified pages
14
+ # doc-res - Copy all resources
15
+ # doc-clean - Remove generated documentation
16
+ # html/[filename] - Transform single [filename] unconditionally
17
+ # doc-monitor - Start monitor mode on doc source
18
+ #
19
+ ws = Rote::DocTask.new(:doc) { |site|
12
20
  site.output_dir = 'html'
13
21
  site.layout_dir = 'doc/layouts'
14
22
 
15
23
  site.pages.dir = 'doc/pages'
16
24
  site.pages.include('**/*')
17
25
 
18
- site.res.dir = 'doc/res/'
26
+ site.res.dir = 'doc/res'
19
27
  site.res.include('**/*.png')
20
28
  site.res.include('**/*.gif')
21
29
  site.res.include('**/*.jpg')
data/lib/rote/page.rb CHANGED
@@ -31,10 +31,12 @@ module Rote
31
31
  # when (if) the page source calls layout(basename).
32
32
  attr_reader :layout_text
33
33
 
34
- # Formatting options passed to RedCloth. This is an array of the
35
- # option symbols defined by RedCloth.
36
- # The most common are :textile and :markdown. See RedCloth
37
- # documentation for full details of supported options.
34
+ # Formatting options for this page. This is an array of the
35
+ # option symbols, as defined by RedCloth, with a further +:rdoc+
36
+ # symbol that selects RDoc formatting. The most common are
37
+ # :textile. :markdown, and :rdoc, but additional options are
38
+ # supported by RedCloth - see it's documentation for full details
39
+ # of supported option symbols and their effect.
38
40
  #
39
41
  # The default is [], which means 'No formatting'. This setting
40
42
  # does not affect ERB rendering (which is always performed, before
@@ -77,8 +79,8 @@ module Rote
77
79
  # get script filenames, and eval them if found
78
80
  src_rb = template_fn.sub(/\..*$/,'') + '.rb'
79
81
  section_rb = @fixme_dir + '/COMMON.rb'
80
- instance_eval(File.read(section_rb)) if File.exists?(section_rb)
81
- instance_eval(File.read(src_rb)) if File.exists?(src_rb)
82
+ instance_eval(File.read(section_rb),section_rb) if File.exists?(section_rb)
83
+ instance_eval(File.read(src_rb),src_rb) if File.exists?(src_rb)
82
84
 
83
85
  # Allow block to have the final say
84
86
  yield self if block_given?
@@ -208,10 +210,12 @@ module Rote
208
210
  end
209
211
  end
210
212
 
211
- # FIXME NASTY HACK II: relative links (doesn't work)
213
+ # FIXME NASTY HACK II: relative links (kinda works, but simply. Handy when
214
+ # you do both local preview from some deep directory, and remote deployment
215
+ # to a root)
212
216
  def link_rel(href)
213
217
  thr = href
214
- if thr.is_a?(String) && href[0,1] == '/'
218
+ if thr.is_a?(String) && href[0,1] == '/' # only interested in absolute
215
219
  thr = href[1..href.length]
216
220
  count = @fixme_dir.split('/').length - 2
217
221
  if count > 0 then count.times {
@@ -222,4 +226,4 @@ module Rote
222
226
  end
223
227
 
224
228
  end #class
225
- end #module
229
+ end #module
@@ -63,7 +63,7 @@ module Rote
63
63
  class DocTask < Rake::TaskLib
64
64
  # Default exclusion patterns for the page sources. These are
65
65
  # applied along with the defaults from +FileList+.
66
- DEFAULT_SRC_EXCLUDES = [ /\.rb$/ ]
66
+ DEFAULT_SRC_EXCLUDES = [ /\.rb$/, /\.rf$/ ]
67
67
 
68
68
  # The base-name for tasks created by this instance, supplied at
69
69
  # instantiation.
@@ -82,12 +82,25 @@ module Rote
82
82
  # Globs for the +FileList+ that supplies the resources to copy. You
83
83
  # should configure the +layout_dir+ and +include+ at least one entry
84
84
  # here (you may add +exclude+ strings or regexps, too).
85
+ #
86
+ # This is *not* a +FileList+ - the patterns supplied to this are used
87
+ # with the base-directory specified to construct an appropriate
88
+ # +FileList+.
85
89
  attr_reader :res
86
90
 
87
91
  # If +show_page_tasks+ is +true+, then the file tasks created for each
88
92
  # source page will be shown in the Rake task listing from the command line.
89
- attr_accessor :show_page_tasks
90
- alias :show_page_tasks? :show_page_tasks
93
+ attr_accessor :show_file_tasks
94
+ alias :show_file_tasks? :show_file_tasks
95
+ alias :show_file_tasks= :show_file_tasks=
96
+
97
+ # *Deprecated* alias for +show_file_tasks+. It will be removed.
98
+ alias :show_page_tasks? :show_file_tasks # vv0.3.0 v-0.5
99
+ alias :show_page_tasks= :show_file_tasks=
100
+
101
+ # The approximate number of seconds between update checks when running
102
+ # monitor mode (Default: 1)
103
+ attr_accessor :monitor_interval
91
104
 
92
105
  # Create a new DocTask, using the supplied block for configuration,
93
106
  # and define tasks with the specified base-name within Rake.
@@ -96,6 +109,7 @@ module Rote
96
109
  @output_dir = '.'
97
110
  @pages = FilePatterns.new('.')
98
111
  @res = FilePatterns.new('.')
112
+ @monitor_interval = 1
99
113
  DEFAULT_SRC_EXCLUDES.each { |excl| @pages.exclude(excl) }
100
114
 
101
115
  @show_page_tasks = false
@@ -114,55 +128,90 @@ module Rote
114
128
  nil
115
129
  end
116
130
 
131
+ # define a task for each resource, and 'all resources' task
117
132
  def define_res_tasks
118
133
  res_fl = res.to_filelist
134
+ tasks = res_fl.select { |fn| not File.directory?(fn) }.map do |fn|
135
+ tfn = fn.sub(/^#{res.dir}/, output_dir)
136
+ desc "#{fn} => #{tfn}" if show_file_tasks?
137
+ file tfn => [fn] do
138
+ dn = File.dirname(tfn)
139
+ mkdir_p dn unless File.exists?(dn)
140
+ cp fn, tfn
141
+ end
142
+ tfn
143
+ end
119
144
 
120
- desc "Copy documentation resources"
121
- task "#{name}-res" do
122
- res_fl.each { |fn|
123
- unless File.directory?(fn) # make dirs only as needed
124
- tfn = fn.sub(/#{res.dir}/, output_dir)
125
- dn = File.dirname(tfn)
126
- mkdir_p dn unless File.exists?(dn)
127
- cp fn, tfn
128
- end
129
- }
130
- end #task
145
+ desc "Copy new/changed resources"
146
+ task "#{name}_res" => tasks
131
147
  end
132
148
 
149
+ # define a task for each page, and 'all pages' task
133
150
  def define_page_tasks
134
- # make file list
135
- pages_fl = pages.to_filelist
136
-
137
- # define a task for each page
138
- realpages = FileList[]
139
- pages_fl.each { |fn|
140
- unless File.directory?(fn) # make dirs only as needed
141
- realpages << fn
142
- tfn = fn.sub(/^#{pages.dir}/, output_dir)
143
-
144
- desc "#{fn} => #{tfn}" if show_page_tasks?
145
- file tfn => [fn] do
146
- dn = File.dirname(tfn)
147
- mkdir_p dn unless File.exists?(dn)
148
- File.open(tfn, 'w+') { |f|
149
- puts "tr #{fn} => #{tfn}"
150
- f << Page.new(fn,layout_dir).render
151
- }
152
- end
151
+ pages_fl = pages.to_filelist
152
+ tasks = pages_fl.select { |fn| not File.directory?(fn) }.map do |fn|
153
+ tfn = fn.sub(/^#{pages.dir}/, output_dir)
154
+ desc "#{fn} => #{tfn}" if show_file_tasks?
155
+ file tfn => [fn] do
156
+ dn = File.dirname(tfn)
157
+ mkdir_p dn unless File.exists?(dn)
158
+ File.open(tfn, 'w+') do |f|
159
+ puts "tr #{fn} => #{tfn}"
160
+ f << Page.new(fn,layout_dir).render
161
+ end
153
162
  end
154
- }
163
+ tfn
164
+ end
155
165
 
156
- # this is pretty convenient ;]
157
- desc "Render all documentation pages"
158
- task "#{name}-pages" => realpages.sub(/#{pages.dir}/, output_dir)
166
+ desc "Render new/changed documentation pages"
167
+ task "#{name}_pages" => tasks
159
168
  end
160
169
 
161
170
  def define_main_tasks
162
171
  desc "Build the documentation"
163
- task name => ["#{name}-pages", "#{name}-res"]
172
+ task name => ["#{name}_pages", "#{name}_res"]
173
+
174
+ task :clobber => [ "clobber_#{name}" ]
175
+ desc "Remove the generated documentation"
176
+ task "clobber_#{name}" do
177
+ rm_rf output_dir
178
+ end
179
+
180
+ # thanks to Jonathan Paisley for this :)
181
+ # Relies on Rake mods made below.
182
+ desc "Monitor and automatically rebuild the documentation"
183
+ task "#{name}_monitor" do
184
+ loop do
185
+ Rake::Task::tasks.each { |t| t.reset }
186
+ Rake::Task[name].invoke
187
+ if Rake::Task::tasks.grep(Rake::FileTask).detect { |t| t.executed? } then
188
+ Rake::Task["#{name}_refresh"].invoke if Rake::Task.task_defined?("#{name}_refresh")
189
+ end
190
+ sleep monitor_interval
191
+ end
192
+ end
193
+
164
194
  end
165
195
 
166
196
  end #class
167
197
 
168
- end #module
198
+ end #module
199
+
200
+ ## The -run task requires a few mods to Rake to let us fire
201
+ ## and reset task invocations in a loop.
202
+ module Rake
203
+ class Task
204
+ def reset
205
+ @already_invoked = false
206
+ @executed = false
207
+ end
208
+ def executed?
209
+ @executed
210
+ end
211
+ alias :pre_rote_execute :execute
212
+ def execute
213
+ @executed = true
214
+ pre_rote_execute
215
+ end
216
+ end
217
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rote
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
7
- date: 2005-12-01 00:00:00 +00:00
6
+ version: 0.2.2
7
+ date: 2005-12-03 00:00:00 +00:00
8
8
  summary: Adds template-based doc support to Rake.
9
9
  require_paths:
10
10
  - lib
@@ -33,6 +33,7 @@ files:
33
33
  - README
34
34
  - TODO
35
35
  - LICENSE
36
+ - CONTRIBUTORS
36
37
  - bin/rote
37
38
  - lib/rote.rb
38
39
  - lib/rote/rotetasks.rb
@@ -102,6 +103,7 @@ extra_rdoc_files:
102
103
  - README
103
104
  - LICENSE
104
105
  - TODO
106
+ - CONTRIBUTORS
105
107
  executables:
106
108
  - rote
107
109
  extensions: []