rdoc 2.5.11 → 3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (113) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.document +1 -0
  3. data/History.txt +95 -0
  4. data/Manifest.txt +13 -4
  5. data/README.txt +9 -3
  6. data/Rakefile +1 -1
  7. data/lib/rdoc.rb +15 -298
  8. data/lib/rdoc/alias.rb +65 -16
  9. data/lib/rdoc/any_method.rb +27 -150
  10. data/lib/rdoc/attr.rb +36 -115
  11. data/lib/rdoc/class_module.rb +236 -22
  12. data/lib/rdoc/code_object.rb +76 -31
  13. data/lib/rdoc/constant.rb +32 -4
  14. data/lib/rdoc/context.rb +494 -222
  15. data/lib/rdoc/encoding.rb +79 -0
  16. data/lib/rdoc/erbio.rb +37 -0
  17. data/lib/rdoc/gauntlet.rb +9 -5
  18. data/lib/rdoc/generator.rb +33 -1
  19. data/lib/rdoc/generator/darkfish.rb +284 -375
  20. data/lib/rdoc/generator/markup.rb +72 -36
  21. data/lib/rdoc/generator/ri.rb +4 -4
  22. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +267 -274
  23. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +91 -91
  24. data/lib/rdoc/generator/template/darkfish/index.rhtml +45 -45
  25. data/lib/rdoc/generator/template/darkfish/rdoc.css +298 -298
  26. data/lib/rdoc/include.rb +40 -1
  27. data/lib/rdoc/known_classes.rb +1 -0
  28. data/lib/rdoc/markup.rb +467 -2
  29. data/lib/rdoc/markup/attribute_manager.rb +24 -6
  30. data/lib/rdoc/markup/blank_line.rb +11 -3
  31. data/lib/rdoc/markup/document.rb +6 -0
  32. data/lib/rdoc/markup/formatter.rb +10 -0
  33. data/lib/rdoc/markup/formatter_test_case.rb +339 -3
  34. data/lib/rdoc/markup/heading.rb +3 -0
  35. data/lib/rdoc/markup/inline.rb +11 -1
  36. data/lib/rdoc/markup/list.rb +3 -0
  37. data/lib/rdoc/markup/list_item.rb +3 -0
  38. data/lib/rdoc/markup/paragraph.rb +3 -0
  39. data/lib/rdoc/markup/parser.rb +191 -237
  40. data/lib/rdoc/markup/{preprocess.rb → pre_process.rb} +50 -29
  41. data/lib/rdoc/markup/raw.rb +4 -0
  42. data/lib/rdoc/markup/rule.rb +3 -0
  43. data/lib/rdoc/markup/text_formatter_test_case.rb +116 -0
  44. data/lib/rdoc/markup/to_ansi.rb +14 -2
  45. data/lib/rdoc/markup/to_bs.rb +8 -2
  46. data/lib/rdoc/markup/to_html.rb +84 -91
  47. data/lib/rdoc/markup/to_html_crossref.rb +77 -26
  48. data/lib/rdoc/markup/to_rdoc.rb +94 -49
  49. data/lib/rdoc/markup/to_test.rb +9 -1
  50. data/lib/rdoc/markup/verbatim.rb +6 -3
  51. data/lib/rdoc/method_attr.rb +353 -0
  52. data/lib/rdoc/normal_class.rb +11 -2
  53. data/lib/rdoc/normal_module.rb +0 -5
  54. data/lib/rdoc/options.rb +373 -82
  55. data/lib/rdoc/parser.rb +59 -23
  56. data/lib/rdoc/parser/c.rb +224 -86
  57. data/lib/rdoc/parser/ruby.rb +219 -111
  58. data/lib/rdoc/parser/ruby_tools.rb +4 -1
  59. data/lib/rdoc/parser/simple.rb +9 -4
  60. data/lib/rdoc/rdoc.rb +68 -28
  61. data/lib/rdoc/require.rb +21 -0
  62. data/lib/rdoc/ri/driver.rb +20 -10
  63. data/lib/rdoc/ri/paths.rb +2 -2
  64. data/lib/rdoc/ri/store.rb +22 -5
  65. data/lib/rdoc/ruby_lex.rb +11 -12
  66. data/lib/rdoc/ruby_token.rb +2 -2
  67. data/lib/rdoc/single_class.rb +2 -1
  68. data/lib/rdoc/stats.rb +202 -162
  69. data/lib/rdoc/stats/normal.rb +51 -0
  70. data/lib/rdoc/stats/quiet.rb +59 -0
  71. data/lib/rdoc/stats/verbose.rb +45 -0
  72. data/lib/rdoc/text.rb +133 -4
  73. data/lib/rdoc/{tokenstream.rb → token_stream.rb} +0 -2
  74. data/lib/rdoc/top_level.rb +230 -39
  75. data/test/test_attribute_manager.rb +58 -7
  76. data/test/test_rdoc_alias.rb +13 -0
  77. data/test/test_rdoc_any_method.rb +43 -2
  78. data/test/test_rdoc_attr.rb +15 -8
  79. data/test/test_rdoc_class_module.rb +133 -0
  80. data/test/test_rdoc_code_object.rb +62 -5
  81. data/test/test_rdoc_context.rb +72 -26
  82. data/test/test_rdoc_encoding.rb +145 -0
  83. data/test/test_rdoc_generator_darkfish.rb +119 -0
  84. data/test/test_rdoc_generator_ri.rb +22 -2
  85. data/test/test_rdoc_include.rb +79 -0
  86. data/test/test_rdoc_markup_attribute_manager.rb +4 -4
  87. data/test/test_rdoc_markup_parser.rb +134 -95
  88. data/test/test_rdoc_markup_pre_process.rb +7 -2
  89. data/test/test_rdoc_markup_to_ansi.rb +43 -153
  90. data/test/test_rdoc_markup_to_bs.rb +42 -156
  91. data/test/test_rdoc_markup_to_html.rb +130 -58
  92. data/test/test_rdoc_markup_to_html_crossref.rb +10 -10
  93. data/test/test_rdoc_markup_to_rdoc.rb +40 -151
  94. data/test/test_rdoc_method_attr.rb +122 -0
  95. data/test/test_rdoc_normal_class.rb +1 -1
  96. data/test/test_rdoc_normal_module.rb +6 -1
  97. data/test/test_rdoc_options.rb +237 -12
  98. data/test/test_rdoc_parser.rb +3 -22
  99. data/test/test_rdoc_parser_c.rb +203 -2
  100. data/test/test_rdoc_parser_ruby.rb +403 -89
  101. data/test/test_rdoc_parser_simple.rb +25 -1
  102. data/test/test_rdoc_rdoc.rb +44 -32
  103. data/test/test_rdoc_ri_driver.rb +29 -24
  104. data/test/test_rdoc_ri_store.rb +46 -3
  105. data/test/test_rdoc_task.rb +1 -1
  106. data/test/test_rdoc_text.rb +102 -8
  107. data/test/test_rdoc_top_level.rb +13 -4
  108. data/test/xref_data.rb +8 -0
  109. data/test/xref_test_case.rb +6 -0
  110. metadata +29 -19
  111. metadata.gz.sig +0 -0
  112. data/lib/rdoc/parser/perl.rb +0 -165
  113. data/test/test_rdoc_parser_perl.rb +0 -73
