rote 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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.6 2005/11/27 15:57:45 roscopeco Exp $
9
+ # $Id: Rakefile,v 1.9 2005/12/01 11:06:40 roscopeco Exp $
10
10
  #
11
11
 
12
12
  begin
@@ -26,7 +26,7 @@ require 'rake/rdoctask'
26
26
  $:[0,1] = 'lib'
27
27
  require 'rote'
28
28
 
29
- CLEAN.include('testdata')
29
+ # CLEAN.include('testdata')
30
30
  CLOBBER.include('TAGS')
31
31
  CLOBBER.include('html')
32
32
 
@@ -85,10 +85,10 @@ end
85
85
  # t.warning = true
86
86
  # end
87
87
 
88
- directory 'testdata'
89
- [:alltests, :unittests].each do |t|
90
- task t => ['testdata']
91
- end
88
+ # directory 'testdata'
89
+ # [:alltests, :unittests].each do |t|
90
+ # task t => ['testdata']
91
+ # end
92
92
 
93
93
  # CVS Tasks ----------------------------------------------------------
94
94
 
@@ -117,7 +117,6 @@ rd = Rake::RDocTask.new("rdoc") { |rdoc|
117
117
  ws = Rote::DocTask.new(:doc) { |site|
118
118
  site.output_dir = 'html'
119
119
  site.layout_dir = 'doc/layouts'
120
-
121
120
  site.pages.dir = 'doc/pages'
122
121
  site.pages.include('**/*')
123
122
 
@@ -197,6 +196,8 @@ else
197
196
  '--template' << 'doc/jamis.rb'
198
197
  '-o' << 'html'
199
198
 
199
+ s.test_files = Dir.glob('test/gem_*.rb')
200
+
200
201
  #### Author and project details.
201
202
 
202
203
  s.author = "Ross Bamford"
data/bin/rote CHANGED
@@ -10,7 +10,6 @@ end
10
10
 
11
11
  begin
12
12
  require 'rubygems'
13
- require_gem 'rote'
14
13
  rescue LoadError
15
14
  # just ignore, don't use gems
16
15
  end
@@ -32,8 +31,7 @@ rescue LoadError
32
31
  fail = true # next time.
33
32
  retry
34
33
  else
35
- puts "Cannot execute Rote - Do you need to set $ROTE_LIB ?"
36
- exit(1)
34
+ croak
37
35
  end
38
36
  end
39
37
 
@@ -1,4 +1,4 @@
1
- <?xml version='1.0'?>
1
+ <?xml version='1.0' encoding='utf-8'?>
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/xhtml1-strict.dtd">
3
3
  <html>
4
4
 
@@ -21,9 +21,8 @@
21
21
  </tr>
22
22
  <tr class='topnav'>
23
23
  <td colspan='2'>
24
- <% @navigation.length.times do |i|
25
- nav = @navigation[i] %>
26
- <a id='nav' href='<%= link_rel nav[:url] %>'><%= nav[:title] %></a>
24
+ <% @navigation.each_with_index do |nav, i| %>
25
+ <a class='nav' href='<%= link_rel nav[:url] %>'><%= nav[:title] %></a>
27
26
  <% unless i == (@navigation.length - 1) %>|<% end %>
28
27
  <% end %>
29
28
  </td>
@@ -31,7 +30,7 @@
31
30
 
32
31
  </table>
33
32
 
34
- <div class='main' background='#c0a0c0'>
33
+ <div class='main'>
35
34
  <% if @page_title %>
36
35
  <h2><%= @page_title %></h2>
37
36
  <% end %>
@@ -45,4 +44,5 @@
45
44
  <p/>&nbsp;
46
45
  </div>
47
46
  </body>
47
+ </html>
48
48
 
@@ -15,8 +15,8 @@ h3. Contents
15
15
  * "Creating templates":#create_templates
16
16
  ** "Basics":#create_templates_basics
17
17
  ** "Formatting":#create_templates_formatting
18
- ** "Template code & ERB":create_templates_erb
19
- ** "Applying layout":create_templates_layout
18
+ ** "Template code & ERB":#create_templates_erb
19
+ ** "Applying layout":#create_templates_layout
20
20
  * "Resources":#resources
21
21
  * "Publishing":#publishing
22
22
 
@@ -57,7 +57,7 @@ be laid out as follows:
57
57
  </code></pre>
58
58
 
59
59
  Template sources under the 'pages' directory may have any extension (except
60
- =rb=), and will be rendered to that same name under the output directory.
60
+ @rb@), and will be rendered to that same name under the output directory.
61
61
  See the section on Layouts below for details on layout name resolution.
62
62
 
63
63
  Ruby source is optional, and allows you to define instance variables and
@@ -75,9 +75,9 @@ site).
75
75
  h4. From the command-line
