rote 0.2.4.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -147,3 +147,66 @@ h3 {
147
147
  h4 {
148
148
  border-bottom: thin #b8c8c8 solid;
149
149
  }
150
+
151
+ /* syntax */
152
+ pre.ruby {
153
+ background: #f5f5f5;
154
+ border: thin dashed #3e5972;
155
+ padding: 10px;
156
+ margin-left: 2em;
157
+ }
158
+
159
+ pre.ruby span.comment {
160
+ color: #789a86;
161
+ text-decoration: oblique;
162
+ }
163
+
164
+ pre.ruby span.ident {
165
+ color: #0b0202;
166
+ }
167
+
168
+ pre.ruby span.punct {
169
+ color: #8a7070;
170
+ }
171
+
172
+ pre.ruby span.symbol {
173
+ color: #aa1010;
174
+ font-weight: bold;
175
+ }
176
+
177
+ pre.ruby span.keyword {
178
+ color: #903030;
179
+ font-weight: bold;
180
+ }
181
+
182
+ pre.ruby span.constant {
183
+ color: #3e5972;
184
+ font-weight: bold;
185
+ }
186
+
187
+ pre.ruby span.string {
188
+ color: #2020f0;
189
+ }
190
+
191
+ pre.ruby span.regex {
192
+ color: #552090;
193
+ }
194
+
195
+ pre.ruby span.expr {
196
+ color: #101080;
197
+ font-weight: bold;
198
+ }
199
+
200
+ pre.ruby span.global {
201
+ color: #557462;
202
+ }
203
+
204
+ pre.ruby span.class {
205
+ color: #3e5972;
206
+ font-weight: bold;
207
+ }
208
+
209
+ pre.ruby span.method {
210
+ color: #aa1010;
211
+ }
212
+
data/lib/rote.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # rote.rb - main Rote module
2
2
  # Copyright (c) 2005 Ross Bamford (and contributors)
3
- # $Id: rote.rb,v 1.18.2.1 2005/12/07 16:22:21 roscopeco Exp $
3
+ # $Id: rote.rb,v 1.21 2005/12/12 02:47:47 roscopeco Exp $
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  # this software and associated documentation files (the "Software"), to deal in
@@ -38,11 +38,10 @@ rescue LoadError
38
38
  nil # just try without then...
39
39
  end
40
40
 
41
- require 'net/ftp'
42
41
  require 'rake'
43
42
 
44
43
  # Master Rote version. Manage this from the Rake release support.
45
- ROTEVERSION = '0.2.4.1'
44
+ ROTEVERSION = '0.3.0'
46
45
 
47
46
  #####
48
47
  ## *Rote* is a Rake (http://rake.rubyforge.org) based build tool for static
data/lib/rote/app.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # (c)2005 Ross Bamford (and contributors)
3
3
  #
4
4
  # See 'rote.rb' or LICENSE for licence information.
5
- # $Id: app.rb,v 1.4.4.1 2005/12/07 16:21:39 roscopeco Exp $
5
+ # $Id: app.rb,v 1.6 2005/12/12 02:45:24 roscopeco Exp $
6
6
  require 'getoptlong'
7
7
 
8
8
  module Rote
data/lib/rote/builtin.rf CHANGED
@@ -14,35 +14,8 @@ require 'rake'
14
14
  require 'rake/clean'
15
15
  require 'rote'
16
16
 
17
- # Create a set of tasks with the prefix 'doc' to build the
18
- # documentation set. The directory layout is as for the
19
- # command-line wrapper (but can be changed of course).
20
- #
21
- # This creates the following tasks:
22
- #
23
- # * doc - transform/copy all modified pages / resources
24
- # * doc_pages - transform all modified pages
25
- # * doc_res - copy all modified resources
26
- # * doc_monitor - Start monitor mode, transform changed files automatically
27
- #
28
- # * [html/**/*] - Transform single page / resource unconditionally
29
- #
30
- # * clobber_doc - Remove output (hooks into main 'clobber' task)
31
- #
32
- # In addition to these tasks, you may also wish to define a 'doc_refresh' task
33
- # to be run whenever modified resources are processed in monitor mode.
34
- ws = Rote::DocTask.new(:doc) { |site|
35
- site.output_dir = 'html'
36
- site.layout_dir = 'doc/layouts'
37
-
38
- site.pages.dir = 'doc/pages'
39
- site.pages.include('**/*')
40
-
41
- site.res.dir = 'doc/res'
42
- site.res.include('**/*')
43
- }
44
-
45
- task :default => [:doc]
17
+ # Import the standard doc task
18
+ import File.join(File.dirname(__FILE__),('/project/Rakefile'))
46
19
 
47
20
  #################### CREATE NEW PROJECT FROM TEMPLATE ###############
48
21
  #
@@ -59,6 +32,7 @@ task :default => [:doc]
59
32
  #
60
33
  # Also need a way to display error message if the rule isn't
61
34
  # invoked at least once...
35
+ desc "Bootstrap a new documentation project"
62
36
  task :create do
63
37
  rule '' do |t|
64
38
  fail "'#{t.name}' already exists" if File.exists?(t.name)
@@ -73,10 +47,6 @@ task :create do
73
47
  end
74
48
  end
75
49
 
76
- # import user-level tasks
77
- import "#{ENV['HOME']}/.rotetasks.rf" if File.exists?("#{ENV['HOME']}/.rotetasks.rf")
78
- import 'local.rf' if File.exists?('local.rf')
79
-
80
50
  # DEPRECATED - publish.rf will be unsupported. vv0.2.3 v-0.5 1
81
51
  import 'publish.rf' if File.exists?('publish.rf')
82
52
 
@@ -0,0 +1,10 @@
1
+ #--
2
+ # Require all filters
3
+ # (c)2005 Ross Bamford (and contributors)
4
+ #
5
+ # See 'rote.rb' or LICENSE for licence information.
6
+ # $Id: filters.rb,v 1.2 2005/12/12 02:45:24 roscopeco Exp $
7
+ #++
8
+
9
+ # will require 'base' but it'd get required anyway...
10
+ Dir[File.join(File.dirname(__FILE__), 'filters/*.rb')].each { |f| require f }
@@ -0,0 +1,135 @@
1
+ #--
2
+ # Baseclass for Rote filters
3
+ # (c)2005 Ross Bamford (and contributors)
4
+ #
5
+ # See 'rote.rb' or LICENSE for licence information.
6
+ # $Id: base.rb,v 1.2 2005/12/12 02:45:24 roscopeco Exp $
7
+ #++
8
+ module Rote
9
+ module Filters
10
+
11
+ # Match/extract
12
+ #
13
+ # #:code#args#
14
+ # ... body ...
15
+ # #code#
16
+ #
17
+ # to :code, args, body
18
+ MACRO_RE = /^\s*\#\:([a-z]+)(?:\#([a-z]*))?\#\s*^(.*?)$\s*\#\:\1\#(?:\2\#)?\s*$/m
19
+
20
+ #####
21
+ ## Baseclass from which Rote filters can be derived if
22
+ ## they want to process text without macros. This class
23
+ ## replaces macro tags/bodies with simple placeholders,
24
+ ## containing only characters [a-z0-9] before passing
25
+ ## it the text to the block. On return, macro markers
26
+ ## are replaced with the corresponding (numbered) original
27
+ ## macro body.
28
+ class TextFilter
29
+ attr_accessor :handler_blk, :macro_data
30
+
31
+ # Create a new TextFilter. The supplied block will be called
32
+ # with the text to be rendered, with all macros replaced
33
+ # by plain-text macro markers:
34
+ #
35
+ # { |text, page| "replacement" }
36
+ def initialize(&handler)
37
+ @handler_blk = handler
38
+ @macro_data = []
39
+ end
40
+
41
+ def filter(text, page)
42
+ # we need to remove any macros to stop them being touched
43
+ n = -1
44
+ tmp = text.gsub(MACRO_RE) do
45
+ macro_data << $&
46
+ # we need make the marker a 'paragraph'
47
+ "\nxmxmxmacro#{n += 1}orcamxmxmx\n"
48
+ end
49
+
50
+ tmp = handler(tmp,page)
51
+
52
+ # Match the placeholder, including any (and greedily all) markup that's
53
+ # been placed before or after it, and put the macro text back.
54
+ tmp.gsub(/(?:<.*>)?xmxmxmacro(\d+)orcamxmxmx(?:<.*>)?/) { @macro_data[$1.to_i] }
55
+ end
56
+
57
+ protected
58
+
59
+ # Calls the handler block. Subclasses may override this rather
60
+ # than use a block.
61
+ def handler(tmp,page)
62
+ handler_blk[tmp,page] if handler_blk
63
+ end
64
+ end
65
+
66
+ #####
67
+ ## Baseclass from which Rote filters can be derived if
68
+ ## you want some help with macro replacement.
69
+ class MacroFilter
70
+
71
+ # An array of macro names supported by this filter.
72
+ # This can be used to selectively disable individual
73
+ # macro support.
74
+ attr_accessor :macros
75
+
76
+ # Block that will be called for each supported macro
77
+ # in the filtered text. Like:
78
+ #
79
+ # { |macro, args, body| "replacement" }
80
+ #
81
+ # The presence of a block precludes the use of any
82
+ # +macro_xxxx+ methods on the subclass.
83
+ attr_accessor :handler_blk
84
+
85
+ # Create a new macro filter. If a three-arg block is passed,
86
+ # it will be called for each macro with a name that exists
87
+ # in the +macros+ array. Otherwise, macros will be sought
88
+ # as methods (e.g. +macro_code+). If an array of names isn't
89
+ # passed, a search such methods will be used to populate
90
+ # the names array.
91
+ def initialize(macros = nil, code_re = MACRO_RE, &handler_blk)
92
+ @handler_blk = handler_blk
93
+ @macros = macros || reflect_macro_names
94
+ @code_re = code_re
95
+ end
96
+
97
+ def filter(text,page)
98
+ # Just go through, subbing with block if this is
99
+ # our macro, or with the original match if not.
100
+ text.gsub(@code_re) do
101
+ if macros.detect { |it| it.to_s == $1 }
102
+ # Handler might refuse the macro (bad args, etc)
103
+ handler($1,$2,$3) || $&
104
+ else
105
+ $&
106
+ end
107
+ end
108
+ end
109
+
110
+ protected
111
+
112
+ # Calls the handler block, or attempts to call a method named
113
+ # 'macro_XXXX' where 'XXXX' is the name of the macro.
114
+ # Macro methods take two arguments -args and body.
115
+ # Name is implied by method that is invoked.
116
+ def handler(macro,args,body)
117
+ if handler_blk
118
+ handler_blk[macro,args,body]
119
+ elsif respond_to?(meth = "macro_#{macro}")
120
+ send(meth, args, body) # name implied by method
121
+ end
122
+ end
123
+
124
+ private
125
+
126
+ # inits the macro array from defined 'macro_' methods if no array is passed.
127
+ def reflect_macro_names
128
+ [methods, private_methods, singleton_methods, protected_methods].inject([]) do |arr,m|
129
+ arr += m.grep(/macro_([a-z0-9]+)/) { $1 }
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
135
+
@@ -0,0 +1,25 @@
1
+ #--
2
+ # Rote page class
3
+ # (c)2005 Ross Bamford (and contributors)
4
+ #
5
+ # See 'rote.rb' or LICENSE for licence information.
6
+ # $Id: rdoc.rb,v 1.2 2005/12/12 02:45:24 roscopeco Exp $
7
+ #++
8
+
9
+ require 'rdoc/markup/simple_markup'
10
+ require 'rdoc/markup/simple_markup/to_html'
11
+
12
+ module Rote
13
+ module Filters
14
+
15
+ #####
16
+ ## Page filter supporting RDoc markup.
17
+ class RDoc < TextFilter
18
+ def initialize(markup = SM::SimpleMarkup.new, output = SM::ToHtml.new)
19
+ @markup = markup
20
+ @output = output
21
+ self.handler_blk = proc { |text,page| @markup.convert(text, @output) }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,40 @@
1
+ #--
2
+ # Rote filter for RedCloth
3
+ # (c)2005 Ross Bamford (and contributors)
4
+ #
5
+ # See 'rote.rb' or LICENSE for licence information.
6
+ # $Id: redcloth.rb,v 1.2 2005/12/12 02:45:24 roscopeco Exp $
7
+ #++
8
+
9
+ require 'redcloth'
10
+ require 'rote/filters/base'
11
+
12
+ module Rote
13
+ module Filters
14
+ #####
15
+ ## Page filter that converts plain-text formatting to HTML using
16
+ ## RedCloth. This allows both Textile and Markdown formatting
17
+ ## to be used with any page.
18
+ class RedCloth < TextFilter
19
+
20
+ # Create a new filter instance. The supplied options are passed
21
+ # directly to RedCloth. The most common are :textile and
22
+ # :markdown - See RedCloth docs for a full list.
23
+ #
24
+ # If no options are supplied, :textile is assumed.
25
+ def initialize(*redcloth_opts)
26
+ super()
27
+ @redcloth_opts = redcloth_opts
28
+ raise "RedCloth is not available" unless defined?(RedCloth)
29
+ end
30
+
31
+ def handler(text,page)
32
+ rc = ::RedCloth.new(text)
33
+ # hack around a RedCloth warning
34
+ rc.instance_eval { @lite_mode = false }
35
+ rc.to_html(*@redcloth_opts)
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,38 @@
1
+ #--
2
+ # Rote filter with syntax highlighting
3
+ # (c)2005 Ross Bamford (and contributors)
4
+ #
5
+ # See 'rote.rb' or LICENSE for licence information.
6
+ # $Id: syntax.rb,v 1.2 2005/12/12 02:45:24 roscopeco Exp $
7
+ #++
8
+
9
+ require 'syntax'
10
+ require 'syntax/convertors/html'
11
+ require 'rote/filters/base'
12
+
13
+ module Rote
14
+ module Filters
15
+
16
+ #####
17
+ ## Page filter that supports syntax highlighting for Ruby code
18
+ ## via the +Syntax+ library. Code is expected to be in the
19
+ ## following format:
20
+ ##
21
+ ## #:code#ruby#
22
+ ## def amethod(arg)
23
+ ## puts arg
24
+ ## end
25
+ ## #:code#
26
+ ##
27
+ class Syntax < MacroFilter
28
+ def initialize(macro_re = MACRO_RE)
29
+ super([:code],macro_re)
30
+ end
31
+
32
+ def macro_code(lang,body)
33
+ converter = ::Syntax::Convertors::HTML.for_syntax(lang)
34
+ "<pre class='#{lang}'><code>#{converter.convert(body,false)}</code></pre>"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,55 @@
1
+ #--
2
+ # Rote filter for HTML Tidy
3
+ # (c)2005 Ross Bamford (and contributors)
4
+ #
5
+ # See 'rote.rb' or LICENSE for licence information.
6
+ # $Id: tidy.rb,v 1.2 2005/12/12 02:45:24 roscopeco Exp $
7
+ #++
8
+
9
+ module Rote
10
+ module Filters
11
+
12
+ #####
13
+ ## Post filter that runs HTML Tidy on the laid-out page to correct and
14
+ ## clean up HTML in the output. This filter can be used with any of
15
+ ## the _asXXXX_ formats supported by Tidy.
16
+ ##
17
+ ## Note that this filter requires the 'tidy' command, and should be
18
+ ## added to the +post_filters+ array, in contrast to most of the
19
+ ## other filters which are page filters.
20
+ ##
21
+ ## If 'tidy' isn't in your path you'll need to specify it here or
22
+ ## via a TIDYCMD environment variable.
23
+ class Tidy
24
+
25
+ # Create a new filter instance, using the specified output format,
26
+ # and optionally a custom 'tidy' command and options.
27
+ def initialize(format = :xhtml, tidycmd = nil, tidyopts = '-q')
28
+ @tidycmd = tidycmd || ENV['TIDYCMD'] || (PLATFORM =~ /mswin/ ? 'tidy.exe' : 'tidy')
29
+ # TODO windows 'tidy.exe' correct?
30
+
31
+ @tidyopts = tidyopts
32
+ @format = format
33
+ end
34
+
35
+ attr_accessor :format, :tidyopts, :tidycmd
36
+
37
+ def filter(text, page)
38
+ # TODO need to properly capture and log warnings here
39
+ result = IO.popen("#{@tidycmd} #{self.tidyopts} -f tidy.log -as#{self.format}","r+") do |fp|
40
+ Thread.new { fp.write(text); fp.close_write }
41
+ fp.read
42
+ end
43
+
44
+ if $?.exitstatus < 2
45
+ result
46
+ else
47
+ warn 'Tidy command failed (exitstatus: $?)'
48
+ text
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+