Class: Rails::API::Task

Inherits:
RDoc::Task
  • Object
show all
Defined in:
lib/rails/api/task.rb

Direct Known Subclasses

AppTask, RepoTask

Constant Summary collapse

RDOC_FILES =
{
  'activesupport' => {
    :include => %w(
      README.rdoc
      lib/active_support/**/*.rb
    ),
    :exclude => 'lib/active_support/vendor/*'
  },

  'activerecord' => {
    :include => %w(
      README.rdoc
      lib/active_record/**/*.rb
    )
  },

  'activemodel' => {
    :include => %w(
      README.rdoc
      lib/active_model/**/*.rb
    )
  },

  'actionpack' => {
    :include => %w(
      README.rdoc
      lib/abstract_controller/**/*.rb
      lib/action_controller/**/*.rb
      lib/action_dispatch/**/*.rb
    )
  },

  'actionview' => {
    :include => %w(
      README.rdoc
      lib/action_view/**/*.rb
    ),
    :exclude => 'lib/action_view/vendor/*'
  },

  'actionmailer' => {
    :include => %w(
      README.rdoc
      lib/action_mailer/**/*.rb
    )
  },

  'railties' => {
    :include => %w(
      README.rdoc
      lib/**/*.rb
    ),
    :exclude => 'lib/rails/generators/rails/**/templates/**/*.rb'
  }
}

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Task

Returns a new instance of Task.



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rails/api/task.rb', line 62

def initialize(name)
  super

  # Every time rake runs this task is instantiated as all the rest.
  # Be lazy computing stuff to have as light impact as possible to
  # the rest of tasks.
  before_running_rdoc do
    load_and_configure_sdoc
    configure_rdoc_files
    setup_horo_variables
  end
end

Instance Method Details

#api_mainObject



117
118
119
# File 'lib/rails/api/task.rb', line 117

def api_main
  component_root_dir('railties') + '/RDOC_MAIN.rdoc'
end

#configure_rdoc_filesObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/rails/api/task.rb', line 96

def configure_rdoc_files
  rdoc_files.include(api_main)

  RDOC_FILES.each do |component, cfg|
    cdr = component_root_dir(component)

    Array(cfg[:include]).each do |pattern|
      rdoc_files.include("#{cdr}/#{pattern}")
    end

    Array(cfg[:exclude]).each do |pattern|
      rdoc_files.exclude("#{cdr}/#{pattern}")
    end
  end
end

#desc(description) ⇒ Object

Hack, ignore the desc calls performed by the original initializer.



76
77
78
# File 'lib/rails/api/task.rb', line 76

def desc(description)
  # no-op
end

#load_and_configure_sdocObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rails/api/task.rb', line 80

def load_and_configure_sdoc
  require 'sdoc'

  self.title    = 'Ruby on Rails API'
  self.rdoc_dir = api_dir

  options << '-m'  << api_main
  options << '-e'  << 'UTF-8'

  options << '-f'  << 'sdoc'
  options << '-T'  << 'rails'
rescue LoadError
  $stderr.puts %(Unable to load SDoc, please add\n\n    gem 'sdoc', require: false\n\nto the Gemfile.)
  exit 1
end

#setup_horo_variablesObject



112
113
114
115
# File 'lib/rails/api/task.rb', line 112

def setup_horo_variables
  ENV['HORO_PROJECT_NAME']    = 'Ruby on Rails'
  ENV['HORO_PROJECT_VERSION'] = rails_version
end