class Packnga::YARDTask
This class creates YARD task. YARD task generates references by YARD.
@since 0.9.0
Attributes
base_dir[RW]
This attribute is used to set path of base directory of document. @return [String] path of base directory of document
options[RW]
@return [Array<String>] custom yardoc command line options
readme[RW]
This attribute is used to set README file to yardoc task. @return [String] path of readme file
source_files[RW]
This attribute is used to set source files for document. @return [Array<String>] target source files
text_files[RW]
This attribute is used to set text files for document. @return [Array<String>] target text files
Public Class Methods
new(spec)
click to toggle source
@private
# File lib/packnga/yard-task.rb, line 48 def initialize(spec) @spec = spec @hooks = [] @readme = nil @text_files = nil @base_dir = nil @options = [] @source_files = nil end
Public Instance Methods
before_define(&hook)
click to toggle source
Regists yardoc parameters with block.
# File lib/packnga/yard-task.rb, line 70 def before_define(&hook) @hooks << hook end
define()
click to toggle source
@private
# File lib/packnga/yard-task.rb, line 64 def define set_default_values define_tasks end
Private Instance Methods
define_tasks()
click to toggle source
# File lib/packnga/yard-task.rb, line 88 def define_tasks define_yardoc_task define_yard_task end
define_yard_task()
click to toggle source
# File lib/packnga/yard-task.rb, line 111 def define_yard_task task :yard do |yard_task| reference_en_dir.find do |path| next if path.extname != ".html" html = path.read html = html.gsub(/<div id="footer">.+<\/div>/m, "<div id=\"footer\"></div>") path.open("w") do |html_file| html_file.print(html) end end end end
define_yardoc_task()
click to toggle source
# File lib/packnga/yard-task.rb, line 93 def define_yardoc_task YARD::Rake::YardocTask.new do |yardoc_task| yardoc_task.options += ["--title", @spec.name] yardoc_task.options += ["--readme", readme] if readme @text_files.each do |file| yardoc_task.options += ["--files", file] end yardoc_task.options += ["--output-dir", reference_en_dir.to_s] yardoc_task.options += ["--charset", "utf-8"] yardoc_task.options += ["--no-private"] yardoc_task.options += @options yardoc_task.files += @source_files @hooks.each do |hook| hook.call(yardoc_task) end end end
reference_dir()
click to toggle source
# File lib/packnga/yard-task.rb, line 80 def reference_dir @base_dir + "reference" end
reference_en_dir()
click to toggle source
# File lib/packnga/yard-task.rb, line 84 def reference_en_dir reference_dir + "en" end
set_default_values()
click to toggle source
# File lib/packnga/yard-task.rb, line 75 def set_default_values @base_dir ||= "doc" @base_dir = Pathname.new(@base_dir) end