@@ -3,49 +3,75 @@ require 'rdoc/code_object'
3
3
  ##
4
4
  # Represent an alias, which is an old_name/new_name pair associated with a
5
5
  # particular context
6
- #
7
- # TODO: RDoc::Alias needs to know if it's a singleton alias or not
6
+ #--
7
+ # TODO implement Alias as a proxy to a method/attribute, inheriting from
8
+ # MethodAttr
8
9
 
9
10
  class RDoc::Alias < RDoc::CodeObject
10
11
 
11
12
  ##
12
- # Allow comments to be overridden
13
+ # Aliased method's name
13
14
 
14
- attr_writer :comment
15
+ attr_reader :new_name
15
16
 
16
- ##
17
- # Aliased name
18
-
19
- attr_accessor :new_name
17
+ alias name new_name
20
18
 
21
19
  ##
22
- # Aliasee's name
20
+ # Aliasee method's name
23
21
 
24
- attr_accessor :old_name
22
+ attr_reader :old_name
25
23
 
26
24
  ##
27
- # Is this a singeton alias?
25
+ # Is this an alias declared in a singleton context?
28
26
 
29
27
  attr_accessor :singleton
30
28
 
31
29
  ##
32
30
  # Source file token stream
33
31
 
34
- attr_accessor :text
32
+ attr_reader :text
35
33
 
