[英]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: 官方文档表明我应该能够使用
rake doc:app
为我的应用程序构建文档,但是当我在Rails 5中运行命令时,我得到以下输出:
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)
This functionality was removed from Rails in version 5 with the following justification: 此功能已从版本5中的Rails中删除,具有以下理由:
...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...
...根据我们的经验,应用程序不使用doc:app生成API ...如果团队绝对需要为内部目的生成应用程序文档,他们仍然可以轻松编写自己的任务...
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中创建一个文件,可以轻松恢复该功能,其中包含以下内容,取自官方任务的最新版本 :
# /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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.