Skip to content

Commit de83ed0

Browse files
committed
Used rdoc -u to improve documentation
1 parent 81de6e8 commit de83ed0

29 files changed

+187
-24
lines changed

lib/rdoc/any_method.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ class RDoc::AnyMethod < RDoc::MethodAttr
2525

2626
include RDoc::TokenStream
2727

28-
def initialize(text, name)
29-
super text, name
28+
##
29+
# Creates a new AnyMethod with a token stream +text+ and +name+
30+
31+
def initialize text, name
32+
super
33+
3034
@dont_rename_initialize = false
3135
@token_stream = nil
3236
end

lib/rdoc/constant.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def <=> other
4242
[parent_name, name] <=> [other.parent_name, other.name]
4343
end
4444

45+
##
46+
# Constants are equal when their #parent and #name is the same
47+
4548
def == other
4649
self.class == other.class and
4750
@parent == other.parent and

lib/rdoc/generator/markup.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,20 @@ def cvs_url(url, full_path)
5858

5959
class RDoc::AnyMethod
6060

61+
##
62+
# Maps RDoc::RubyToken classes to CSS class names
63+
6164
STYLE_MAP = {
62-
RDoc::RubyToken::TkCONSTANT => "ruby-constant",
63-
RDoc::RubyToken::TkKW => "ruby-keyword",
64-
RDoc::RubyToken::TkIVAR => "ruby-ivar",
65-
RDoc::RubyToken::TkOp => "ruby-operator",
66-
RDoc::RubyToken::TkId => "ruby-identifier",
67-
RDoc::RubyToken::TkNode => "ruby-node",
68-
RDoc::RubyToken::TkCOMMENT => "ruby-comment",
69-
RDoc::RubyToken::TkREGEXP => "ruby-regexp",
70-
RDoc::RubyToken::TkSTRING => "ruby-string",
71-
RDoc::RubyToken::TkVal => "ruby-value",
65+
RDoc::RubyToken::TkCONSTANT => 'ruby-constant',
66+
RDoc::RubyToken::TkKW => 'ruby-keyword',
67+
RDoc::RubyToken::TkIVAR => 'ruby-ivar',
68+
RDoc::RubyToken::TkOp => 'ruby-operator',
69+
RDoc::RubyToken::TkId => 'ruby-identifier',
70+
RDoc::RubyToken::TkNode => 'ruby-node',
71+
RDoc::RubyToken::TkCOMMENT => 'ruby-comment',
72+
RDoc::RubyToken::TkREGEXP => 'ruby-regexp',
73+
RDoc::RubyToken::TkSTRING => 'ruby-string',
74+
RDoc::RubyToken::TkVal => 'ruby-value',
7275
}
7376

7477
include RDoc::Generator::Markup

lib/rdoc/markup/attribute_manager.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,19 @@ def attribute(turn_on, turn_off)
7979
RDoc::Markup::AttrChanger.new turn_on, turn_off
8080
end
8181

82-
def change_attribute(current, new)
82+
##
83+
# Changes the current attribute from +current+ to +new+
84+
85+
def change_attribute current, new
8386
diff = current ^ new
8487
attribute(new & diff, current & diff)
8588
end
8689

87-
def changed_attribute_by_name(current_set, new_set)
90+
##
91+
# Used by the tests to change attributes by name from +current_set+ to
92+
# +new_set+
93+
94+
def changed_attribute_by_name current_set, new_set
8895
current = new = 0
8996
current_set.each do |name|
9097
current |= RDoc::Markup::Attribute.bitmap_for(name)
@@ -97,6 +104,9 @@ def changed_attribute_by_name(current_set, new_set)
97104
change_attribute(current, new)
98105
end
99106

107+
##
108+
# Copies +start_pos+ to +end_pos+ from the current string
109+
100110
def copy_string(start_pos, end_pos)
101111
res = @str[start_pos...end_pos]
102112
res.gsub!(/\000/, '')
@@ -265,6 +275,9 @@ def display_attributes
265275
end
266276
end
267277

278+
##
279+
# Splits the string into chunks by attribute change
280+
268281
def split_into_flow
269282
res = []
270283
current_attr = 0

lib/rdoc/markup/blank_line.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ class RDoc::Markup::BlankLine
55

66
@instance = new
77

8+
##
9+
# RDoc::Markup::BlankLine is a singleton
10+
811
def self.new
912
@instance
1013
end
1114

15+
##
16+
# Calls #accept_blank_line on +visitor+
17+
1218
def accept visitor
1319
visitor.accept_blank_line self
1420
end