76
76
 
77
77
  If you are generating a standalone documentation set (i.e. not as part of
78
- some wider build) then you don't need to worry about writing a =Rakefile= -
79
- you can use the built-in build via the +rote+ command. This works with
80
- a standard directory layout, and wraps invocation of +rake+ to handle
78
+ some wider build) then you don't need to worry about writing a @Rakefile@ -
79
+ you can use the built-in build via the @rote@ command. This works with
80
+ a standard directory layout, and wraps invocation of @rake@ to handle
81
81
  setting up library dependencies and generation of appropriate tasks.
82
82
 
83
83
  The command-line wrapper expects the above layout, and requires no direct
@@ -85,7 +85,7 @@ configuration. To generate an entire documentation set, simply run:
85
85
 
86
86
  <pre><code> rote</code></pre>
87
87
 
88
- from the top-level directory (=project= in the example above), you should get
88
+ from the top-level directory (@project@ in the example above), you should get
89
89
  a 'html' directory created with the (transformed) templates, and any
90
90
  resources should be copied as necessary.
91
91
 
@@ -102,7 +102,7 @@ you'd run:
102
102
 
103
103
  <pre><code> rote html/index.html</code></pre>
104
104
 
105
- The =clean= task supports deleting all output files to start from scratch:
105
+ The @clean@ task supports deleting all output files to start from scratch:
106
106
 
107
107
  <pre><code> rote clean</code></pre>
108
108
 
@@ -116,16 +116,16 @@ Further command-line usage information is available with:
116
116
  <pre><code> rote --usage</code></pre>
117
117
 
118
118
  and Unix installations performed with =install.rb= should also make a
119
- manpage available for the =rote= command.
119
+ manpage available for the @rote@ command.
120
120
 