36
34
  ##
37
35
  # Creates a new Alias with a token stream of +text+ that aliases +old_name+
38
- # to +new_name+ and has +comment+
36
+ # to +new_name+, has +comment+ and is a +singleton+ context.
39
37
 
40
- def initialize(text, old_name, new_name, comment)
38
+ def initialize(text, old_name, new_name, comment, singleton = false)
41
39
  super()
42
40
 
43
41
  @text = text
42
+ @singleton = singleton
44
43
  @old_name = old_name
45
44
  @new_name = new_name
46
45
  self.comment = comment
46
+ end
47
+
48
+ ##
49
+ # Order by #singleton then #new_name
50
+
51
+ def <=>(other)
52
+ [@singleton ? 0 : 1, new_name] <=> [other.singleton ? 0 : 1, other.new_name]
53
+ end
54
+
55
+ ##
56
+ # HTML fragment reference for this alias
57
+
58
+ def aref
59
+ type = singleton ? 'c' : 'i'
60
+ "#alias-#{type}-#{html_name}"
61
+ end
62
+
63
+ ##
64
+ # Full old name including namespace
65
+
66
+ def full_old_name
67
+ @full_name || "#{parent.name}#{pretty_old_name}"
68
+ end
47
69
 
48
- @singleton = false
70
+ ##
71
+ # HTML id-friendly version of +#new_name+.
72
+
73
+ def html_name
74
+ CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
49
75
  end
50
76
 
51
77
  def inspect # :nodoc:
@@ -56,8 +82,31 @@ class RDoc::Alias < RDoc::CodeObject
56
82
  ]
57
83
  end
58
84
 
85
+ ##
86
+ # '::' for the alias of a singleton method/attribute, '#' for instance-level.
87
+
88
+ def name_prefix
89
+ singleton ? '::' : '#'
90
+ end
91
+
92
+ ##
93
+ # Old name with prefix '::' or '#'.
94
+
95
+ def pretty_old_name
96
+ "#{singleton ? '::' : '#'}#{@old_name}"
97
+ end
98
+
99
+ ##
100
+ # New name with prefix '::' or '#'.
101
+
102
+ def pretty_new_name
103
+ "#{singleton ? '::' : '#'}#{@new_name}"
104
+ end
105
+
106
+ alias pretty_name pretty_new_name
107
+
59
108
  def to_s # :nodoc:
60
- "alias: #{self.old_name} -> #{self.new_name}\n#{self.comment}"
109
+ "alias: #{self.new_name} -> #{self.pretty_old_name} in: #{parent}"
61
110
  end
62
111
 
63
112
  end
@@ -1,29 +1,12 @@
1
- require 'rdoc/code_object'
2
- require 'rdoc/tokenstream'
1
+ require 'rdoc/method_attr'
2
+ require 'rdoc/token_stream'
3
3
 
4
4
  ##
5
5
  # AnyMethod is the base class for objects representing methods
6
6
 
7
- class RDoc::AnyMethod < RDoc::CodeObject
7
+ class RDoc::AnyMethod < RDoc::MethodAttr
8
8
 
9
- MARSHAL_VERSION = 1 # :nodoc:
10
-
11
- include Comparable
12
-
13
- ##
14
- # Method name
15
-
16
- attr_writer :name
17
-
18
- ##
19
- # public, protected, private
20
-
21
- attr_accessor :visibility
22
-
23
- ##
24
- # Parameters yielded by the called block
25
-
26
- attr_accessor :block_params
9
+ MARSHAL_VERSION = 0 # :nodoc:
27
10
 
28
11
  ##
29
12
  # Don't rename \#initialize to \::new
