Class: Rails::API::Task

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

Direct Known Subclasses

RepoTask

Constant Summary collapse

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

  "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
    )
  },

  "activejob" => {
    include: %w(
      README.md
      lib/active_job/**/*.rb
    )
  },

  "actioncable" => {
    include: %w(
      README.md
      lib/action_cable/**/*.rb
    )
  },

  "activestorage" => {
    include: %w(
      README.md
      app/**/active_storage/**/*.rb
      lib/active_storage/**/*.rb
    )
  },

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

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Task

Returns a new instance of Task.



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rails/api/task.rb', line 90

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
    configure_sdoc
    configure_rdoc_files
    setup_horo_variables
  end
end

Instance Method Details

#api_mainObject



153
154
155
# File 'lib/rails/api/task.rb', line 153

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

#configure_rdoc_filesObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/rails/api/task.rb', line 119

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

  # Only generate documentation for files that have been
  # changed since the API was generated.
  if Dir.exist?("doc/rdoc") && !ENV["ALL"]
    last_generation = DateTime.rfc2822(File.open("doc/rdoc/created.rid", &:readline))

    rdoc_files.keep_if do |file|
      File.mtime(file).to_datetime > last_generation
    end

    # Nothing to do
    exit(0) if rdoc_files.empty?
  end
end

#configure_sdocObject



108
109
110
111
112
113
114
115
116
117
# File 'lib/rails/api/task.rb', line 108

def configure_sdoc
  self.title    = "Ruby on Rails API"
  self.rdoc_dir = api_dir

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

  options << "-f"  << "api"
  options << "-T"  << "rails"
end

#desc(description) ⇒ Object

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



104
105
106
# File 'lib/rails/api/task.rb', line 104

def desc(description)
  # no-op
end

#setup_horo_variablesObject



148
149
150
151
# File 'lib/rails/api/task.rb', line 148

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