我能做到
sudo gem rdoc activerecord --no-ri
和
sudo gem rdoc actionpack --no-ri
这两个都给了我很好的文档。
但是
sudo gem rdoc rails --no-ri
几乎没有给我任何东西,因为Rails宝石本身只是其他人的持有者。如何生成等效的http://api.rubyonrails.org/?
答案 0 :(得分:16)
sudo gem rdoc --all --overwrite
答案 1 :(得分:14)
我发现最简单的方法是从railsapi.com下载它们并将文件解压缩到/Library/Ruby/Gems/1.8/doc/rails-2.3.3/rdoc/
答案 2 :(得分:9)
如果您使用rdoc安装rails(sudo gem install rails) 您可以通过
访问它gem server
答案 3 :(得分:5)
以下是我尝试澄清有关如何将本地下载的rails 3.1文档下载到您的计算机上的步骤,等同于http://api.rubyonrails.org/
作为旁注,看起来sdoc正式成为Ruby on Rails API的文档(参见http://weblog.rubyonrails.org/2011/8/29/the-rails-api-switches-to-sdoc)
答案 4 :(得分:3)
您可以在应用中冻结Rails并运行rake doc:rails
以获取文档。
rails doc_project
cd doc_project
rake rails:freeze
rake doc:rails
RDoc应位于doc / api目录中。您可以使用rake rails:freeze:edge
获取Edge Rails的文档。
或者,您也可以从Rails Brain等网站下载文档,以获取可搜索的模板。
如果您希望文档显示在gem server
中,那么最简单的方法可能是使用rdoc选项重新安装rails gem。
sudo gem install rails --rdoc
答案 5 :(得分:2)
在命令行上运行命令bundle exec rdoc
。
它将生成代码的所有文档。
答案 6 :(得分:0)
desc "Generate documentation for the Rails framework"
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.title = "Ruby on Rails Documentation"
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.options << '-A cattr_accessor=object'
rdoc.options << '--charset' << 'utf-8'
rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : './doc/template/horo'
rdoc.rdoc_files.include('railties/CHANGELOG')
rdoc.rdoc_files.include('railties/MIT-LICENSE')
rdoc.rdoc_files.include('railties/README')
rdoc.rdoc_files.include('railties/lib/{*.rb,commands/*.rb,rails/*.rb,rails_generator/*.rb}')
rdoc.rdoc_files.include('activerecord/README')
rdoc.rdoc_files.include('activerecord/CHANGELOG')
rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')
rdoc.rdoc_files.include('activeresource/README')
rdoc.rdoc_files.include('activeresource/CHANGELOG')
rdoc.rdoc_files.include('activeresource/lib/active_resource.rb')
rdoc.rdoc_files.include('activeresource/lib/active_resource/*')
rdoc.rdoc_files.include('actionpack/README')
rdoc.rdoc_files.include('actionpack/CHANGELOG')
rdoc.rdoc_files.include('actionpack/lib/action_controller/**/*.rb')
rdoc.rdoc_files.include('actionpack/lib/action_view/**/*.rb')
rdoc.rdoc_files.exclude('actionpack/lib/action_controller/vendor/*')
rdoc.rdoc_files.include('actionmailer/README')
rdoc.rdoc_files.include('actionmailer/CHANGELOG')
rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')
rdoc.rdoc_files.include('activesupport/README')
rdoc.rdoc_files.include('activesupport/CHANGELOG')
rdoc.rdoc_files.include('activesupport/lib/active_support/**/*.rb')
rdoc.rdoc_files.exclude('activesupport/lib/active_support/vendor/*')
end
# Enhance rdoc task to copy referenced images also
task :rdoc do
FileUtils.mkdir_p "doc/rdoc/files/examples/"
FileUtils.copy "activerecord/examples/associations.png", "doc/rdoc/files/examples/associations.png"
end
答案 7 :(得分:0)
如果您需要生成边缘文档,可以执行类似这样的操作
git clone git://github.com/rails/rails.git ~/rails
# or if you have repo, just checkout interested branch
cd ~
ruby ~/rails/railties/bin/rails docapp
cd docapp
ln -s ~/rails vendor/rails
rake doc:rerails
rake doc:guides
答案 8 :(得分:0)
$ rake rails:freeze:gems
$ rake doc:rails
$ rake rails:unfreeze
$ sudo mv doc/api/* /Library/Ruby/Gems/1.8/doc/rails-2.3.5/rdoc
$ gem server