@@ -31,76 +14,49 @@ class RDoc::AnyMethod < RDoc::CodeObject
31
14
  attr_accessor :dont_rename_initialize
32
15
 
33
16
  ##
34
- # Is this a singleton method?
35
-
36
- attr_accessor :singleton
37
-
38
- ##
39
- # Source file token stream
40
-
41
- attr_reader :text
42
-
43
- ##
44
- # Array of other names for this method
45
-
46
- attr_reader :aliases
47
-
48
- ##
49
- # The method we're aliasing
17
+ # Different ways to call this method
50
18
 
51
- attr_accessor :is_alias_for
19
+ attr_accessor :call_seq
52
20
 
53
21
  ##
54
22
  # Parameters for this method
55
23
 
56
24
  attr_accessor :params
57
25
 
58
- ##
59
- # Different ways to call this method
60
-
61
- attr_accessor :call_seq
62
-
63
26
  include RDoc::TokenStream
64
27
 
65
- def initialize(text, name)
66
- super()
28
+ ##
29
+ # Creates a new AnyMethod with a token stream +text+ and +name+
67
30
 
68
- @text = text
69
- @name = name
31
+ def initialize text, name
32
+ super
70
33
 
71
- @aliases = []
72
- @block_params = nil
73
- @call_seq = nil
74
34
  @dont_rename_initialize = false
75
- @is_alias_for = nil
76
- @params = nil
77
- @parent_name = nil
78
- @singleton = nil
79
35
  @token_stream = nil
80
- @visibility = :public
81
36
  end
82
37
 
83
38
  ##
84
- # Order by #singleton then #name
39
+ # Adds +an_alias+ as an alias for this method in +context+.
85
40
 
86
- def <=>(other)
87
- [@singleton ? 0 : 1, @name] <=> [other.singleton ? 0 : 1, other.name]
88
- end
89
-
90
- ##
91
- # Adds +method+ as an alias for this method
41
+ def add_alias(an_alias, context)
42
+ method = self.class.new an_alias.text, an_alias.new_name
92
43
 
93
- def add_alias(method)
44
+ method.record_location an_alias.file
45
+ method.singleton = self.singleton
46
+ method.params = self.params
47
+ method.visibility = self.visibility
48
+ method.comment = an_alias.comment
49
+ method.is_alias_for = self
94
50
  @aliases << method
51
+ context.add_method method
52
+ method
95
53
  end
96
54
 
97
55
  ##
98
- # HTML fragment reference for this method
56
+ # Prefix for +aref+ is 'method'.
99
57
 
100
- def aref
101
- type = singleton ? 'c' : 'i'
102
-
103
- "method-#{type}-#{CGI.escape name}"
58
+ def aref_prefix
59
+ 'method'
104
60
  end
105
61
 
106
62
  ##
@@ -116,30 +72,6 @@ class RDoc::AnyMethod < RDoc::CodeObject
116
72
  end
117
73
  end
118
74
 
119
- ##
120
- # HTML id-friendly method name
121
-
122
- def html_name
123
- @name.gsub(/[^a-z]+/, '-')
124
- end
125
-
126
- def inspect # :nodoc:
127
- alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
128
- "#<%s:0x%x %s (%s)%s>" % [
129
- self.class, object_id,
130
- full_name,
131
- visibility,
132
- alias_for,
133
- ]
134
- end
135
-
136
- ##
137
- # Full method name including namespace
138
-
139
- def full_name
140
- @full_name ||= "#{@parent ? @parent.full_name : '(unknown)'}#{pretty_name}"
141
- end
142
-
143
75
  ##
144
76
  # Dumps this AnyMethod for use by ri. See also #marshal_load
145
77
 
@@ -192,12 +124,14 @@ class RDoc::AnyMethod < RDoc::CodeObject
192
124
  end
193
125
 
194
126
  array[8].each do |new_name, comment|
195
- add_alias RDoc::Alias.new(nil, @name, new_name, comment)
127
+ add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton)
196
128
  end
197
129
  end
198
130
 
199
131
  ##
200
132
  # Method name
133
+ #
134
+ # If the method has no assigned name, it extracts it from #call_seq.
201
135
 
