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.
- data.tar.gz.sig +0 -0
- data/.document +1 -0
- data/History.txt +95 -0
- data/Manifest.txt +13 -4
- data/README.txt +9 -3
- data/Rakefile +1 -1
- data/lib/rdoc.rb +15 -298
- data/lib/rdoc/alias.rb +65 -16
- data/lib/rdoc/any_method.rb +27 -150
- data/lib/rdoc/attr.rb +36 -115
- data/lib/rdoc/class_module.rb +236 -22
- data/lib/rdoc/code_object.rb +76 -31
- data/lib/rdoc/constant.rb +32 -4
- data/lib/rdoc/context.rb +494 -222
- data/lib/rdoc/encoding.rb +79 -0
- data/lib/rdoc/erbio.rb +37 -0
- data/lib/rdoc/gauntlet.rb +9 -5
- data/lib/rdoc/generator.rb +33 -1
- data/lib/rdoc/generator/darkfish.rb +284 -375
- data/lib/rdoc/generator/markup.rb +72 -36
- data/lib/rdoc/generator/ri.rb +4 -4
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +267 -274
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +91 -91
- data/lib/rdoc/generator/template/darkfish/index.rhtml +45 -45
- data/lib/rdoc/generator/template/darkfish/rdoc.css +298 -298
- data/lib/rdoc/include.rb +40 -1
- data/lib/rdoc/known_classes.rb +1 -0
- data/lib/rdoc/markup.rb +467 -2
- data/lib/rdoc/markup/attribute_manager.rb +24 -6
- data/lib/rdoc/markup/blank_line.rb +11 -3
- data/lib/rdoc/markup/document.rb +6 -0
- data/lib/rdoc/markup/formatter.rb +10 -0
- data/lib/rdoc/markup/formatter_test_case.rb +339 -3
- data/lib/rdoc/markup/heading.rb +3 -0
- data/lib/rdoc/markup/inline.rb +11 -1
- data/lib/rdoc/markup/list.rb +3 -0
- data/lib/rdoc/markup/list_item.rb +3 -0
- data/lib/rdoc/markup/paragraph.rb +3 -0
- data/lib/rdoc/markup/parser.rb +191 -237
- data/lib/rdoc/markup/{preprocess.rb → pre_process.rb} +50 -29
- data/lib/rdoc/markup/raw.rb +4 -0
- data/lib/rdoc/markup/rule.rb +3 -0
- data/lib/rdoc/markup/text_formatter_test_case.rb +116 -0
- data/lib/rdoc/markup/to_ansi.rb +14 -2
- data/lib/rdoc/markup/to_bs.rb +8 -2
- data/lib/rdoc/markup/to_html.rb +84 -91
- data/lib/rdoc/markup/to_html_crossref.rb +77 -26
- data/lib/rdoc/markup/to_rdoc.rb +94 -49
- data/lib/rdoc/markup/to_test.rb +9 -1
- data/lib/rdoc/markup/verbatim.rb +6 -3
- data/lib/rdoc/method_attr.rb +353 -0
- data/lib/rdoc/normal_class.rb +11 -2
- data/lib/rdoc/normal_module.rb +0 -5
- data/lib/rdoc/options.rb +373 -82
- data/lib/rdoc/parser.rb +59 -23
- data/lib/rdoc/parser/c.rb +224 -86
- data/lib/rdoc/parser/ruby.rb +219 -111
- data/lib/rdoc/parser/ruby_tools.rb +4 -1
- data/lib/rdoc/parser/simple.rb +9 -4
- data/lib/rdoc/rdoc.rb +68 -28
- data/lib/rdoc/require.rb +21 -0
- data/lib/rdoc/ri/driver.rb +20 -10
- data/lib/rdoc/ri/paths.rb +2 -2
- data/lib/rdoc/ri/store.rb +22 -5
- data/lib/rdoc/ruby_lex.rb +11 -12
- data/lib/rdoc/ruby_token.rb +2 -2
- data/lib/rdoc/single_class.rb +2 -1
- data/lib/rdoc/stats.rb +202 -162
- data/lib/rdoc/stats/normal.rb +51 -0
- data/lib/rdoc/stats/quiet.rb +59 -0
- data/lib/rdoc/stats/verbose.rb +45 -0
- data/lib/rdoc/text.rb +133 -4
- data/lib/rdoc/{tokenstream.rb → token_stream.rb} +0 -2
- data/lib/rdoc/top_level.rb +230 -39
- data/test/test_attribute_manager.rb +58 -7
- data/test/test_rdoc_alias.rb +13 -0
- data/test/test_rdoc_any_method.rb +43 -2
- data/test/test_rdoc_attr.rb +15 -8
- data/test/test_rdoc_class_module.rb +133 -0
- data/test/test_rdoc_code_object.rb +62 -5
- data/test/test_rdoc_context.rb +72 -26
- data/test/test_rdoc_encoding.rb +145 -0
- data/test/test_rdoc_generator_darkfish.rb +119 -0
- data/test/test_rdoc_generator_ri.rb +22 -2
- data/test/test_rdoc_include.rb +79 -0
- data/test/test_rdoc_markup_attribute_manager.rb +4 -4
- data/test/test_rdoc_markup_parser.rb +134 -95
- data/test/test_rdoc_markup_pre_process.rb +7 -2
- data/test/test_rdoc_markup_to_ansi.rb +43 -153
- data/test/test_rdoc_markup_to_bs.rb +42 -156
- data/test/test_rdoc_markup_to_html.rb +130 -58
- data/test/test_rdoc_markup_to_html_crossref.rb +10 -10
- data/test/test_rdoc_markup_to_rdoc.rb +40 -151
- data/test/test_rdoc_method_attr.rb +122 -0
- data/test/test_rdoc_normal_class.rb +1 -1
- data/test/test_rdoc_normal_module.rb +6 -1
- data/test/test_rdoc_options.rb +237 -12
- data/test/test_rdoc_parser.rb +3 -22
- data/test/test_rdoc_parser_c.rb +203 -2
- data/test/test_rdoc_parser_ruby.rb +403 -89
- data/test/test_rdoc_parser_simple.rb +25 -1
- data/test/test_rdoc_rdoc.rb +44 -32
- data/test/test_rdoc_ri_driver.rb +29 -24
- data/test/test_rdoc_ri_store.rb +46 -3
- data/test/test_rdoc_task.rb +1 -1
- data/test/test_rdoc_text.rb +102 -8
- data/test/test_rdoc_top_level.rb +13 -4
- data/test/xref_data.rb +8 -0
- data/test/xref_test_case.rb +6 -0
- metadata +29 -19
- metadata.gz.sig +0 -0
- data/lib/rdoc/parser/perl.rb +0 -165
- data/test/test_rdoc_parser_perl.rb +0 -73
data/lib/rdoc/alias.rb
CHANGED
@@ -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
|
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
|
-
#
|
13
|
+
# Aliased method's name
|
13
14
|
|
14
|
-
|
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
|
-
|
22
|
+
attr_reader :old_name
|
25
23
|
|
26
24
|
##
|
27
|
-
# Is this a
|
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
|
-
|
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
|
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
|
-
|
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.
|
109
|
+
"alias: #{self.new_name} -> #{self.pretty_old_name} in: #{parent}"
|
61
110
|
end
|
62
111
|
|
63
112
|
end
|
data/lib/rdoc/any_method.rb
CHANGED
@@ -1,29 +1,12 @@
|
|
1
|
-
require 'rdoc/
|
2
|
-
require 'rdoc/
|
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::
|
7
|
+
class RDoc::AnyMethod < RDoc::MethodAttr
|
8
8
|
|
9
|
-
MARSHAL_VERSION =
|
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
|
-
#
|
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 :
|
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
|
-
|
66
|
-
|
28
|
+
##
|
29
|
+
# Creates a new AnyMethod with a token stream +text+ and +name+
|
67
30
|
|
68
|
-
|
69
|
-
|
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
|
-
#
|
39
|
+
# Adds +an_alias+ as an alias for this method in +context+.
|
85
40
|
|
86
|
-
def
|
87
|
-
|
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
|
-
|
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
|
-
#
|
56
|
+
# Prefix for +aref+ is 'method'.
|
99
57
|
|
100
|
-
def
|
101
|
-
|
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
|
|
data/lib/rdoc/attr.rb
CHANGED
@@ -1,113 +1,71 @@
|
|
1
|
-
require 'rdoc/
|
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::
|
7
|
+
class RDoc::Attr < RDoc::MethodAttr
|
8
8
|
|
9
|
-
MARSHAL_VERSION =
|
9
|
+
MARSHAL_VERSION = 1 # :nodoc:
|
10
10
|
|
11
11
|
##
|
12
|
-
#
|
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
|
-
#
|
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
|
-
|
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
|
-
@
|
24
|
+
@singleton = singleton
|
37
25
|
self.comment = comment
|
38
26
|
end
|
39
27
|
|
40
28
|
##
|
41
|
-
# Attributes are
|
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
|
-
#
|
58
|
-
|
59
|
-
def aref
|
60
|
-
type = singleton ? 'c' : 'i'
|
39
|
+
# Add +an_alias+ as an attribute in +context+.
|
61
40
|
|
62
|
-
|
63
|
-
|
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
|
-
|
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
|
-
#
|
54
|
+
# The #aref prefix for attributes
|
73
55
|
|
74
|
-
def
|
56
|
+
def aref_prefix
|
57
|
+
'attribute'
|
75
58
|
end
|
76
59
|
|
77
60
|
##
|
78
|
-
# Returns
|
61
|
+
# Returns attr_reader, attr_writer or attr_accessor as appropriate.
|
79
62
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
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
|
-
"#{
|
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
|