lsegal / yard

YARD is a Ruby Documentation tool. The Y stands for "Yay!"
http://yardoc.org
MIT License
1.94k stars 397 forks source link

Rake task.options '--list-undoc' doesn't work #387

Closed klauern closed 12 years ago

klauern commented 12 years ago

If I have this in my Rakefile:

YARD::Rake::YardocTask.new do |t|
  t.files   = ['lib/**/*.rb' ]   # optional
  t.options = [ '--list-undoc' ]
end

and try to run the rake yard task:

klauer@klauer-imac ~/Programming/Ruby/yardoc_failure
$ bundle exec rake yard
[warn]: Unrecognized/invalid option: --list-undoc
Files:           2
Modules:         1 (    1 undocumented)
Classes:         0 (    0 undocumented)
Constants:       1 (    1 undocumented)
Methods:         0 (    0 undocumented)
 0.00% documented

I get nothing from --list-undoc. I can get it to work just fine from the command line

$ yard --list-undoc
[warn]: Unrecognized/invalid option: --list-undoc
Files:           2
Modules:         1 (    1 undocumented)
Classes:         0 (    0 undocumented)
Constants:       1 (    1 undocumented)
Methods:         0 (    0 undocumented)
 0.00% documented

Undocumented Objects:

(in file: lib/yardoc_failure.rb)
YardocFailure

(in file: lib/yardoc_failure/version.rb)
YardocFailure::VERSION
klauern commented 12 years ago

Also an issue is that even from the command-line it says

[warn]: Unrecognized/invalid option: --list-undoc

but does it anyway, so that could be the crux of the issue and my Rake issues are just a symptom.

lsegal commented 12 years ago

--list-undoc is an option for the yard stats command, which is not used by the YARD task. You could run the yard stats task manually with:

YARD::CLI::Stats.run('--list-undoc')
lsegal commented 12 years ago

The reason this works in the command-line is kind of a quirk in the way options are parsed-- Stats.run(*args) is effectively called on the commandline string when you use yardoc from the CLI, so it picks up the option later.. I wouldn't recommend doing it this way.

I'm closing this ticket because the Stats command should be used instead of the YardocTask, which runs the Yardoc command. Thanks for pointing out the quirk though, at some point we might fix the way CLI parses to deal with this oddity.

klauern commented 12 years ago

Excellent. Thanks for the pointer. So does that make yard --list-undoc a bug then?

lsegal commented 12 years ago

As I mentioned, it's a quirk in the command line parsing-- let's call it "unsupported behaviour" for now-- or a known limitation.