如何重命名或移动Rails的README_FOR_APP [英] How to Rename or Move Rails's README_FOR_APP
问题描述
当我在我的Rails应用程序根目录中运行 rake doc:app
时,API文档将使用 / doc / README_FOR_APP
作为主页。我想为该文件添加一个 .rdoc
扩展名,以便在GitHub上正确呈现。更好的是,我想将其移动到应用程序根目录( /README.rdoc
)。有没有办法通过修改包含的 rake / rdoctask
任务在我的 Rakefile
中执行此操作?有没有找到可以修改的主页文件的名称?或者我必须写一个新的耙子任务?
When I run rake doc:app
in my Rails application root, the API docs are generated using /doc/README_FOR_APP
as the home page. I would like to add a .rdoc
extention to that file so it is properly rendered on GitHub. Even better, I would like to move it to the app root (/README.rdoc
). Is there a way to do this in my Rakefile
by modifying the included rake/rdoctask
task? Is there some place it looks for the name of the home page file that can be modified? Or do I have to write a new Rake task?
奖金问题:两个单独文件背后的逻辑是什么 / README
和 / doc / README_FOR_APP
为Rails应用程序?为什么不只是一个?
Bonus question: what is the logic behind the two separate files /README
and /doc/README_FOR_APP
for Rails applications? Why not just one?
推荐答案
Rails rdoc任务在< rails gem folder> / lib /任务/ documentation.rake
Rails rdoc task is in <rails gem folder>/lib/tasks/documentation.rake
做你想要的,执行:app任务并修改它,将其放在.rake文件中你的应用程序/ lib / tasks
to do what you want, take the :app task and alter it, putting it in a .rake file in your app's /lib/tasks
#clear the doc:app task et al
Rake::Task["doc:app"].clear
Rake::Task["doc/app"].clear
Rake::Task["doc/app/index.html"].clear
namespace :doc do
desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
Rake::RDocTask.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' << '--inline-source'
rdoc.options << '--charset' << 'utf-8'
rdoc.rdoc_files.include('app/**/*.rb')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('README')
rdoc.main = 'README'
}
end
我不知道这是否是完全正确的,但玩弄它,看看 rdoc任务文档了解更多信息。
I'm not sure if that is exactly it, but play around with it and look at the rdoc task docs for more info.
这篇关于如何重命名或移动Rails的README_FOR_APP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!