202
136
  def name
203
137
  return @name if @name
@@ -229,62 +163,5 @@ class RDoc::AnyMethod < RDoc::CodeObject
229
163
  params
230
164
  end
231
165
 
232
- ##
233
- # Name of our parent with special handling for un-marshaled methods
234
-
235
- def parent_name
236
- @parent_name || super
237
- end
238
-
239
- ##
240
- # Path to this method
241
-
242
- def path
243
- "#{@parent.path}##{aref}"
244
- end
245
-
246
- ##
247
- # Method name with class/instance indicator
248
-
249
- def pretty_name
250
- "#{singleton ? '::' : '#'}#{@name}"
251
- end
252
-
253
- def pretty_print q # :nodoc:
254
- alias_for = @is_alias_for ? "alias for #{@is_alias_for.name}" : nil
255
-
256
- q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
257
- if alias_for then
258
- q.breakable
259
- q.text alias_for
260
- end
261
-
262
- if text then
263
- q.breakable
264
- q.text "text:"
265
- q.breakable
266
- q.pp @text
267
- end
268
-
269
- unless comment.empty? then
270
- q.breakable
271
- q.text "comment:"
272
- q.breakable
273
- q.pp @comment
274
- end
275
- end
276
- end
277
-
278
- def to_s # :nodoc:
279
- "#{self.class.name}: #{full_name} (#{@text})\n#{@comment}"
280
- end
281
-
282
- ##
283
- # Type of method (class or instance)
284
-
285
- def type
286
- singleton ? 'class' : 'instance'
287
- end
288
-
289
166
  end
290
167
 
@@ -1,113 +1,71 @@
1
- require 'rdoc/code_object'
1
+ require 'rdoc/method_attr'
2
2
 
3
3
  ##
4
4
  # An attribute created by \#attr, \#attr_reader, \#attr_writer or
5
5
  # \#attr_accessor
6
6
 
7
- class RDoc::Attr < RDoc::CodeObject
7
+ class RDoc::Attr < RDoc::MethodAttr
8
8
 
9
- MARSHAL_VERSION = 0 # :nodoc:
9
+ MARSHAL_VERSION = 1 # :nodoc:
10
10
 
11
11
  ##
12
- # Name of the attribute
13
-
14
- attr_accessor :name
15
-
16
- ##
17
- # Is the attribute readable, writable or both?
12
+ # Is the attribute readable ('R'), writable ('W') or both ('RW')?
18
13
 
19
14
  attr_accessor :rw
20
15
 
21
16
  ##
22
- # Source file token stream
17
+ # Creates a new Attr with body +text+, +name+, read/write status +rw+ and
18
+ # +comment+. +singleton+ marks this as a class attribute.
23
19
 
24
- attr_accessor :text
20
+ def initialize(text, name, rw, comment, singleton = false)
21
+ super text, name
25
22
 
26
- ##
27
- # public, protected, private
28
-
29
- attr_accessor :visibility
30
-
31
- def initialize(text, name, rw, comment)
32
- super()
33
- @text = text
34
- @name = name
35
23
  @rw = rw
36
- @visibility = :public
24
+ @singleton = singleton
37
25
  self.comment = comment
38
26
  end
39
27
 
40
28
  ##
41
- # Attributes are ordered by name
42
-
43
- def <=>(other)
44
- self.name <=> other.name
45
- end
46
-
47
- ##
48
- # Attributes are equal when their names and rw is identical
29
+ # Attributes are equal when their names, singleton and rw are identical
49
30
 
50
31
  def == other
51
32
  self.class == other.class and
52
33
  self.name == other.name and
53
- self.rw == other.rw
34
+ self.rw == other.rw and
35
+ self.singleton == other.singleton
54
36
  end
55
37
 
56
38
  ##
57
- # HTML fragment reference for this attr
58
-
59
- def aref
60
- type = singleton ? 'c' : 'i'
39
+ # Add +an_alias+ as an attribute in +context+.
61
40
 