121
121
  ["top":#top]
122
122
 
123
123
  <a name='getting_started_rakefile'/>
124
- h4. From your +Rakefile+
124
+ h4. From your @Rakefile@
125
125
 
126
126
  If you are wanting to build documentation as part of a larger build process, or
127
127
  commandline setup, then you'll want to get started on integrating Rote with
128
- your own (existing) +Rakefile+. Fortunately, this is very easy to do. Try
128
+ your own (existing) @Rakefile@. Fortunately, this is very easy to do. Try
129
129
  something like:
130
130
 
131
131
  <pre><code>
@@ -148,14 +148,14 @@ something like:
148
148
 
149
149
  </code></pre>
150
150
 
151
- Save this as =Rakefile=, and fire up:
151
+ Save this as @Rakefile@, and fire up:
152
152
 
153
153
  <pre><code> rake doc</code></pre>
154
154
 
155
155
  If all goes well, you should see each command and transformation output to your
156
156
  console as Rote runs.
157
157
 
158
- *Note* that it's safe to include '**/*' in the +pages+ list, since +rb+
158
+ *Note* that it's safe to include '**/*' in the @pages@ list, since @rb@
159
159
  files are implicitly excluded.
160
160
 
161
161
  ["top":#top]
@@ -170,7 +170,7 @@ As mentioned, templates are simply text files in the =doc/pages= directory. The
170
170
  layout below that directory is retained when transforming pages, and is
171
171
  also used to provide simple hierarchical structure to the common page code.
172
172
 
173
- By default, any file with an extension other than =rb= will be processed
173
+ By default, any file with an extension other than @rb@ will be processed
174
174
  as a page template (with it's associated ruby source). The output will have
175
175
  the same filename and path, relative to the output directory.
176
176
 
@@ -180,21 +180,23 @@ the same filename and path, relative to the output directory.
180
180
  h4. Applying formatting
181
181
 
182
182
  If you're generating HTML, you'll probably want to use some plaintext
183
- formatting, rather than writing HTML by hand. Rote uses
184
- "RedCloth":http://redcloth.rubyforge.org to provide text to HTML formatting,
185
- supporting both Textile and Markdown. The formatting applied to a given page is
186
- controlled by that page's +format_opts+ array. Both are disabled by default - to
187
- enable formatting you must add something like the following somewhere appropriate:
183
+ formatting, rather than writing HTML by hand. Rote directly supports
184
+ the Textile, Markdown and Rdoc textual formatting styles.
185
+ The formatting applied to a given page is controlled by that page's @format_opts@
186
+ array. All three are disabled by default - to enable formatting you must add
187
+ appropriate symbols to the array, for example in page code or COMMON.rb:
188
+
189
+ <pre><code> format_opts << :textile << :markdown << :rdoc</code></pre>
188
190
 
189
- <pre><code> format_opts << :textile << :markdown</code></pre>
190
-
191
191
  This can be done in page code, COMMON.rb, or even inside the template itself.
192
192
  See "the section on template code":#create_templates_erb for more information
193
- on adding code to your templates.
193
+ on adding code to your templates. Obviously you don't have to use all three,
194
+ and order isn't significant - formatting is applied as Textile, then Markdown,
195
+ then Rdoc.
194
196
 
195
197
  *Some additional notes on formatting*
196
198
 
197
- * Although you can directly assign to +format_opts+, this isn't recommended
199
+ * Although you can directly assign to @format_opts@, this isn't recommended
198
200
  since Ruby often interprets it as a local variable set rather than method call,
199
201
  resulting in much head scratching as to why your options are being ignored.
200
202
 
@@ -217,14 +219,14 @@ allow information to be passed into templates. There are four places where
217
219
  you might define such variables. The following is in order of evaluation:
218
220
 
219
221
  * This directory's COMMON.rb, or the parent directory's COMMON.rb if
220
- =inherit_common= is used.
222
+ @inherit_common@ is used.
221
223
  * This page's ruby code, _basename_.rb
222
224
  * In a block passed to Page.new
223
225
  * In the template itself
224
226
 
225
227
  When a =Rote::Page= instance is created, Rote looks for these, and if found
226
228
  evaluates them, in order, in the same binding as the template is later rendered
227
- in (i.e. the =Page= instance binding). Therefore, you can define
229
+ in (i.e. the @Page@ instance binding). Therefore, you can define
228
230
  instance variables to pass data around, or even helper methods if you wish.
229
231
 
230
232
  ["top":#top]
@@ -234,17 +236,17 @@ h4. Layout
234
236
 
235
237
  Layouts are stored under the =doc/layouts= directory (by default). They may
236
238
  be organised into subdirectories, but this hierarchy is not connected to
237
- the hierarchy in =pages=. To apply a layout to a page, simply call the
239
+ the hierarchy in @pages@. To apply a layout to a page, simply call the
238
240
  =Rote::Page.layout= method from code applied to that page, passing the
239
- base-name (and path, relative to =layouts=, if used). If no extension is
241
+ base-name (and path, relative to @layouts@, if used). If no extension is
240
242
  specified, then the same extension as the page itself is assumed. Examples:
241
243
 
242
- <code><pre>
244
+ <pre>
243
245
  layout 'one'
244
246
  layout 'main/wide'
245
247
  layout 'dark.txt'
246
248
  &lt;% layout 'my' %&gt;
247
- </code></pre>
249
+ </pre>
248
250
 
249
251
  With that done, Rote would first render the template text (including textile)
250
252
  and set the Page instance variable =@content_for_layout= before rendering
@@ -252,7 +254,7 @@ the layout (in which textile is currently not supported). The layout is
252
254
  responsible for inserting the rendered template where appropriate, with
253
255
  e.g.:
254
256
 
255
- <code><pre> &lt;%= @content_for_layout %&gt;</code></pre>
257
+ <pre> &lt;%= @content_for_layout %&gt;</pre>
256
258
 
257
259
  This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate
258
260
  HTML, despite the appearance from the ERB tags - any (textual) format can
@@ -265,11 +267,11 @@ h3. Resources
265
267
 
266
268
  Of course, you're likely to have resources for your site (images, sounds, etc)
267
269
  and you'll need to copy them over to the target too. Such resources should be
268
- placed under 'res' (with the commandline setup) or in your specified +res+
270
+ placed under 'res' (with the commandline setup) or in your specified @res@
269
271
  directory, and will be copied directly to the output directory after page
270
272
  rendering.
271
273
 
272
- As you'd expect, the directory layout beneath =res= should mirror that of the
274
+ As you'd expect, the directory layout beneath @res@ should mirror that of the
273
275
  output, and will be preserved during the copy.
274
276
 
275
277
  ["top":#top]
@@ -284,7 +286,7 @@ allows maximum flexibility, and allows Rote to concentrate on creating your
284
286
  documents.
285
287
 
286
288
  The command-line build will automatically look for a file in the top-level
287
- directory (above =doc=) named =publish.rf=. If found, this file will be
289
+ directory (above @doc@) named =publish.rf=. If found, this file will be
288
290
  evaluated by Rake, making any tasks defined within it available to your
289
291
  build. The most likely use case is to define a task that uses an SSH directory
290
292
  publisher to publish via SCP.
@@ -32,28 +32,28 @@ a:visited {
32
32
  text-decoration: none;
33
33
  }
34
34
 
35
- a#nav:link {
35
+ a.nav:link {
36
36
  color: #cc3030;
37
37
  text-decoration: none;
38
38
  font-weight: bold;
39
39
  background: auto;
40
40
  }
41
41
 
42
- a#nav:hover {
42
+ a.nav:hover {
43
43
  color: #df3b3b;
44
44
  text-decoration: underline;
45
45
  font-weight: bold;
46
46
  background: #c3c3c3;
47
47
  }
48
48
 
49
- a#nav:active {
49
+ a.nav:active {
50
50
  color: #df3b3b;
51
51
  text-decoration: underline;
52
52
  font-weight: bold;
53
53
  background: #c3c3c3;
54
54
  }
55
55
 
56
- a#nav:visited {
56
+ a.nav:visited {
57
57
  color: #b02424;
58
58
  text-decoration: none;
59
59
  font-weight: bold;
data/lib/rote.rb CHANGED
@@ -21,14 +21,27 @@
21
21
  #
22
22
  # See Rote for full documentation
23
23
 
24
- require 'net/ftp'
25
- require 'rubygems'
26
- require_gem 'rake'
24
+ # require these before gems, because we want to use them from
25
+ # lib/ , or from normal install, if that's how Rote was started.
26
+ #
27
+ # If rote has been loaded through Gems, this will automatically
28
+ # come from the right lib directory...
27
29
 
28
30
  require 'rote/rotetasks'
31
+ require 'rote/page'
32
+
33
+ # Everything else should come first from Gems, if installed.
34
+ begin
35
+ require 'rubygems'
36
+ rescue LoadError
37
+ nil # just try without then...
38
+ end
39
+
40
+ require 'net/ftp'
41
+ require 'rake'
29
42
 
30
43
  # Master Rote version. Manage this from the Rake release support.
31
- ROTEVERSION = '0.1.6'
44
+ ROTEVERSION = '0.2.0'
32
45
 
33
46
  #####
34
47
  ## *Rote* is a Rake (http://rake.rubyforge.org) based build tool for page-based
@@ -44,43 +57,9 @@ ROTEVERSION = '0.1.6'
44
57
  ## Rake task integration, while +Rote::Page+ has information useful to template
45
58
  ## writers.
46
59
  ##
47
- ## Rote is (c)2005 Ross Bamford, and is licensed under an MIT license.
48
- ## See +LICENSE+ for details.
60
+ ## Rote is (c)2005 Ross Bamford. See +LICENSE+ for details.
49
61
  module Rote
50
62
 
51
- private
52
-
53
- ####################################################
54
- ## WILL BE REMOVED... ##
55
- ## ...I SAID, "WILL BE REMOVED" ##
56
- ####################################################
57
-
58
- def ftp_putdir(dir, ftp_host, ftp_user, ftp_pass = nil, ftp_root = '/')
59
- f = Net::FTP.new(ftp_host, ftp_user, ftp_pass)
60
- f.passive = true
61
-
62
- Dir[dir + '/**/*'].sort.each { |fn|
63
- # pretty f*cking trick - it's replacing the local 'target' or whatever prefix
64
- # with remote root ;)
65
- rfn = fn.dup
66
- rfn[dir] = ftp_root
67
-
68
- if File.directory?(fn)
69
- puts "Creating remote directory #{rfn}"
70
- begin
71
- f.mkdir(rfn)
72
- rescue
73
- # forget it then, already exists prob'ly
74
- # TODO maybe should raise if $! != FTP 550?
75
- end
76
- else
63
+ # this space intentionally left blank
77
64
 
78
- # TODO continue on error perhaps
79
- puts "Uploading #{fn} => #{rfn}"
80
- f.put(fn,rfn)
81
- end
82
- }
83
-
84
- f.close
85
- end
86
65
  end
data/lib/rote/page.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  require 'erb'
2
- require 'rubygems'
2
+ require 'rdoc/markup/simple_markup'
3
+ require 'rdoc/markup/simple_markup/to_html'
3
4
 
4
- require_gem('RedCloth')
5
+ begin
6
+ require 'redcloth'
7
+ rescue LoadError
8
+ # optional dep
9
+ nil
10
+ end
5
11
 
6
12
  module Rote
7
13
 
@@ -15,7 +21,7 @@ module Rote
15
21
  ## and set any instance variables, for use later in the template.
16
22
  ##
17
23
  ## Rendering happens only once for a given page object, when the
18
- ## to_html method is first called. Once a page has been rendered
24
+ ## +render+ method is first called. Once a page has been rendered
19
25
  ## it is frozen.
20
26
  class Page
21
27
  # The text of the template to use for this page.
@@ -120,19 +126,53 @@ module Rote
120
126
  end
121
127
  end
122
128
 
129
+ def render_fmt(text)
130
+ result = text
131
+
132
+ # need to get opts to a known state (array), and copy it
133
+ # so we can modify it.
134
+ if @format_opts && ((@format_opts.respond_to?(:to_ary) && (!@format_opts.empty?)) || @format_opts.is_a?(Symbol))
135
+ opts = @format_opts.respond_to?(:to_ary) ? @format_opts.dup : [@format_opts]
136
+
137
+ # Remove :rdoc opts from array (RedCloth doesn't do 'em)
138
+ # and remember for after first rendering...
139
+ #
140
+ # Cope with multiple occurences of :rdoc
141
+ unless (rdoc_opt = opts.grep(:rdoc)).empty?
142
+ opts -= rdoc_opt
143
+ end
144
+
145
+ # Render out RedCloth / markdown
146
+ unless opts.empty?
147
+ if defined?(RedCloth)
148
+ rc = RedCloth.new(result)
149
+ rc.instance_eval { @lite_mode = false } # hack around a warning
150
+ result = rc.to_html(*opts)
151
+ else
152
+ puts "WARN: RedCloth options specified but no RedCloth installed"
153
+ end
154
+ end
155
+
156
+ # Render out Rdoc
157
+ #
158
+ # TODO could support alternative output formats by having the user supply
159
+ # the formatter class (ToHtml etc).
160
+ unless rdoc_opt.empty?
161
+ p = SM::SimpleMarkup.new
162
+ h = SM::ToHtml.new
163
+ result = p.convert(result, h)
164
+ end
165
+ end
166
+
167
+ result
168
+ end
169
+
170
+
123
171
  # render, set up @result for next time. Return result too.
124
172
  def do_render!
125
173
  # Render the page content into the @content_for_layout
126
- if !@template_text.nil?
127
- ctl = ERB.new(@template_text).result(binding)
128
-
129
- @content_for_layout =
130
- if @format_opts && ((@format_opts.respond_to?(:to_ary) && (!@format_opts.empty?)) || @format_opts.is_a?(Symbol))
131
- opts = @format_opts.respond_to?(:to_ary) ? @format_opts : [@format_opts]
132
- RedCloth.new(ctl).to_html(*opts)
133
- else
134
- ctl
135
- end
174
+ unless @template_text.nil?
175
+ @content_for_layout = render_fmt( ERB.new(@template_text).result(binding) )
136
176
  end
137
177
 
138
178
  # render into the layout if supplied.
@@ -143,6 +183,7 @@ module Rote
143
183
  end
144
184
 
145
185
  freeze
186
+
146
187
  @result
147
188
  end
148
189
 
@@ -2,10 +2,53 @@ require 'rake'
2
2
  require 'rake/tasklib'
3
3
 
4
4
  require 'rote/page'
5
- require 'rote/dirfilelist'
6
5
 
7
6
  module Rote
8
7
 
8
+ # Just a temporary holder for a set of patterns that are used
9
+ # to construct a relative +FileList+ for pages and resources.
10
+ class FilePatterns
11
+ def initialize(basedir = '.')
12
+ @dir = basedir
13
+ @includes, @excludes = [], []
14
+ end
15
+
16
+ # Access the pattern arrays
17
+ attr_reader :includes
18
+ attr_reader :excludes
19
+
20
+ # Access the base dir for these patterns
21
+ attr_accessor :dir
22
+
23
+ # Specify glob patterns to include
24
+ def include(*patterns)
25
+ patterns.each { |it|
26
+ @includes << it
27
+ }
28
+ end
29
+
30
+ # Specify glob patterns or regexps to exclude
31
+ def exclude(*patterns)
32
+ patterns.each { |it|
33
+ @excludes << it
34
+ }
35
+ end
36
+
37
+ # Create a +FileList+ with these patterns
38
+ def to_filelist
39
+ fl = FileList.new
40
+ fl.include(*includes.map { |it| "#{dir}/#{it}"} ) unless includes.empty?
41
+
42
+ # excludes may be regexp too
43
+ fl.exclude(*excludes.map { |it| it.is_a?(String) ? "#{dir}/#{it}" : it } ) unless excludes.empty?
44
+
45
+ # don't allow dir to be changed anymore.
46
+ freeze
47
+
48
+ fl
49
+ end
50
+ end
51
+
9
52
  #####
10
53
  ## Rake task library that provides a set of tasks to transform documentation
11
54
  ## using Rote. To use, create a new instance of this class in your Rakefile,
@@ -26,20 +69,19 @@ module Rote
26
69
  # instantiation.
27
70
  attr_reader :name
28
71
 
29
- # The directory in which output will be placed.
30
- attr_accessor :output_dir
72
+ # Base directories used by the task.
73
+ attr_accessor :output_dir, :layout_dir
31
74
 
32
- # The base directory within which layouts requested by pages will be
33
- # resolved.
34
- attr_accessor :layout_dir
35
-
36
- # A DirectoryFileList that supplies the pages to transform. You should
37
- # configure the +dir+ and at least one +include+ entry in the
38
- # configuration block.
75
+ # Globs for the +FileList+ that supplies the pages to transform. You
76
+ # should configure the +pages_dir+ and +include+ at least one entry
77
+ # here. (you may add +exclude+ strings or regexps, too).
78
+ # Patterns added are made relative to the +pages_dir+ and
79
+ # added to a FileList once init is complete.
39
80
  attr_reader :pages
40
81
 
41
- # A DirectoryFileList that supplies the resources to copy to the
42
- # output directory.
82
+ # Globs for the +FileList+ that supplies the resources to copy. You
83
+ # should configure the +layout_dir+ and +include+ at least one entry
84
+ # here (you may add +exclude+ strings or regexps, too).
43
85
  attr_reader :res
44
86
 
45
87
  # If +show_page_tasks+ is +true+, then the file tasks created for each
@@ -52,16 +94,14 @@ module Rote
52
94
  def initialize(name = :site) # :yield: self if block_given?
53
95
  @name = name
54
96
  @output_dir = '.'
55
- @layout_dir = '.' # layouts are looked up as needed
56
-
57
- @pages = DirectoryFileList.new
58
- @res = DirectoryFileList.new
97
+ @pages = FilePatterns.new('.')
98
+ @res = FilePatterns.new('.')
59
99
  DEFAULT_SRC_EXCLUDES.each { |excl| @pages.exclude(excl) }
60
100
 
61
101
  @show_page_tasks = false
62
102
 
63
103
  yield self if block_given?
64
-
104
+
65
105
  define
66
106
  end
67
107
 
@@ -75,9 +115,11 @@ module Rote
75
115
  end
76
116
 
77
117
  def define_res_tasks
118
+ res_fl = res.to_filelist
119
+
78
120
  desc "Copy documentation resources"
79
121
  task "#{name}-res" do
80
- res.each { |fn|
122
+ res_fl.each { |fn|
81
123
  unless File.directory?(fn) # make dirs only as needed
82
124
  tfn = fn.sub(/#{res.dir}/, output_dir)
83
125
  dn = File.dirname(tfn)
@@ -89,13 +131,15 @@ module Rote
89
131
  end
90
132
 
91
133
  def define_page_tasks
134
+ # make file list
135
+ pages_fl = pages.to_filelist
92
136
 
93
137
  # define a task for each page
94
138
  realpages = FileList[]
95
- pages.each { |fn|
139
+ pages_fl.each { |fn|
96
140
  unless File.directory?(fn) # make dirs only as needed
97
141
  realpages << fn
98
- tfn = fn.sub(/#{pages.dir}/, output_dir)
142
+ tfn = fn.sub(/^#{pages.dir}/, output_dir)
99
143
 
100
144
  desc "#{fn} => #{tfn}" if show_page_tasks?
101
145
  file tfn => [fn] do
data/test/gem_tests.rb ADDED
@@ -0,0 +1,2 @@
1
+ TEST_FROM_GEM = true
2
+ require File.join(File.dirname(__FILE__), 'test_page.rb')
@@ -0,0 +1,3 @@
1
+ <% format_opts << :rdoc %>
2
+ == RDoc
3
+ === Markup
data/test/test_page.rb CHANGED
@@ -1,3 +1,9 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ nil
5
+ end
6
+
1
7
  require 'test/unit'
2
8
  require 'rote/page'
3
9
 
@@ -27,6 +33,7 @@ module Rote
27
33
 
28
34
  def test_initialize_ok
29
35
  new_test_page('justtext')
36
+ assert true
30
37
  end
31
38
 
32
39
  ############## accessors #################
@@ -80,7 +87,6 @@ module Rote
80
87
  p.format_opts = :textile
81
88
  # should create array for one sim
82
89
  assert_equal [:textile], p.format_opts
83
-
84
90
  end
85
91
 
86
92
  ############## render #################
@@ -93,6 +99,18 @@ module Rote
93
99
  t = new_test_page('textile').render.chomp
94
100
  assert_equal '<p><strong>This</strong> is a <em>simple</em> test of <a href="http://www.textism.org/tools/textile">Textile</a> formatting.</p>', t
95
101
  end
102
+
103
+ # FIXME Fails under Gem install, but passes when run normally (???)
104
+ unless defined?(TEST_FROM_GEM)
105
+ def test_render_rdoc
106
+ begin
107
+ t = new_test_page('rdoc').render.chomp
108
+ assert_equal "<h2>RDoc</h2>\n<h3>Markup</h3>", t
109
+ rescue Object => ex
110
+ p ex
111
+ end
112
+ end
113
+ end
96
114
 
97
115
  def test_render_markdown
98
116
  t = new_test_page('markdown').render.chomp
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.1.6
7
- date: 2005-11-28 00:00:00 +00:00
6
+ version: 0.2.0
7
+ date: 2005-12-01 00:00:00 +00:00
8
8
  summary: Adds template-based doc support to Rake.
9
9
  require_paths:
10
10
  - lib
@@ -38,14 +38,15 @@ files:
38
38
  - lib/rote/rotetasks.rb
39
39
  - lib/rote/page.rb
40
40
  - lib/rote/app.rb
41
- - lib/rote/dirfilelist.rb
42
41
  - lib/rote/builtin.rf
43
42
  - test/test_page.rb
44
43
  - test/pages
45
44
  - test/layouts
45
+ - test/gem_tests.rb
46
46
  - test/pages/samedir.txt
47
47
  - test/pages/baselayout.txt
48
48
  - test/pages/markdown.txt
49
+ - test/pages/rdoc.txt
49
50
  - test/pages/badlayout.rb
50
51
  - test/pages/samedir.rb
51
52
  - test/pages/COMMON.rb
@@ -86,8 +87,8 @@ files:
86
87
  - doc/pages/guide/index.html
87
88
  - doc/man/rote.1.gz
88
89
  - doc/layouts/page.html
89
- test_files: []
90
-
90
+ test_files:
91
+ - test/gem_tests.rb
91
92
  rdoc_options:
92
93
  - --title
93
94
  - Rote -- Template-based doc support for Rake
@@ -1,46 +0,0 @@
1
- module Rote
2
-
3
-
4
- # TODO untested
5
-
6
-
7
- # An extension to the Rake +FileList+ class that allows a root
8
- # directory to be specified.
9
- class DirectoryFileList < FileList
10
-
11
- # Create a +DirectoryFileList+ with optional root directory and
12
- # patterns. You may also pass a block to perform additional
13
- # configuration (e.g. if you have a lot of includes/excludes
14
- # or just don't like arguments for whatever reason).
15
- def initialize(basedir = '.', *patterns)
16
- super(*patterns)
17
- self.dir = basedir
18
- end
19
-
20
- # The root directory from which this filelist matches. All patterns
21
- # are considered relative to this directory.
22
- attr_reader :dir
23
- def dir=(newdir)
24
- newdir = newdir.sub(/\/$/,'')
25
- self.sub!(/^#{@dir}/,newdir) unless self.empty?
26
- @dir = newdir
27
- end
28
-
29
- # Adds the specified *shell glob* pattern(s) to the list of includes
30
- # for this file list. The base directory is implied.
31
- def include(*patterns)
32
- super(*patterns.map { |it| "#{dir}/#{it}"})
33
- end
34
-
35
- # Adds the specified *regexp or shell glob* pattern(s) to the list of
36
- # excludes for this file list. The base directory is implied on
37
- # non-+Regexp+.arguments.
38
- def exclude(*patterns)
39
- # exclude takes regexps too, which we should leave alone.
40
- super(*patterns.map { |it|
41
- it.is_a?(String) ? "#{dir}/#{it}" : it
42
- })
43
- end
44
- end
45
-
46
- end