Method: Inventory::Rake::Tasks::YARD#define

Defined in:
lib/inventory-rake-tasks-yard-1.0.rb

#defineObject

Defines the following tasks (html is actually whatever #name has been set to):

<dl>

<dt>.yardopts (file)</dt>
<dd>Create .yardopts file based on {#options}; depends on the file
defining this task and Rakefile.</dd>

<dt>html</dt>
<dd>Generate documentation in HTML format for all {#files}, passing
{#globals} to YARD; depends on .yardopts file.</dd>

</dl>



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/inventory-rake-tasks-yard-1.0.rb', line 82

def define
  desc 'Create .yardopts file'
  file '.yardopts' => [__FILE__, 'Rakefile'] do |t|
    tmp = '%s.tmp' % t.name
    rm([t.name, tmp], :force => true)
    rake_output_message 'echo %s > %s' % [options.join(' '), tmp] if verbose
    File.open(tmp, 'wb') do |f|
      f.write options.join(' ')
    end
    chmod File.stat(tmp).mode & ~0222, tmp
    mv tmp, t.name
  end

  desc name == :html ?
    'Generate documentation in HTML format' :
    'Generate documentation for %s in HTML format' % name
  task name => '.yardopts' do
    require 'yard'
    yardoc = YARD::CLI::Yardoc.new
    yardoc.parse_arguments(*arguments)
    globals.each do |key, value|
      yardoc.options.globals.send '%s=' % key, value
    end
    rake_output_message 'yard doc %s' % Shellwords.shelljoin(arguments(yardopts(yardoc))) if verbose
    yardoc.run(nil)
  end
end