ruby - 使用 rakefile 从源代码生成文档

标签 ruby rake yard

我下载了 ruby​​ Twitter gem 源代码并尝试使用 yard 生成文档,我通过 gem install yard 安装了它。在 rakefile 中,我发现了以下内容,我认为它用于为 Twitter gem 生成文档:

require 'yard'
YARD::Rake::YardocTask.new

我尝试在 irb 中require yard 然后运行 ​​YARD::Rake::YardocTask.new 但没有任何反应。

你能帮我走上正轨吗?

最佳答案

来自 the YARD docs :

The second most obvious is to generate docs via a Rake task. You can do this by adding the following to your Rakefile:

YARD::Rake::YardocTask.new do |t|
  t.files   = ['lib/**/*.rb', OTHER_PATHS]   # optional
  t.options = ['--any', '--extra', '--opts'] # optional
end

both the files and options settings are optional. files will default to lib/**/*.rb and options will represents any options you might want to add. Again, a full list of options is available by typing yardoc --help in a shell. You can also override the options at the Rake command-line with the OPTS environment variable:

$ rake yard OPTS='--any --extra --opts'

总结:将 YARD::Rake::YardocTask.new 添加到您的 Rakefile 后,运行 rake yard

关于ruby - 使用 rakefile 从源代码生成文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13022837/

相关文章:

ruby-on-rails - Rails I18n中verification.rb验证方法不起作用?

.net - Bin 部署 rake(和 IronRuby)

heroku - Heroku上#<Rails::Application::Configuration的未定义方法 `sass'

ruby-on-rails - 如何找到 rake 任务的源文件?

ruby - 如何使用 YARD 记录简单的脚本?

ruby - 用 Yardoc 记录 def_delegators

ruby-on-rails - 如何使用 RSpec 测试内存?

ruby-on-rails - 仅为本地主机创建 rails 路由

ruby-on-rails - RSpec、Rails 的未定义方法 `belong_to'

ruby-on-rails - YARD:如何创建指向类方法的链接?