lib/rdoc/markup/document.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def == other # :nodoc:
3939
self.class == other.class and @parts == other.parts
4040
end
4141

42+
##
43+
# Runs this document and all its #items through +visitor+
44+
4245
def accept visitor
4346
visitor.start_accepting
4447

@@ -49,6 +52,9 @@ def accept visitor
4952
visitor.end_accepting
5053
end
5154

55+
##
56+
# Does this document have no parts?
57+
5258
def empty?
5359
@parts.empty?
5460
end

lib/rdoc/markup/formatter.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
class RDoc::Markup::Formatter
99

10+
##
11+
# Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
12+
# +off+ triggers.
13+
1014
InlineTag = Struct.new(:bit, :on, :off)
1115

1216
##
@@ -101,6 +105,9 @@ def in_tt?
101105
@in_tt > 0
102106
end
103107

108+
##
109+
# Turns on tags for +item+ on +res+
110+
104111
def on_tags res, item
105112
attr_mask = item.turn_on
106113
return if attr_mask.zero?
@@ -113,6 +120,9 @@ def on_tags res, item
113120
end
114121
end
115122

123+
##
124+
# Turns off tags for +item+ on +res+
125+
116126
def off_tags res, item
117127
attr_mask = item.turn_off
118128
return if attr_mask.zero?

lib/rdoc/markup/formatter_test_case.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,43 @@
44
##
55
# Test case for creating new RDoc::Markup formatters. See
66
# test/test_rdoc_markup_to_*.rb for examples.
7+
#
8+
# Example:
9+
#
10+
# class TestRDocMarkupToNewFormat < RDoc::Markup::FormatterTestCase
11+
#
12+
# add_visitor_tests
13+
#
14+
# def setup
15+
# super
16+
#
17+
# @to = RDoc::Markup::ToNewFormat.new
18+
# end
19+
#
20+
# def accept_blank_line
21+
# assert_equal :junk, @to.res.join
22+
# end
23+
#
24+
# # ...
25+
#
26+
# end
727

828
class RDoc::Markup::FormatterTestCase < MiniTest::Unit::TestCase
929

30+
##
31+
# Call #setup when inheriting from this test case.
32+
#
33+
# Provides the following instance variables:
34+
#
35+
# +@m+:: RDoc::Markup.new
36+
# +@RM+:: RDoc::Markup # to reduce typing
37+
# +@bullet_list+:: @RM::List.new :BULLET, # ...
38+
# +@label_list+:: @RM::List.new :LABEL, # ...
39+
# +@lalpha_list+:: @RM::List.new :LALPHA, # ...
40+
# +@note_list+:: @RM::List.new :NOTE, # ...
41+
# +@number_list+:: @RM::List.new :NUMBER, # ...
42+
# +@ualpha_list+:: @RM::List.new :UALPHA, # ...
43+
1044
def setup
1145
super
1246

@@ -38,7 +72,11 @@ def setup
3872
@RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
3973
end
4074

75+
##
76+
# Call to add the visitor tests to your test case
77+
4178
def self.add_visitor_tests
79+
# :stopdoc:
4280
self.class_eval do
4381
def test_start_accepting
4482
@to.start_accepting
@@ -487,6 +525,7 @@ def test_list_verbatim # HACK overblown
487525

488526
list_verbatim
489527
end
528+
# :stopdoc:
490529
end
491530
end
492531

lib/rdoc/markup/heading.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
class RDoc::Markup::Heading < Struct.new :level, :text
55

6+
##
7+
# Calls #accept_heading on +wisitor+
8+
69
def accept visitor
710
visitor.accept_heading self
811
end

lib/rdoc/markup/inline.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Attribute
1515
@@name_to_bitmap = { :_SPECIAL_ => SPECIAL }
1616
@@next_bitmap = 2
1717

18+
##
19+
# Returns a unique bit for +name+
20+
1821
def self.bitmap_for(name)
1922
bitmap = @@name_to_bitmap[name]
2023
unless bitmap then
@@ -25,6 +28,9 @@ def self.bitmap_for(name)
2528
bitmap
2629
end
2730

31+
##
32+
# Returns a string reperesentation of +bitmap+
33+
2834
def self.as_string(bitmap)
2935
return "none" if bitmap.zero?
3036
res = []
@@ -34,6 +40,9 @@ def self.as_string(bitmap)
3440
res.join(",")
3541
end
3642

43+
##
44+
# yields each attribute name in +bitmap+
45+
3746
def self.each_name_of(bitmap)
3847
@@name_to_bitmap.each do |name, bit|
3948
next if bit == SPECIAL

0 commit comments

Comments
 (0)