Brad Werth Brad Werth - 7 months ago 12
Ruby Question

Rake aborted! Don't know how to build task 'doc:app'

The official documentation indicates that I should be able to build documentation for my application using

rake doc:app
, but when I run the command in Rails 5 I get the following output:

bwerth@bwerth-VirtualBox:~/rails/gep$ rake doc:app
rake aborted!
Don't know how to build task 'doc:app' (see --tasks)

(See full trace by running task with --trace)

Answer

This functionality was removed from Rails in version 5 with the following justification:

...In our experience applications do not generate APIs using doc:app...If a team absolutely needs to generate application documentation for internal purposes, they can still easily write their own task...

The functionality can be easily restored by creating a file at /lib/tasks/documentation.rake with the following contents, taken from the last version of the official task:

# /lib/tasks/documentation.rake
require 'rdoc/task'

namespace :doc do
  RDoc::Task.new("app") { |rdoc|
    rdoc.rdoc_dir = 'doc/app'
    rdoc.template = ENV['template'] if ENV['template']
    rdoc.title = ENV['title'] || 'Rails Application Documentation'
    rdoc.options << '--line-numbers'
    rdoc.options << '--charset' << 'utf-8'
    rdoc.rdoc_files.include('README.md')
    rdoc.rdoc_files.include('app/**/*.rb')
    rdoc.rdoc_files.include('lib/**/*.rb')
  }
  Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"
end

Although, at this point it almost seems easier to just run something like this, from the command line:

rdoc --main README.md --title 'My Fancy Title' README.md app/**/*.rb lib/**/*.rb 
Comments