Brad Werth Brad Werth - 1 year ago 58
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 Source

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"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'
  Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"

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

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