Module: Hoe::Yard

Defined in:
lib/hoe/yard.rb

Overview

YARD plugin for hoe.

Tasks Provided:

  • yard: Generate YARD documentation
  • docs: Generate YARD documentation

Constant Summary collapse

PLUGIN_VERSION =

hoe-yard version

'0.1.3'
YARD_MARKUP =

Supported markups

[:markdown, :texttile, :rdoc, :asciidoc]
YARD_RAW_EXTS =

File extensions indicating raw content

['.txt', '.html']
YARD_EXTS =

File extensions for various markups

{
  :markdown => ['.markdown', '.md'],
  :texttile => ['.texttile', '.tt'],
  :rdoc => ['.rdoc'],
  :asciidoc => ['.adoc']
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#yard_markupObject

Markup style used in documentation, like textile, markdown or rdoc. (default: :rdoc)



36
37
38
# File 'lib/hoe/yard.rb', line 36

def yard_markup
  @yard_markup
end

#yard_markup_providerObject

Overrides the library used to process markup formatting (specify the gem name)



40
41
42
# File 'lib/hoe/yard.rb', line 40

def yard_markup_provider
  @yard_markup_provider
end

#yard_optionsObject

Options to pass to YARD



43
44
45
# File 'lib/hoe/yard.rb', line 43

def yard_options
  @yard_options
end

#yard_titleObject

Title for the YARD documentation



32
33
34
# File 'lib/hoe/yard.rb', line 32

def yard_title
  @yard_title
end

Instance Method Details

#define_yard_tasksObject

Defines additional rake tasks.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/hoe/yard.rb', line 78

def define_yard_tasks
  require 'yard'

  desc "Remove YARD products"
  task :clobber_docs do
    if File.exists?(local_yard_dir)
      rm_r local_yard_dir, :verbose => true
    end
  end

  # generate the YARD options
  opts = normalize_yard_opts

  # define the yard task
  ::YARD::Rake::YardocTask.new do |t|
    t.files = self.spec.files.select { |path| path =~ /^lib\/.+\.rb$/ }
    t.options = opts + ['--files'] + self.yard_files
  end
  task :docs => :yard

  # override the RDoc options
  self.spec.rdoc_options = opts
end

#initialize_yardObject

Initializes the hoe-yard plugin.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/hoe/yard.rb', line 48

def initialize_yard
  self.yard_title = Hoe.normalize_names(self.name).last + ' Documentation'
  self.yard_markup = nil
  self.yard_markup_provider = nil
  self.yard_options = []

  # find the README.* and History.* files
  self.readme_file = intuit_file_name(File.basename(self.readme_file))
  self.history_file = intuit_file_name(File.basename(self.history_file))

  # disable RDoc and ri tasks
  self.need_rdoc = false

  unless self.name == 'hoe-yard'
    # add hoe-yard as a development dependency
    self.extra_dev_deps << ['hoe-yard', ">=#{PLUGIN_VERSION}"]
  end

  # we have YARD docs
  self.spec_extras.merge!(:has_rdoc => 'yard')

  if self.history_file
    # include the history file
    self.yard_files << self.history_file
  end
end