Class: Rote::DocTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Rote::DocTask
- Defined in:
- lib/rote/rotetasks.rb
Overview
Rake task library that provides a set of tasks to transform documentation using Rote. To use, create a new instance of this class in your Rakefile, performing appropriate configuration in a block supplied to new
. This will automatically register a set of tasks with names based on the name you supply. The tasks defined are:
#{name} - Transform all documentation, copy resources.
#{name}_pages - Transform all pages
#{name}_res - Copy resources
#{name}_monitor - Start watching for changes
#clobber_{name} - Remove output
Constant Summary collapse
- DEFAULT_SRC_EXCLUDES =
Default exclusion patterns for the page sources. These are applied along with the defaults from
FileList
. [ /\.rb$/, /\.rf$/ ]
Instance Attribute Summary collapse
-
#ext_mappings ⇒ Object
readonly
Ordered
ExtHash
that supplies mappings between input and output file extensions. -
#layout_dir ⇒ Object
Base directories used by the task.
-
#monitor_interval ⇒ Object
The approximate number of seconds between update checks when running monitor mode (Default: 1).
-
#name ⇒ Object
readonly
The base-name for tasks created by this instance, supplied at instantiation.
-
#output_dir ⇒ Object
Base directories used by the task.
-
#pages ⇒ Object
readonly
Globs for the
FileList
that supplies the pages to transform. -
#res ⇒ Object
readonly
Globs for the
FileList
that supplies the resources to copy. -
#show_file_tasks ⇒ Object
(also: #show_file_tasks?, #show_page_tasks?)
If
show_page_tasks
istrue
, then the file tasks created for each output file will be shown in the Rake task listing from the command line.
Instance Method Summary collapse
-
#ext_mapping(match, extension, &block) ⇒ Object
Define an extension mapping for the specified regex, which will be replaced with the specified extension.
-
#initialize(name = :doc) {|_self| ... } ⇒ DocTask
constructor
Create a new DocTask, using the supplied block for configuration, and define tasks with the specified base-name within Rake.
Constructor Details
#initialize(name = :doc) {|_self| ... } ⇒ DocTask
Create a new DocTask, using the supplied block for configuration, and define tasks with the specified base-name within Rake.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/rote/rotetasks.rb', line 181 def initialize(name = :doc) # :yield: self if block_given? @name = name @output_dir = '.' @pages = FilePatterns.new('.') @res = FilePatterns.new('.') @monitor_interval = 1 @ext_mappings = ExtHash.new @show_page_tasks = false DEFAULT_SRC_EXCLUDES.each { |excl| @pages.exclude(excl) } yield self if block_given? define end |
Instance Attribute Details
#ext_mappings ⇒ Object (readonly)
Ordered ExtHash
that supplies mappings between input and output file extensions. Keys are regexps that are matched in order against the search key.
The values are [extension, ({ |page| …})] . If a mapping has a block, it is executed when pages with a matching extension are, instantiated (before common and page code). It can be used to apply filters, for example, on a per-extension basis.
156 157 158 |
# File 'lib/rote/rotetasks.rb', line 156 def ext_mappings @ext_mappings end |
#layout_dir ⇒ Object
Base directories used by the task.
130 131 132 |
# File 'lib/rote/rotetasks.rb', line 130 def layout_dir @layout_dir end |
#monitor_interval ⇒ Object
The approximate number of seconds between update checks when running monitor mode (Default: 1)
177 178 179 |
# File 'lib/rote/rotetasks.rb', line 177 def monitor_interval @monitor_interval end |
#name ⇒ Object (readonly)
The base-name for tasks created by this instance, supplied at instantiation.
127 128 129 |
# File 'lib/rote/rotetasks.rb', line 127 def name @name end |
#output_dir ⇒ Object
Base directories used by the task.
130 131 132 |
# File 'lib/rote/rotetasks.rb', line 130 def output_dir @output_dir end |
#pages ⇒ Object (readonly)
Globs for the FileList
that supplies the pages to transform. You should configure the pages_dir
and include
at least one entry here. (you may add exclude
strings or regexps, too). Patterns added are made relative to the pages_dir
and added to a FileList once init is complete.
137 138 139 |
# File 'lib/rote/rotetasks.rb', line 137 def pages @pages end |
#res ⇒ Object (readonly)
Globs for the FileList
that supplies the resources to copy. You should configure the layout_dir
and include
at least one entry here (you may add exclude
strings or regexps, too).
This is not a FileList
- the patterns supplied to this are used with the base-directory specified to construct an appropriate FileList
.
146 147 148 |
# File 'lib/rote/rotetasks.rb', line 146 def res @res end |
#show_file_tasks ⇒ Object Also known as: show_file_tasks?, show_page_tasks?
If show_page_tasks
is true
, then the file tasks created for each output file will be shown in the Rake task listing from the command line.
167 168 169 |
# File 'lib/rote/rotetasks.rb', line 167 def show_file_tasks @show_file_tasks end |
Instance Method Details
#ext_mapping(match, extension, &block) ⇒ Object
Define an extension mapping for the specified regex, which will be replaced with the specified extension. If a block is supplied it will be called with each matching Page
as it’s created.
161 162 163 |
# File 'lib/rote/rotetasks.rb', line 161 def ext_mapping(match, extension, &block) @ext_mappings[match] = [extension,block] end |