Ruby Tips 13 - Find code that has not been documented with YARD

I use YARD for documenting my Ruby and Rails code. One of the things that it does when it runs is that it gives you the stats of your documentation coverage. I often forget how to find what has not been documented and this is to help me remember it.

Often, when using YARD, you will see something that looks like this:

$ yard
Files:          30
Modules:        14 (    1 undocumented)
Classes:        27 (    4 undocumented)
Constants:       1 (    0 undocumented)
Attributes:      3 (    0 undocumented)
Methods:        72 (    0 undocumented)
 95.73% documented

So, where are these undocumented bits? I then hunt frantically through the code to find where I missed adding in-line documentation.

There’s an easier way!

$ yard stats --list-undoc

That’s it – you’ll get a list of items that have not been documented yet.

$ yard stats --list-undoc
Files:          30
Modules:        14 (    1 undocumented)
Classes:        27 (    4 undocumented)
Constants:       1 (    0 undocumented)
Attributes:      3 (    0 undocumented)
Methods:        72 (    0 undocumented)
 95.73% documented

Undocumented Objects:

(in file: app/channels/application_cable/channel.rb)
ApplicationCable
ApplicationCable::Channel

(in file: app/channels/application_cable/connection.rb)
ApplicationCable::Connection

(in file: app/jobs/application_job.rb)
ApplicationJob

(in file: app/mailers/application_mailer.rb)
ApplicationMailer

Just be aware that if you have a lot of stuff that is not documented, you’re going to end up with a long, long list!

comments powered by Disqus