You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm going through the book 'Ruby By Example' by Kevin C. Baird, and I have a small code example for the 99 bottles problem:
#!/usr/bin/env ruby# 99bottles.rbclassWalldefinitialize(num_of_bottles)@bottles=num_of_bottlesend=begin rdocPredicate, ends in a question mark, returns <b>Boolean</b>.=enddefempty?()@bottles.zero?enddefsing_one_verse!()putssing(' on the wall, ') + sing("\n") + take_one_down! + sing(" on the wall.\n\n")endprivatedefsing(extra='')"#{(@bottles > 0) ? @bottles : 'no more'}#{(@bottles == 1) ? 'bottle' : 'bottles'} of beer" + extraend=begin rdocDestructive method named with a bang because it decrements @bottles.Returns a <b>String</b>.=enddeftake_one_down!()@bottles -= 1'take one down, pass it around, 'endendwall=Wall.new99putswall.sing_one_verse!putswall.sing_one_verse!wall=Wall.new1putswall.sing_one_verse!
I know that the book is fairly old, and that maybe the exact output shouldn't be trusted, but I'm running this through rdoc and I get the following:
$ rdoc -C 99bottles.rb
Parsing sources...
100% [ 1/ 1] 99bottles.rb
The following items are not documented:
In files:
* 99bottles.rb
class Wall
# in file 99bottles.rb:4
def self.new(num_of_bottles); end
# in file 99bottles.rb:15
def sing_one_verse!(); end
end
Files: 1
Classes: 1 (1 undocumented)
Modules: 0 (0 undocumented)
Constants: 0 (0 undocumented)
Attributes: 0 (0 undocumented)
Methods: 3 (2 undocumented)
Total: 4 (3 undocumented)
25.00% documented
Elapsed: 0.0s
It appears that rdoc cannot detect the documentation of the Wall#take_one_down! method, which is based on a heredoc. I don't know if that's to be expected or not (say, if the functionality got removed in the past and I'm unaware), but it seems like a problem that the documentation of Wall#empty? works based on the exact same form. I am using rdoc 6.5.0 and ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin21]
The text was updated successfully, but these errors were encountered:
Okay, ignore me - I just realised it's not an issue. It works fine, but reporting is slightly ambiguous.
The method doesn't appear documented because it is marked private. I need to add a comment #:doc: next to its definition, and then rdoc works fine with it.
Hello.
I'm going through the book 'Ruby By Example' by Kevin C. Baird, and I have a small code example for the 99 bottles problem:
I know that the book is fairly old, and that maybe the exact output shouldn't be trusted, but I'm running this through
rdoc
and I get the following:It appears that
rdoc
cannot detect the documentation of theWall#take_one_down!
method, which is based on a heredoc. I don't know if that's to be expected or not (say, if the functionality got removed in the past and I'm unaware), but it seems like a problem that the documentation ofWall#empty?
works based on the exact same form. I am usingrdoc 6.5.0
andruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin21]
The text was updated successfully, but these errors were encountered: