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
@@ -0,0 +1,51 @@
|
|
1
|
+
##
|
2
|
+
# Stats printer that prints just the files being documented with a progress
|
3
|
+
# bar
|
4
|
+
|
5
|
+
class RDoc::Stats::Normal < RDoc::Stats::Quiet
|
6
|
+
|
7
|
+
def begin_adding # :nodoc:
|
8
|
+
puts "Parsing sources..."
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# Prints a file with a progress bar
|
13
|
+
|
14
|
+
def print_file files_so_far, filename
|
15
|
+
progress_bar = sprintf("%3d%% [%2d/%2d] ",
|
16
|
+
100 * files_so_far / @num_files,
|
17
|
+
files_so_far,
|
18
|
+
@num_files)
|
19
|
+
|
20
|
+
if $stdout.tty? then
|
21
|
+
# Print a progress bar, but make sure it fits on a single line. Filename
|
22
|
+
# will be truncated if necessary.
|
23
|
+
terminal_width = (ENV['COLUMNS'] || 80).to_i
|
24
|
+
max_filename_size = terminal_width - progress_bar.size
|
25
|
+
|
26
|
+
if filename.size > max_filename_size then
|
27
|
+
# Turn "some_long_filename.rb" to "...ong_filename.rb"
|
28
|
+
filename = filename[(filename.size - max_filename_size) .. -1]
|
29
|
+
filename[0..2] = "..."
|
30
|
+
end
|
31
|
+
|
32
|
+
# Pad the line with whitespaces so that leftover output from the
|
33
|
+
# previous line doesn't show up.
|
34
|
+
line = "#{progress_bar}#{filename}"
|
35
|
+
padding = terminal_width - line.size
|
36
|
+
line << (" " * padding) if padding > 0
|
37
|
+
|
38
|
+
$stdout.print("#{line}\r")
|
39
|
+
else
|
40
|
+
$stdout.puts "#{progress_bar} #{filename}"
|
41
|
+
end
|
42
|
+
|
43
|
+
$stdout.flush
|
44
|
+
end
|
45
|
+
|
46
|
+
def done_adding # :nodoc:
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
##
|
2
|
+
# Stats printer that prints nothing
|
3
|
+
|
4
|
+
class RDoc::Stats::Quiet
|
5
|
+
|
6
|
+
##
|
7
|
+
# Creates a new Quiet that will print nothing
|
8
|
+
|
9
|
+
def initialize num_files
|
10
|
+
@num_files = num_files
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Prints a message at the beginning of parsing
|
15
|
+
|
16
|
+
def begin_adding(*) end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Prints when an alias is added
|
20
|
+
|
21
|
+
def print_alias(*) end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Prints when an attribute is added
|
25
|
+
|
26
|
+
def print_attribute(*) end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Prints when a class is added
|
30
|
+
|
31
|
+
def print_class(*) end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Prints when a constant is added
|
35
|
+
|
36
|
+
def print_constant(*) end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Prints when a file is added
|
40
|
+
|
41
|
+
def print_file(*) end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Prints when a method is added
|
45
|
+
|
46
|
+
def print_method(*) end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Prints when a module is added
|
50
|
+
|
51
|
+
def print_module(*) end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Prints when RDoc is done
|
55
|
+
|
56
|
+
def done_adding(*) end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
##
|
2
|
+
# Stats printer that prints everything documented, including the documented
|
3
|
+
# status
|
4
|
+
|
5
|
+
class RDoc::Stats::Verbose < RDoc::Stats::Normal
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns a marker for RDoc::CodeObject +co+ being undocumented
|
9
|
+
|
10
|
+
def nodoc co
|
11
|
+
" (undocumented)" unless co.documented?
|
12
|
+
end
|
13
|
+
|
14
|
+
def print_alias as # :nodoc:
|
15
|
+
puts " alias #{as.new_name} #{as.old_name}#{nodoc as}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_attribute attribute # :nodoc:
|
19
|
+
puts " #{attribute.definition} #{attribute.name}#{nodoc attribute}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def print_class(klass) # :nodoc:
|
23
|
+
puts " class #{klass.full_name}#{nodoc klass}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_constant(constant) # :nodoc:
|
27
|
+
puts " #{constant.name}#{nodoc constant}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_file(files_so_far, file) # :nodoc:
|
31
|
+
super
|
32
|
+
puts
|
33
|
+
end
|
34
|
+
|
35
|
+
def print_method(method) # :nodoc:
|
36
|
+
puts " #{method.singleton ? '::' : '#'}#{method.name}#{nodoc method}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def print_module(mod) # :nodoc:
|
40
|
+
puts " module #{mod.full_name}#{nodoc mod}"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
data/lib/rdoc/text.rb
CHANGED
@@ -1,8 +1,43 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# For RDoc::Text#to_html
|
5
|
+
|
6
|
+
require 'strscan'
|
7
|
+
|
1
8
|
##
|
2
9
|
# Methods for manipulating comment text
|
3
10
|
|
4
11
|
module RDoc::Text
|
5
12
|
|
13
|
+
##
|
14
|
+
# Maps an encoding to a Hash of characters properly transcoded for that
|
15
|
+
# encoding.
|
16
|
+
#
|
17
|
+
# See also encode_fallback.
|
18
|
+
|
19
|
+
TO_HTML_CHARACTERS = Hash.new do |h, encoding|
|
20
|
+
h[encoding] = {
|
21
|
+
:close_dquote => encode_fallback('”', encoding, '"'),
|
22
|
+
:close_squote => encode_fallback('’', encoding, '\''),
|
23
|
+
:copyright => encode_fallback('©', encoding, '(c)'),
|
24
|
+
:ellipsis => encode_fallback('…', encoding, '...'),
|
25
|
+
:em_dash => encode_fallback('—', encoding, '---'),
|
26
|
+
:en_dash => encode_fallback('–', encoding, '--'),
|
27
|
+
:open_dquote => encode_fallback('“', encoding, '"'),
|
28
|
+
:open_squote => encode_fallback('‘', encoding, '\''),
|
29
|
+
:trademark => encode_fallback('®', encoding, '(r)'),
|
30
|
+
}
|
31
|
+
end if Object.const_defined? :Encoding
|
32
|
+
|
33
|
+
##
|
34
|
+
# Transcodes +character+ to +encoding+ with a +fallback+ character.
|
35
|
+
|
36
|
+
def self.encode_fallback character, encoding, fallback
|
37
|
+
character.encode(encoding, :fallback => { character => fallback },
|
38
|
+
:undef => :replace, :replace => fallback)
|
39
|
+
end
|
40
|
+
|
6
41
|
##
|
7
42
|
# Expands tab characters in +text+ to eight spaces
|
8
43
|
|
@@ -43,8 +78,7 @@ module RDoc::Text
|
|
43
78
|
end
|
44
79
|
|
45
80
|
##
|
46
|
-
# Convert a string in markup format into HTML.
|
47
|
-
# tags if +remove_para+ is true.
|
81
|
+
# Convert a string in markup format into HTML.
|
48
82
|
#
|
49
83
|
# Requires the including class to implement #formatter
|
50
84
|
|
@@ -105,7 +139,7 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
|
|
105
139
|
|
106
140
|
def strip_hashes text
|
107
141
|
return text if text =~ /^(?>\s*)[^\#]/
|
108
|
-
text.gsub(/^\s*(#+)/) { $1.tr '#',' ' }
|
142
|
+
text.gsub(/^\s*(#+)/) { $1.tr '#',' ' }.gsub(/^\s+$/, '')
|
109
143
|
end
|
110
144
|
|
111
145
|
##
|
@@ -123,7 +157,102 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
|
|
123
157
|
text.sub! %r%/\*+% do " " * $&.length end
|
124
158
|
text.sub! %r%\*+/% do " " * $&.length end
|
125
159
|
text.gsub! %r%^[ \t]*\*%m do " " * $&.length end
|
126
|
-
text
|
160
|
+
text.gsub(/^\s+$/, '')
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Converts ampersand, dashes, ellipsis, quotes, copyright and registered
|
165
|
+
# trademark symbols in +text+ to properly encoded characters.
|
166
|
+
|
167
|
+
def to_html text
|
168
|
+
if Object.const_defined? :Encoding then
|
169
|
+
html = ''.encode text.encoding
|
170
|
+
|
171
|
+
encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
|
172
|
+
else
|
173
|
+
html = ''
|
174
|
+
encoded = {
|
175
|
+
:close_dquote => '”',
|
176
|
+
:close_squote => '’',
|
177
|
+
:copyright => '©',
|
178
|
+
:ellipsis => '…',
|
179
|
+
:em_dash => '—',
|
180
|
+
:en_dash => '–',
|
181
|
+
:open_dquote => '“',
|
182
|
+
:open_squote => '‘',
|
183
|
+
:trademark => '®',
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
s = StringScanner.new text
|
188
|
+
insquotes = false
|
189
|
+
indquotes = false
|
190
|
+
after_word = nil
|
191
|
+
|
192
|
+
until s.eos? do
|
193
|
+
case
|
194
|
+
when s.scan(/<tt>.*?<\/tt>/) then # skip contents of tt
|
195
|
+
html << s.matched.gsub('\\\\', '\\')
|
196
|
+
when s.scan(/<tt>.*?/) then
|
197
|
+
warn 'mismatched <tt> tag' # TODO signal file/line
|
198
|
+
html << s.matched
|
199
|
+
when s.scan(/<[^>]+\/?s*>/) then # skip HTML tags
|
200
|
+
html << s.matched
|
201
|
+
when s.scan(/\\(\S)/) then # unhandled suppressed crossref
|
202
|
+
html << s[1]
|
203
|
+
after_word = nil
|
204
|
+
when s.scan(/\.\.\.(\.?)/) then
|
205
|
+
html << s[1] << encoded[:ellipsis]
|
206
|
+
after_word = nil
|
207
|
+
when s.scan(/\(c\)/) then
|
208
|
+
html << encoded[:copyright]
|
209
|
+
after_word = nil
|
210
|
+
when s.scan(/\(r\)/) then
|
211
|
+
html << encoded[:trademark]
|
212
|
+
after_word = nil
|
213
|
+
when s.scan(/---/) then
|
214
|
+
html << encoded[:em_dash]
|
215
|
+
after_word = nil
|
216
|
+
when s.scan(/--/) then
|
217
|
+
html << encoded[:en_dash]
|
218
|
+
after_word = nil
|
219
|
+
when s.scan(/"|"/) then
|
220
|
+
html << encoded[indquotes ? :close_dquote : :open_dquote]
|
221
|
+
indquotes = !indquotes
|
222
|
+
after_word = nil
|
223
|
+
when s.scan(/``/) then # backtick double quote
|
224
|
+
html << encoded[:open_dquote]
|
225
|
+
after_word = nil
|
226
|
+
when s.scan(/''/) then # tick double quote
|
227
|
+
html << encoded[:close_dquote]
|
228
|
+
after_word = nil
|
229
|
+
when s.scan(/'/) then # single quote
|
230
|
+
if insquotes
|
231
|
+
html << encoded[:close_squote]
|
232
|
+
insquotes = false
|
233
|
+
elsif after_word
|
234
|
+
# Mary's dog, my parents' house: do not start paired quotes
|
235
|
+
html << encoded[:close_squote]
|
236
|
+
else
|
237
|
+
html << encoded[:open_squote]
|
238
|
+
insquotes = true
|
239
|
+
end
|
240
|
+
|
241
|
+
after_word = nil
|
242
|
+
else # advance to the next potentially significant character
|
243
|
+
match = s.scan(/.+?(?=[<\\.("'`&-])/) #"
|
244
|
+
|
245
|
+
if match then
|
246
|
+
html << match
|
247
|
+
after_word = match =~ /\w$/
|
248
|
+
else
|
249
|
+
html << s.rest
|
250
|
+
break
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
html
|
127
256
|
end
|
128
257
|
|
129
258
|
end
|
data/lib/rdoc/top_level.rb
CHANGED
@@ -20,7 +20,14 @@ class RDoc::TopLevel < RDoc::Context
|
|
20
20
|
|
21
21
|
attr_accessor :absolute_name
|
22
22
|
|
23
|
-
|
23
|
+
##
|
24
|
+
# All the classes or modules that were declared in
|
25
|
+
# this file. These are assigned to either +#classes_hash+
|
26
|
+
# or +#modules_hash+ once we know what they really are.
|
27
|
+
|
28
|
+
attr_reader :classes_or_modules
|
29
|
+
|
30
|
+
attr_accessor :diagram # :nodoc:
|
24
31
|
|
25
32
|
##
|
26
33
|
# The parser that processed this file
|
@@ -28,45 +35,110 @@ class RDoc::TopLevel < RDoc::Context
|
|
28
35
|
attr_accessor :parser
|
29
36
|
|
30
37
|
##
|
31
|
-
# Returns all classes
|
38
|
+
# Returns all classes discovered by RDoc
|
32
39
|
|
33
|
-
def self.
|
34
|
-
|
40
|
+
def self.all_classes
|
41
|
+
@all_classes_hash.values
|
35
42
|
end
|
36
43
|
|
37
44
|
##
|
38
|
-
# Returns all classes discovered by RDoc
|
45
|
+
# Returns all classes and modules discovered by RDoc
|
39
46
|
|
40
|
-
def self.
|
41
|
-
|
47
|
+
def self.all_classes_and_modules
|
48
|
+
@all_classes_hash.values + @all_modules_hash.values
|
42
49
|
end
|
43
50
|
|
44
51
|
##
|
45
52
|
# Hash of all classes known to RDoc
|
46
53
|
|
47
|
-
def self.
|
48
|
-
@
|
54
|
+
def self.all_classes_hash
|
55
|
+
@all_classes_hash
|
49
56
|
end
|
50
57
|
|
51
58
|
##
|
52
59
|
# All TopLevels known to RDoc
|
53
60
|
|
54
|
-
def self.
|
55
|
-
@
|
61
|
+
def self.all_files
|
62
|
+
@all_files_hash.values
|
56
63
|
end
|
57
64
|
|
58
65
|
##
|
59
66
|
# Hash of all files known to RDoc
|
60
67
|
|
61
|
-
def self.
|
62
|
-
@
|
68
|
+
def self.all_files_hash
|
69
|
+
@all_files_hash
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Returns all modules discovered by RDoc
|
74
|
+
|
75
|
+
def self.all_modules
|
76
|
+
all_modules_hash.values
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Hash of all modules known to RDoc
|
81
|
+
|
82
|
+
def self.all_modules_hash
|
83
|
+
@all_modules_hash
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Prepares the RDoc code object tree for use by a generator.
|
88
|
+
#
|
89
|
+
# It finds unique classes/modules defined, and replaces classes/modules that
|
90
|
+
# are aliases for another one by a copy with RDoc::ClassModule#is_alias_for
|
91
|
+
# set.
|
92
|
+
#
|
93
|
+
# It updates the RDoc::ClassModule#constant_aliases attribute of "real"
|
94
|
+
# classes or modules.
|
95
|
+
#
|
96
|
+
# It also completely removes the classes and modules that should be removed
|
97
|
+
# from the documentation and the methods that have a visibility below
|
98
|
+
# +min_visibility+, which is the <tt>--visibility</tt> option.
|
99
|
+
#
|
100
|
+
# See also RDoc::Context#remove_from_documentation?
|
101
|
+
|
102
|
+
def self.complete min_visibility
|
103
|
+
fix_basic_object_inheritance
|
104
|
+
|
105
|
+
# cache included modules before they are removed from the documentation
|
106
|
+
all_classes_and_modules.each { |cm| cm.ancestors }
|
107
|
+
|
108
|
+
remove_nodoc @all_classes_hash
|
109
|
+
remove_nodoc @all_modules_hash
|
110
|
+
|
111
|
+
@unique_classes = find_unique @all_classes_hash
|
112
|
+
@unique_modules = find_unique @all_modules_hash
|
113
|
+
|
114
|
+
unique_classes_and_modules.each do |cm|
|
115
|
+
cm.complete min_visibility
|
116
|
+
end
|
117
|
+
|
118
|
+
@all_files_hash.each_key do |file_name|
|
119
|
+
tl = @all_files_hash[file_name]
|
120
|
+
|
121
|
+
unless RDoc::Parser::Simple === tl.parser then
|
122
|
+
tl.modules_hash.clear
|
123
|
+
tl.classes_hash.clear
|
124
|
+
|
125
|
+
tl.classes_or_modules.each do |cm|
|
126
|
+
name = cm.full_name
|
127
|
+
if cm.type == 'class' then
|
128
|
+
tl.classes_hash[name] = cm if @all_classes_hash[name]
|
129
|
+
else
|
130
|
+
tl.modules_hash[name] = cm if @all_modules_hash[name]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
63
135
|
end
|
64
136
|
|
65
137
|
##
|
66
138
|
# Finds the class with +name+ in all discovered classes
|
67
139
|
|
68
140
|
def self.find_class_named(name)
|
69
|
-
|
141
|
+
@all_classes_hash[name]
|
70
142
|
end
|
71
143
|
|
72
144
|
##
|
@@ -91,9 +163,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
91
163
|
# Finds the class or module with +name+
|
92
164
|
|
93
165
|
def self.find_class_or_module(name)
|
94
|
-
name =~ /^::/
|
95
|
-
name = $' || name
|
96
|
-
|
166
|
+
name = $' if name =~ /^::/
|
97
167
|
RDoc::TopLevel.classes_hash[name] || RDoc::TopLevel.modules_hash[name]
|
98
168
|
end
|
99
169
|
|
@@ -101,7 +171,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
101
171
|
# Finds the file with +name+ in all discovered files
|
102
172
|
|
103
173
|
def self.find_file_named(name)
|
104
|
-
@
|
174
|
+
@all_files_hash[name]
|
105
175
|
end
|
106
176
|
|
107
177
|
##
|
@@ -112,26 +182,98 @@ class RDoc::TopLevel < RDoc::Context
|
|
112
182
|
end
|
113
183
|
|
114
184
|
##
|
115
|
-
#
|
185
|
+
# Finds unique classes/modules defined in +all_hash+,
|
186
|
+
# and returns them as an array. Performs the alias
|
187
|
+
# updates in +all_hash+: see ::complete.
|
188
|
+
#--
|
189
|
+
# TODO aliases should be registered by Context#add_module_alias
|
116
190
|
|
117
|
-
def self.
|
118
|
-
|
191
|
+
def self.find_unique(all_hash)
|
192
|
+
unique = []
|
193
|
+
|
194
|
+
all_hash.each_pair do |full_name, cm|
|
195
|
+
unique << cm if full_name == cm.full_name
|
196
|
+
end
|
197
|
+
|
198
|
+
unique
|
119
199
|
end
|
120
200
|
|
121
201
|
##
|
122
|
-
#
|
202
|
+
# Fixes the erroneous <tt>BasicObject < Object</tt> in 1.9.
|
203
|
+
#
|
204
|
+
# Because we assumed all classes without a stated superclass
|
205
|
+
# inherit from Object, we have the above wrong inheritance.
|
206
|
+
#
|
207
|
+
# We fix BasicObject right away if we are running in a Ruby
|
208
|
+
# version >= 1.9. If not, we may be documenting 1.9 source
|
209
|
+
# while running under 1.8: we search the files of BasicObject
|
210
|
+
# for "object.c", and fix the inheritance if we find it.
|
211
|
+
|
212
|
+
def self.fix_basic_object_inheritance
|
213
|
+
basic = all_classes_hash['BasicObject']
|
214
|
+
return unless basic
|
215
|
+
if RUBY_VERSION >= '1.9'
|
216
|
+
basic.superclass = nil
|
217
|
+
elsif basic.in_files.any? { |f| File.basename(f.full_name) == 'object.c' }
|
218
|
+
basic.superclass = nil
|
219
|
+
end
|
220
|
+
end
|
123
221
|
|
124
|
-
|
125
|
-
|
222
|
+
##
|
223
|
+
# Removes from +all_hash+ the contexts that are nodoc or have no content.
|
224
|
+
#
|
225
|
+
# See RDoc::Context#remove_from_documentation?
|
226
|
+
|
227
|
+
def self.remove_nodoc(all_hash)
|
228
|
+
all_hash.keys.each do |name|
|
229
|
+
context = all_hash[name]
|
230
|
+
all_hash.delete(name) if context.remove_from_documentation?
|
231
|
+
end
|
126
232
|
end
|
127
233
|
|
128
234
|
##
|
129
235
|
# Empties RDoc of stored class, module and file information
|
130
236
|
|
131
237
|
def self.reset
|
132
|
-
@
|
133
|
-
@
|
134
|
-
@
|
238
|
+
@all_classes_hash = {}
|
239
|
+
@all_modules_hash = {}
|
240
|
+
@all_files_hash = {}
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# Returns the unique classes discovered by RDoc.
|
245
|
+
#
|
246
|
+
# ::complete must have been called prior to using this method.
|
247
|
+
|
248
|
+
def self.unique_classes
|
249
|
+
@unique_classes
|
250
|
+
end
|
251
|
+
|
252
|
+
##
|
253
|
+
# Returns the unique classes and modules discovered by RDoc.
|
254
|
+
# ::complete must have been called prior to using this method.
|
255
|
+
|
256
|
+
def self.unique_classes_and_modules
|
257
|
+
@unique_classes + @unique_modules
|
258
|
+
end
|
259
|
+
|
260
|
+
##
|
261
|
+
# Returns the unique modules discovered by RDoc.
|
262
|
+
# ::complete must have been called prior to using this method.
|
263
|
+
|
264
|
+
def self.unique_modules
|
265
|
+
@unique_modules
|
266
|
+
end
|
267
|
+
|
268
|
+
class << self
|
269
|
+
alias classes all_classes
|
270
|
+
alias classes_hash all_classes_hash
|
271
|
+
|
272
|
+
alias files all_files
|
273
|
+
alias files_hash all_files_hash
|
274
|
+
|
275
|
+
alias modules all_modules
|
276
|
+
alias modules_hash all_modules_hash
|
135
277
|
end
|
136
278
|
|
137
279
|
reset
|
@@ -148,17 +290,49 @@ class RDoc::TopLevel < RDoc::Context
|
|
148
290
|
@diagram = nil
|
149
291
|
@parser = nil
|
150
292
|
|
293
|
+
@classes_or_modules = []
|
294
|
+
|
151
295
|
RDoc::TopLevel.files_hash[file_name] = self
|
152
296
|
end
|
153
297
|
|
154
298
|
##
|
155
|
-
# Adds +
|
299
|
+
# Adds +an_alias+ to +Object+ instead of +self+.
|
300
|
+
|
301
|
+
def add_alias(an_alias)
|
302
|
+
return an_alias unless @document_self
|
303
|
+
object_class.add_alias an_alias
|
304
|
+
end
|
305
|
+
|
306
|
+
##
|
307
|
+
# Adds +constant+ to +Object+ instead of +self+.
|
308
|
+
|
309
|
+
def add_constant(constant)
|
310
|
+
return constant unless @document_self
|
311
|
+
object_class.add_constant constant
|
312
|
+
end
|
313
|
+
|
314
|
+
##
|
315
|
+
# Adds +include+ to +Object+ instead of +self+.
|
316
|
+
|
317
|
+
def add_include(include)
|
318
|
+
return include unless @document_self
|
319
|
+
object_class.add_include include
|
320
|
+
end
|
321
|
+
|
322
|
+
##
|
323
|
+
# Adds +method+ to +Object+ instead of +self+.
|
156
324
|
|
157
325
|
def add_method(method)
|
158
|
-
|
159
|
-
|
326
|
+
return method unless @document_self
|
327
|
+
object_class.add_method method
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# Adds class or module +mod+. Used in the building phase
|
332
|
+
# by the ruby parser.
|
160
333
|
|
161
|
-
|
334
|
+
def add_to_classes_or_modules mod
|
335
|
+
@classes_or_modules << mod
|
162
336
|
end
|
163
337
|
|
164
338
|
##
|
@@ -168,8 +342,13 @@ class RDoc::TopLevel < RDoc::Context
|
|
168
342
|
File.basename @absolute_name
|
169
343
|
end
|
170
344
|
|
345
|
+
alias name base_name
|
346
|
+
|
171
347
|
##
|
172
|
-
# See RDoc::TopLevel
|
348
|
+
# See RDoc::TopLevel::find_class_or_module
|
349
|
+
#--
|
350
|
+
# TODO Why do we search through all classes/modules found, not just the
|
351
|
+
# ones of this instance?
|
173
352
|
|
174
353
|
def find_class_or_module name
|
175
354
|
RDoc::TopLevel.find_class_or_module name
|
@@ -186,11 +365,11 @@ class RDoc::TopLevel < RDoc::Context
|
|
186
365
|
# Finds a module or class with +name+
|
187
366
|
|
188
367
|
def find_module_named(name)
|
189
|
-
find_class_or_module(name)
|
368
|
+
find_class_or_module(name)
|
190
369
|
end
|
191
370
|
|
192
371
|
##
|
193
|
-
#
|
372
|
+
# Returns the relative name of this file
|
194
373
|
|
195
374
|
def full_name
|
196
375
|
@relative_name
|
@@ -215,16 +394,24 @@ class RDoc::TopLevel < RDoc::Context
|
|
215
394
|
end
|
216
395
|
|
217
396
|
##
|
218
|
-
#
|
397
|
+
# Time this file was last modified, if known
|
219
398
|
|
220
399
|
def last_modified
|
221
|
-
@file_stat ? file_stat.mtime
|
400
|
+
@file_stat ? file_stat.mtime : nil
|
222
401
|
end
|
223
402
|
|
224
403
|
##
|
225
|
-
#
|
226
|
-
|
227
|
-
|
404
|
+
# Returns the NormalClass "Object", creating it if not found.
|
405
|
+
#
|
406
|
+
# Records +self+ as a location in "Object".
|
407
|
+
|
408
|
+
def object_class
|
409
|
+
@object_class ||= begin
|
410
|
+
oc = self.class.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
|
411
|
+
oc.record_location self
|
412
|
+
oc
|
413
|
+
end
|
414
|
+
end
|
228
415
|
|
229
416
|
##
|
230
417
|
# Path to this file
|
@@ -244,5 +431,9 @@ class RDoc::TopLevel < RDoc::Context
|
|
244
431
|
end
|
245
432
|
end
|
246
433
|
|
434
|
+
def to_s # :nodoc:
|
435
|
+
"file #{full_name}"
|
436
|
+
end
|
437
|
+
|
247
438
|
end
|
248
439
|
|