Module: Bones::Plugins::Rdoc

Extended by:
Rdoc
Includes:
Helpers
Included in:
Rdoc
Defined in:
lib/bones/plugins/rdoc.rb

Constant Summary

Constants included from Helpers

Helpers::DEV_NULL, Helpers::GEM, Helpers::HAVE, Helpers::HAVE_SVN, Helpers::RCOV, Helpers::RDOC, Helpers::SUDO

Instance Method Summary collapse

Methods included from Helpers

#find_file, #have?, #paragraphs_of, #quiet, #remove_desc_for_task

Instance Method Details

#define_tasksObject



79
80
81
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/bones/plugins/rdoc.rb', line 79

def define_tasks
  config = ::Bones.config

  namespace :doc do
    desc 'Generate RDoc documentation'

    # rdoc-2.4.2
    rd = have?(:rdoc_gem) ? RDoc::Task.new : Rake::RDocTask.new
    rdoc_config(rd,config)

    desc 'Generate ri locally for testing'
    task :ri => :clobber_ri do
      sh "#{RDOC} --ri -o ri ."
    end

    task :clobber_ri do
      rm_r 'ri' rescue nil
    end
  end  # namespace :doc

  unless have? :yard
    desc 'Alias to doc:rdoc'
    task :doc => 'doc:rdoc'
  end

  desc 'Remove all build products'
  task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)

  remove_desc_for_task %w(doc:clobber_rdoc)
end

#initialize_rdocObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bones/plugins/rdoc.rb', line 14

def initialize_rdoc
  ::Bones.config {
    desc 'Configuration settings for rdoc and ri'
    rdoc {

      opts  [], :desc => 'Array of rdoc options to use when generating documentation.'

      include  %w(^lib/ ^bin/ ^ext/ \.txt$ \.rdoc$), :desc => <<-__
        An array of patterns that will be used to find the files for which
        documentation should be generated. This is an array of strings that
        will be converted in regular expressions.
      __

      exclude  %w(extconf\.rb$ ^version.txt), :desc => <<-__
        An array of patterns that will be used to exclude files from rdoc
        processing. This is an array of strings that will be converted in
        regular expressions.
      __

      main  nil, :desc => <<-__
        The main rdoc file for the project. This defaults to the project's
        README file.
      __

      dir  'doc', :desc => 'Output directory for generated documentation.'
    }
  }

  have?(:rdoc) { true }
  have?(:rdoc_gem) { true } if defined? RDoc
end

#post_loadObject



46
47
48
49
50
51
# File 'lib/bones/plugins/rdoc.rb', line 46

def post_load
  config = ::Bones.config

  config.exclude << "^#{Regexp.escape(config.rdoc.dir)}/"
  config.rdoc.main ||= config.readme_file
end

#rdoc_config(rd, config) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/bones/plugins/rdoc.rb', line 53

def rdoc_config(rd, config)
  rdoc = config.rdoc
  incl = Regexp.new(rdoc.include.join('|'))
  excl = Regexp.new(rdoc.exclude.join('|'))
  files = config.gem.files.find_all do |fn|
            case fn
            when excl; false
            when incl; true
            else false end
          end
  title = "#{config.name}-#{config.version} Documentation"
  rd.main = rdoc.main
  rd.rdoc_dir = rdoc.dir

  rd.rdoc_files.push(*files)


  if have? :rdoc_gem
    rd.title = title
  else
    rd.options << "-t #{title}"
  end

  rd.options.concat(rdoc.opts)
end