Class: YARD::Rake::YardocTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/yard/rake/yardoc_task.rb

Overview

The rake task to run CLI::Yardoc and generate documentation.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (YardocTask) initialize(name = :yard) {|_self| ... }

Creates a new task with name name.

Yields:

  • a block to allow any options to be modified on the task

Yield Parameters:

  • _self (YardocTask)

    the task object to allow any parameters to be changed.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/yard/rake/yardoc_task.rb', line 46

def initialize(name = :yard)
  @name = name
  @options = []
  @files = []

  yield self if block_given?
  self.options +=  ENV['OPTS'].split(/[ ,]/) if ENV['OPTS']
  self.files   += ENV['FILES'].split(/[ ,]/) if ENV['FILES']

  define
end

Instance Attribute Details

- (Proc) after

Runs a Proc after the task



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

def after
  @after
end

- (Proc) before

Runs a Proc before the task



28
29
30
# File 'lib/yard/rake/yardoc_task.rb', line 28

def before
  @before
end

- (Array<String>) files

The Ruby source files (and any extra documentation files separated by '-') to process.

Examples:

Task files assignment

YARD::Rake::YardocTask.new do |t|
  t.files   = ['app/**/*.rb', 'lib/**/*.rb', '-', 'doc/FAQ.md', 'doc/Changes.md']
end


24
25
26
# File 'lib/yard/rake/yardoc_task.rb', line 24

def files
  @files
end

- (String) name

The name of the task



11
12
13
# File 'lib/yard/rake/yardoc_task.rb', line 11

def name
  @name
end

- (Array<String>) options

Options to pass to CLI::Yardoc



15
16
17
# File 'lib/yard/rake/yardoc_task.rb', line 15

def options
  @options
end

- (Verifier, Proc) verifier

Returns an optional Verifier to run against all objects being generated. Any object that the verifier returns false for will be excluded from documentation. This attribute can also be a lambda.

See Also:



38
39
40
# File 'lib/yard/rake/yardoc_task.rb', line 38

def verifier
  @verifier
end

Instance Method Details

- (void) define (protected)

This method returns an undefined value.

Defines the rake task



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/yard/rake/yardoc_task.rb', line 62

def define
  desc "Generate YARD Documentation"
  task(name) do
    before.call if before.is_a?(Proc)
    yardoc = YARD::CLI::Yardoc.new
    yardoc.parse_arguments *(options + files)
    yardoc.options[:verifier] = verifier if verifier
    yardoc.run
    after.call if after.is_a?(Proc)
  end
end