耙子流产了!不知道如何建立任务'doc:app' [英] Rake aborted! Don't know how to build task 'doc:app'
问题描述
官方文档表明,我应该能够使用以下方法为我的应用程序构建文档rake doc:app
,但是当我在Rails 5中运行命令时,得到以下输出:
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)
推荐答案
此功能已已从Rails中删除在第5版中具有以下理由:
This functionality was removed from Rails in version 5 with the following justification:
...根据我们的经验,如果团队绝对需要生成应用程序文档,则应用程序不会使用doc:app生成API. 出于内部目的,他们仍然可以轻松地编写自己的任务...
...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...
通过在/lib/tasks/documentation.rake中创建一个文件,可以轻松地恢复该功能,该文件包含以下内容,该内容取自
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
这篇关于耙子流产了!不知道如何建立任务'doc:app'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!