我下载了 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
andoptions
settings are optional.files
will default tolib/**/*.rb
andoptions
will represents any options you might want to add. Again, a full list of options is available by typingyardoc --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/