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

谁说胖子不能爱 提交于 2019-12-10 19:35:39

问题


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)

回答1:


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 


来源:https://stackoverflow.com/questions/36804473/rake-aborted-dont-know-how-to-build-task-docapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!