62
- "attribute-#{type}-#{CGI.escape name}"
63
- end
64
-
65
- ##
66
- # Returns nil, for duck typing with RDoc::AnyMethod
41
+ def add_alias(an_alias, context)
42
+ new_attr = self.class.new(self.text, an_alias.new_name, self.rw,
43
+ self.comment, self.singleton)
67
44
 
68
- def arglists
45
+ new_attr.record_location an_alias.file
46
+ new_attr.visibility = self.visibility
47
+ new_attr.is_alias_for = self
48
+ @aliases << new_attr
49
+ context.add_attribute new_attr
50
+ new_attr
69
51
  end
70
52
 
71
53
  ##
72
- # Returns nil, for duck typing with RDoc::AnyMethod
54
+ # The #aref prefix for attributes
73
55
 
74
- def block_params
56
+ def aref_prefix
57
+ 'attribute'
75
58
  end
76
59
 
77
60
  ##
78
- # Returns nil, for duck typing with RDoc::AnyMethod
61
+ # Returns attr_reader, attr_writer or attr_accessor as appropriate.
79
62
 
80
- def call_seq
81
- end
82
-
83
- ##
84
- # Partially bogus as Attr has no parent. For duck typing with
85
- # RDoc::AnyMethod.
86
-
87
- def full_name
88
- @full_name ||= "#{@parent ? @parent.full_name : '(unknown)'}##{name}"
89
- end
90
-
91
- ##
92
- # An HTML id-friendly representation of #name
93
-
94
- def html_name
95
- @name.gsub(/[^a-z]+/, '-')
96
- end
97
-
98
- def inspect # :nodoc:
99
- attr = case rw
100
- when 'RW' then :attr_accessor
101
- when 'R' then :attr_reader
102
- when 'W' then :attr_writer
103
- else
104
- " (#{rw})"
105
- end
106
-
107
- "#<%s:0x%x %s.%s :%s>" % [
108
- self.class, object_id,
109
- parent_name, attr, @name,
110
- ]
63
+ def definition
64
+ case @rw
65
+ when 'RW' then 'attr_accessor'
66
+ when 'R' then 'attr_reader'
67
+ when 'W' then 'attr_writer'
68
+ end
111
69
  end
112
70
 
113
71
  ##
@@ -120,11 +78,12 @@ class RDoc::Attr < RDoc::CodeObject
120
78
  @rw,
121
79
  @visibility,
122
80
  parse(@comment),
81
+ singleton,
123
82
  ]
124
83
  end
125
84
 
126
85
  ##
127
- # Loads this AnyMethod from +array+. For a loaded AnyMethod the following
86
+ # Loads this Attr from +array+. For a loaded Attr the following
128
87
  # methods will return cached values:
129
88
  #
130
89
  # * #full_name
@@ -136,51 +95,13 @@ class RDoc::Attr < RDoc::CodeObject
136
95
  @rw = array[3]
137
96
  @visibility = array[4]
138
97
  @comment = array[5]
98
+ @singleton = array[6] || false # MARSHAL_VERSION == 0
139
99
 
140
100
  @parent_name = @full_name
141
101
  end
142
102
 
143
- ##
144
- # Name of our parent with special handling for un-marshaled methods
145
-
146
- def parent_name
147
- @parent_name || super
148
- end
149
-
150
- ##
151
- # For duck typing with RDoc::AnyMethod, returns nil
152
-
153
- def params
154
- nil
155
- end
156
-
157
- ##
158
- # URL path for this attribute
159
-
160
- def path
161
- "#{@parent.path}##{@name}"
162
- end
163
-
164
- ##
165
- # For duck typing with RDoc::AnyMethod
166
-
167
- def singleton
168
- false
169
- end
170
-
171
103
  def to_s # :nodoc:
172
- "#{type} #{name}\n#{comment}"
173
- end
174
-
175
- ##
176
- # Returns attr_reader, attr_writer or attr_accessor as appropriate
177
-
178
- def type
179
- case @rw
180
- when 'RW' then 'attr_accessor'
181
- when 'R' then 'attr_reader'
182
- when 'W' then 'attr_writer'
183
- end
104
+ "#{definition} #{name} in: #{parent}"
184
105
  end
185
106
 
186
107
  end