6

I downloaded the ruby Twitter gem source code and am trying to generate the documentation using yard, which I installed via gem install yard. In the rakefile, I found the following, which I assume is used to generate the docs for the Twitter gem:

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

I tried to require yard in irb and then run YARD::Rake::YardocTask.new but nothing happened.

Can you help me get on the right track?

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134

1 Answers1

15

From 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'

To summarize: after adding YARD::Rake::YardocTask.new to your Rakefile, run rake yard.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
  • 1
    Note that the block is actually optional. According to [the doc](http://www.rubydoc.info/gems/yard/0.9.5/YARD/Rake/YardocTask#initialize-instance_method), you can change the name of the task if you like. – Franklin Yu Sep 03 '16 at 19:10
  • But what is really OTHER_PATHS? I'm not able to include any extra files. – Juan Ibiapina Sep 24 '16 at 14:29
  • @NathanLilienthal - I can only assume/hope that YARD was named for the sake of this pun. I smell a backronymic apronym... – Benjineer Dec 05 '17 at 09:32