gpt4 book ai didi

ruby-on-rails - rake 中止!不知道如何构建任务 'doc:app'

转载 作者:数据小太阳 更新时间:2023-10-29 07:52:04 24 4
gpt4 key购买 nike

official documentation indicates我应该能够使用 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)

最佳答案

此功能是 removed from Rails在版本 5 中具有以下理由:

...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 中创建一个包含以下内容的文件可以轻松恢复功能,这些内容取自 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

虽然,在这一点上,从命令行运行这样的东西似乎更容易:

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

关于ruby-on-rails - rake 中止!不知道如何构建任务 'doc:app',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36804473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com