更改用于生成Rails应用程序文档的RDoc模板 [英] Change a RDoc template for generating Rails app documentation
问题描述
我刚刚在Rails 3.2.13应用程序中添加了一些文档.通过使用rake任务,我可以很好地生成文档(运行RDoc 3.12.2):
I have just added some documentation to my Rails 3.2.13 app. I can generate the documentation just fine (running RDoc 3.12.2) by using a rake task:
# lib/tasks/documentation.rake
Rake::Task["doc:app"].clear
Rake::Task["doc/app"].clear
Rake::Task["doc/app/index.html"].clear
namespace :doc do
RDoc::Task.new('app') do |rdoc|
rdoc.rdoc_dir = 'doc/app'
rdoc.generator = 'hanna'
rdoc.title = 'Stoffi Web App Documentation'
rdoc.main = 'doc/Overview'
rdoc.options << '--charset' << 'utf-8'
rdoc.rdoc_files.include('app/**/*.rb')
rdoc.rdoc_files.include('doc/*')
end
end
...然后运行rake doc:app
.但是我真的不喜欢Hanna模板的默认外观.有没有办法编辑CSS,也许是通过提供自己的CSS文件来覆盖Hanna中使用的默认CSS文件吗?
...and then running rake doc:app
. But I really don't like the default look of the Hanna template. Is there a way to edit the CSS, perhaps by providing my own CSS file which will override the default one used in Hanna?
谢谢!
推荐答案
首先找到模板的位置:
⮀ RDPATH=$(dirname $(gem which rdoc))
# ⇒ /home/am/.rvm/rubies/ruby-head/lib/ruby/2.1.0
现在将默认模板从此处复制到所需位置(将/tmp
更改为您的项目目录或类似目录):
Now copy the default template from there to the desired location (change /tmp
to your project directory or like):
⮀ cp -r $RDPATH/rdoc/generator/template/darkfish /tmp/myniftytemplate
最后,我们来教rdoc
:
class RDoc::Options
def template_dir_for template
"/tmp/#{template}"
end
end
RDoc::Task.new('app') do |rdoc|
rdoc.template = 'myniftytemplate'
…
end
就是这样.希望对您有所帮助.
That’s it. Hope it helps.
这篇关于更改用于生成Rails应用程序文档的RDoc模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!