rdoc 5.1.0 → 6.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTING.rdoc +5 -6
- data/ExampleMarkdown.md +2 -0
- data/ExampleRDoc.rdoc +2 -0
- data/History.rdoc +68 -66
- data/LEGAL.rdoc +1 -1
- data/LICENSE.rdoc +2 -0
- data/README.rdoc +18 -6
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -12
- data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +1 -2
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +83 -26
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +5 -9
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +112 -24
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +4 -5
- data/lib/rdoc/{context → code_object/context}/section.rb +13 -83
- data/lib/rdoc/{context.rb → code_object/context.rb} +69 -70
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +1 -2
- data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +1 -2
- data/lib/rdoc/{include.rb → code_object/include.rb} +1 -2
- data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +1 -2
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +22 -31
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +1 -2
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +4 -5
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +2 -3
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +6 -2
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +22 -32
- data/lib/rdoc/code_object.rb +8 -41
- data/lib/rdoc/code_objects.rb +2 -3
- data/lib/rdoc/comment.rb +48 -41
- data/lib/rdoc/cross_reference.rb +77 -33
- data/lib/rdoc/encoding.rb +50 -38
- data/lib/rdoc/erb_partial.rb +2 -3
- data/lib/rdoc/erbio.rb +4 -5
- data/lib/rdoc/generator/darkfish.rb +178 -125
- data/lib/rdoc/generator/json_index.rb +9 -22
- data/lib/rdoc/generator/markup.rb +6 -17
- data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
- data/lib/rdoc/generator/pot/po.rb +3 -3
- data/lib/rdoc/generator/pot/po_entry.rb +12 -12
- data/lib/rdoc/generator/pot.rb +4 -8
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -12
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +19 -10
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +26 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +27 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +125 -78
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +430 -339
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +13 -13
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -92
- data/lib/rdoc/generator/template/darkfish/js/search.js +35 -34
- data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +20 -18
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +32 -20
- data/lib/rdoc/generator/template/json_index/js/navigation.js +12 -49
- data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
- data/lib/rdoc/generator.rb +6 -6
- data/lib/rdoc/i18n/locale.rb +1 -1
- data/lib/rdoc/i18n/text.rb +5 -5
- data/lib/rdoc/i18n.rb +4 -4
- data/lib/rdoc/known_classes.rb +6 -5
- data/lib/rdoc/markdown/entities.rb +1 -2
- data/lib/rdoc/markdown/literals.kpeg +1 -2
- data/lib/rdoc/markdown/literals.rb +99 -50
- data/lib/rdoc/markdown.kpeg +115 -58
- data/lib/rdoc/markdown.rb +1584 -902
- data/lib/rdoc/markup/attr_changer.rb +1 -2
- data/lib/rdoc/markup/attr_span.rb +9 -4
- data/lib/rdoc/markup/attribute_manager.rb +118 -57
- data/lib/rdoc/markup/attributes.rb +7 -8
- data/lib/rdoc/markup/blank_line.rb +1 -2
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +1 -2
- data/lib/rdoc/markup/formatter.rb +44 -37
- data/lib/rdoc/markup/hard_break.rb +1 -2
- data/lib/rdoc/markup/heading.rb +11 -6
- data/lib/rdoc/markup/include.rb +1 -2
- data/lib/rdoc/markup/indented_paragraph.rb +1 -2
- data/lib/rdoc/markup/list.rb +1 -2
- data/lib/rdoc/markup/list_item.rb +1 -2
- data/lib/rdoc/markup/paragraph.rb +1 -2
- data/lib/rdoc/markup/parser.rb +90 -48
- data/lib/rdoc/markup/pre_process.rb +38 -11
- data/lib/rdoc/markup/raw.rb +1 -2
- data/lib/rdoc/markup/regexp_handling.rb +40 -0
- data/lib/rdoc/markup/rule.rb +1 -2
- data/lib/rdoc/markup/table.rb +56 -0
- data/lib/rdoc/markup/to_ansi.rb +1 -2
- data/lib/rdoc/markup/to_bs.rb +30 -5
- data/lib/rdoc/markup/to_html.rb +95 -40
- data/lib/rdoc/markup/to_html_crossref.rb +108 -43
- data/lib/rdoc/markup/to_html_snippet.rb +13 -11
- data/lib/rdoc/markup/to_joined_paragraph.rb +6 -32
- data/lib/rdoc/markup/to_label.rb +11 -12
- data/lib/rdoc/markup/to_markdown.rb +13 -14
- data/lib/rdoc/markup/to_rdoc.rb +49 -31
- data/lib/rdoc/markup/to_table_of_contents.rb +2 -2
- data/lib/rdoc/markup/to_test.rb +1 -2
- data/lib/rdoc/markup/to_tt_only.rb +3 -4
- data/lib/rdoc/markup/verbatim.rb +1 -2
- data/lib/rdoc/markup.rb +64 -694
- data/lib/rdoc/options.rb +226 -44
- data/lib/rdoc/parser/c.rb +231 -246
- data/lib/rdoc/parser/changelog.rb +169 -23
- data/lib/rdoc/parser/markdown.rb +1 -3
- data/lib/rdoc/parser/prism_ruby.rb +1092 -0
- data/lib/rdoc/parser/rd.rb +1 -2
- data/lib/rdoc/parser/ripper_state_lex.rb +302 -0
- data/lib/rdoc/parser/ruby.rb +695 -478
- data/lib/rdoc/parser/ruby_tools.rb +33 -36
- data/lib/rdoc/parser/simple.rb +4 -4
- data/lib/rdoc/parser/text.rb +1 -2
- data/lib/rdoc/parser.rb +37 -42
- data/lib/rdoc/rd/block_parser.rb +708 -57
- data/lib/rdoc/rd/block_parser.ry +15 -11
- data/lib/rdoc/rd/inline.rb +5 -6
- data/lib/rdoc/rd/inline_parser.rb +787 -140
- data/lib/rdoc/rd/inline_parser.ry +1 -1
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +72 -87
- data/lib/rdoc/ri/driver.rb +236 -152
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +4 -18
- data/lib/rdoc/ri/store.rb +1 -2
- data/lib/rdoc/ri/task.rb +2 -2
- data/lib/rdoc/ri.rb +5 -6
- data/lib/rdoc/rubygems_hook.rb +98 -20
- data/lib/rdoc/servlet.rb +30 -20
- data/lib/rdoc/stats/normal.rb +24 -18
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +1 -3
- data/lib/rdoc/stats.rb +6 -7
- data/lib/rdoc/store.rb +84 -55
- data/lib/rdoc/task.rb +35 -10
- data/lib/rdoc/text.rb +40 -27
- data/lib/rdoc/token_stream.rb +56 -34
- data/lib/rdoc/tom_doc.rb +18 -19
- data/lib/rdoc/version.rb +10 -0
- data/lib/rdoc.rb +80 -56
- data/lib/rubygems_plugin.rb +23 -0
- data/man/ri.1 +247 -0
- metadata +45 -99
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.travis.yml +0 -24
- data/Gemfile +0 -3
- data/RI.rdoc +0 -57
- data/Rakefile +0 -133
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/gauntlet_rdoc.rb +0 -82
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
- data/lib/rdoc/generator/template/json_index/.document +0 -1
- data/lib/rdoc/markup/formatter_test_case.rb +0 -764
- data/lib/rdoc/markup/inline.rb +0 -2
- data/lib/rdoc/markup/special.rb +0 -41
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
- data/lib/rdoc/ruby_lex.rb +0 -1367
- data/lib/rdoc/ruby_token.rb +0 -461
- data/lib/rdoc/test_case.rb +0 -204
- data/rdoc.gemspec +0 -57
@@ -1,4 +1,6 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'cgi/util'
|
3
|
+
|
2
4
|
##
|
3
5
|
# A section of documentation like:
|
4
6
|
#
|
@@ -34,8 +36,6 @@ class RDoc::Context::Section
|
|
34
36
|
|
35
37
|
attr_reader :title
|
36
38
|
|
37
|
-
@@sequence = "SEC00000"
|
38
|
-
|
39
39
|
##
|
40
40
|
# Creates a new section with +title+ and +comment+
|
41
41
|
|
@@ -43,9 +43,6 @@ class RDoc::Context::Section
|
|
43
43
|
@parent = parent
|
44
44
|
@title = title ? title.strip : title
|
45
45
|
|
46
|
-
@@sequence.succ!
|
47
|
-
@sequence = @@sequence.dup
|
48
|
-
|
49
46
|
@comments = []
|
50
47
|
|
51
48
|
add_comment comment
|
@@ -64,19 +61,10 @@ class RDoc::Context::Section
|
|
64
61
|
# Adds +comment+ to this section
|
65
62
|
|
66
63
|
def add_comment comment
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
case comment
|
72
|
-
when RDoc::Comment then
|
73
|
-
@comments << comment
|
74
|
-
when RDoc::Markup::Document then
|
75
|
-
@comments.concat comment.parts
|
76
|
-
when Array then
|
77
|
-
@comments.concat comment
|
78
|
-
else
|
79
|
-
raise TypeError, "unknown comment type: #{comment.inspect}"
|
64
|
+
comments = Array(comment)
|
65
|
+
comments.each do |c|
|
66
|
+
extracted_comment = extract_comment(c)
|
67
|
+
@comments << extracted_comment unless extracted_comment.empty?
|
80
68
|
end
|
81
69
|
end
|
82
70
|
|
@@ -100,10 +88,6 @@ class RDoc::Context::Section
|
|
100
88
|
|
101
89
|
def extract_comment comment
|
102
90
|
case comment
|
103
|
-
when Array then
|
104
|
-
comment.map do |c|
|
105
|
-
extract_comment c
|
106
|
-
end
|
107
91
|
when nil
|
108
92
|
RDoc::Comment.new ''
|
109
93
|
when RDoc::Comment then
|
@@ -118,8 +102,6 @@ class RDoc::Context::Section
|
|
118
102
|
end
|
119
103
|
end
|
120
104
|
|
121
|
-
comment
|
122
|
-
when RDoc::Markup::Document then
|
123
105
|
comment
|
124
106
|
else
|
125
107
|
raise TypeError, "unknown comment #{comment.inspect}"
|
@@ -138,20 +120,7 @@ class RDoc::Context::Section
|
|
138
120
|
# The files comments in this section come from
|
139
121
|
|
140
122
|
def in_files
|
141
|
-
|
142
|
-
|
143
|
-
case @comments
|
144
|
-
when Array then
|
145
|
-
@comments.map do |comment|
|
146
|
-
comment.file
|
147
|
-
end
|
148
|
-
when RDoc::Markup::Document then
|
149
|
-
@comment.parts.map do |document|
|
150
|
-
document.file
|
151
|
-
end
|
152
|
-
else
|
153
|
-
raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
|
154
|
-
end
|
123
|
+
@comments.map(&:file)
|
155
124
|
end
|
156
125
|
|
157
126
|
##
|
@@ -173,7 +142,7 @@ class RDoc::Context::Section
|
|
173
142
|
@parent = nil
|
174
143
|
|
175
144
|
@title = array[1]
|
176
|
-
@comments = array[2]
|
145
|
+
@comments = array[2].parts.map { |doc| RDoc::Comment.from_document(doc) }
|
177
146
|
end
|
178
147
|
|
179
148
|
##
|
@@ -181,26 +150,7 @@ class RDoc::Context::Section
|
|
181
150
|
# multiple RDoc::Markup::Documents with their file set.
|
182
151
|
|
183
152
|
def parse
|
184
|
-
|
185
|
-
when String then
|
186
|
-
super
|
187
|
-
when Array then
|
188
|
-
docs = @comments.map do |comment, location|
|
189
|
-
doc = super comment
|
190
|
-
doc.file = location if location
|
191
|
-
doc
|
192
|
-
end
|
193
|
-
|
194
|
-
RDoc::Markup::Document.new(*docs)
|
195
|
-
when RDoc::Comment then
|
196
|
-
doc = super @comments.text, comments.format
|
197
|
-
doc.file = @comments.location
|
198
|
-
doc
|
199
|
-
when RDoc::Markup::Document then
|
200
|
-
return @comments
|
201
|
-
else
|
202
|
-
raise ArgumentError, "unknown comment class #{comments.class}"
|
203
|
-
end
|
153
|
+
RDoc::Markup::Document.new(*@comments.map(&:parse))
|
204
154
|
end
|
205
155
|
|
206
156
|
##
|
@@ -216,30 +166,10 @@ class RDoc::Context::Section
|
|
216
166
|
# Removes a comment from this section if it is from the same file as
|
217
167
|
# +comment+
|
218
168
|
|
219
|
-
def remove_comment
|
220
|
-
|
221
|
-
|
222
|
-
case @comments
|
223
|
-
when Array then
|
224
|
-
@comments.delete_if do |my_comment|
|
225
|
-
my_comment.file == comment.file
|
226
|
-
end
|
227
|
-
when RDoc::Markup::Document then
|
228
|
-
@comments.parts.delete_if do |document|
|
229
|
-
document.file == comment.file.name
|
230
|
-
end
|
231
|
-
else
|
232
|
-
raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
|
169
|
+
def remove_comment target_comment
|
170
|
+
@comments.delete_if do |stored_comment|
|
171
|
+
stored_comment.file == target_comment.file
|
233
172
|
end
|
234
173
|
end
|
235
174
|
|
236
|
-
##
|
237
|
-
# Section sequence number (deprecated)
|
238
|
-
|
239
|
-
def sequence
|
240
|
-
warn "RDoc::Context::Section#sequence is deprecated, use #aref"
|
241
|
-
@sequence
|
242
|
-
end
|
243
|
-
|
244
175
|
end
|
245
|
-
|
@@ -1,6 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
2
|
-
require 'cgi'
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
4
2
|
##
|
5
3
|
# A Context is something that can hold modules, classes, methods, attributes,
|
6
4
|
# aliases, requires, and includes. Classes, modules, and files are all
|
@@ -239,7 +237,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
239
237
|
|
240
238
|
if known then
|
241
239
|
known.comment = attribute.comment if known.comment.empty?
|
242
|
-
elsif registered = @methods_hash[attribute.pretty_name
|
240
|
+
elsif registered = @methods_hash[attribute.pretty_name + '='] and
|
243
241
|
RDoc::Attr === registered then
|
244
242
|
registered.rw = 'RW'
|
245
243
|
else
|
@@ -249,7 +247,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
249
247
|
end
|
250
248
|
|
251
249
|
if attribute.rw.index 'W' then
|
252
|
-
key = attribute.pretty_name
|
250
|
+
key = attribute.pretty_name + '='
|
253
251
|
known = @methods_hash[key]
|
254
252
|
|
255
253
|
if known then
|
@@ -407,6 +405,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
407
405
|
mod.section = current_section # TODO declaring context? something is
|
408
406
|
# wrong here...
|
409
407
|
mod.parent = self
|
408
|
+
mod.full_name = nil
|
410
409
|
mod.store = @store
|
411
410
|
|
412
411
|
unless @done_documenting then
|
@@ -414,6 +413,10 @@ class RDoc::Context < RDoc::CodeObject
|
|
414
413
|
# this must be done AFTER adding mod to its parent, so that the full
|
415
414
|
# name is correct:
|
416
415
|
all_hash[mod.full_name] = mod
|
416
|
+
if @store.unmatched_constant_alias[mod.full_name] then
|
417
|
+
to, file = @store.unmatched_constant_alias[mod.full_name]
|
418
|
+
add_module_alias mod, mod.name, to, file
|
419
|
+
end
|
417
420
|
end
|
418
421
|
|
419
422
|
mod
|
@@ -479,7 +482,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
479
482
|
known.comment = method.comment if known.comment.empty?
|
480
483
|
previously = ", previously in #{known.file}" unless
|
481
484
|
method.file == known.file
|
482
|
-
@store.
|
485
|
+
@store.options.warn \
|
483
486
|
"Duplicate method #{known.full_name} in #{method.file}#{previously}"
|
484
487
|
end
|
485
488
|
else
|
@@ -510,41 +513,53 @@ class RDoc::Context < RDoc::CodeObject
|
|
510
513
|
add_class_or_module mod, @modules, @store.modules_hash
|
511
514
|
end
|
512
515
|
|
516
|
+
##
|
517
|
+
# Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
|
518
|
+
|
519
|
+
def add_module_by_normal_module(mod)
|
520
|
+
add_class_or_module mod, @modules, @store.modules_hash
|
521
|
+
end
|
522
|
+
|
513
523
|
##
|
514
524
|
# Adds an alias from +from+ (a class or module) to +name+ which was defined
|
515
525
|
# in +file+.
|
516
526
|
|
517
|
-
def add_module_alias from,
|
527
|
+
def add_module_alias from, from_name, to, file
|
518
528
|
return from if @done_documenting
|
519
529
|
|
520
|
-
|
530
|
+
to_full_name = child_name to.name
|
521
531
|
|
522
532
|
# if we already know this name, don't register an alias:
|
523
533
|
# see the metaprogramming in lib/active_support/basic_object.rb,
|
524
534
|
# where we already know BasicObject is a class when we find
|
525
535
|
# BasicObject = BlankSlate
|
526
|
-
return from if @store.find_class_or_module
|
536
|
+
return from if @store.find_class_or_module to_full_name
|
537
|
+
|
538
|
+
unless from
|
539
|
+
@store.unmatched_constant_alias[child_name(from_name)] = [to, file]
|
540
|
+
return to
|
541
|
+
end
|
527
542
|
|
528
|
-
|
529
|
-
|
530
|
-
|
543
|
+
new_to = from.dup
|
544
|
+
new_to.name = to.name
|
545
|
+
new_to.full_name = nil
|
531
546
|
|
532
|
-
if
|
533
|
-
@store.modules_hash[
|
534
|
-
@modules[name] =
|
547
|
+
if new_to.module? then
|
548
|
+
@store.modules_hash[to_full_name] = new_to
|
549
|
+
@modules[to.name] = new_to
|
535
550
|
else
|
536
|
-
@store.classes_hash[
|
537
|
-
@classes[name] =
|
551
|
+
@store.classes_hash[to_full_name] = new_to
|
552
|
+
@classes[to.name] = new_to
|
538
553
|
end
|
539
554
|
|
540
555
|
# Registers a constant for this alias. The constant value and comment
|
541
556
|
# will be updated later, when the Ruby parser adds the constant
|
542
|
-
const = RDoc::Constant.new name, nil,
|
557
|
+
const = RDoc::Constant.new to.name, nil, new_to.comment
|
543
558
|
const.record_location file
|
544
559
|
const.is_alias_for = from
|
545
560
|
add_constant const
|
546
561
|
|
547
|
-
|
562
|
+
new_to
|
548
563
|
end
|
549
564
|
|
550
565
|
##
|
@@ -673,13 +688,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
673
688
|
section
|
674
689
|
end
|
675
690
|
|
676
|
-
##
|
677
|
-
# Is part of this thing was defined in +file+?
|
678
|
-
|
679
|
-
def defined_in?(file)
|
680
|
-
@in_files.include?(file)
|
681
|
-
end
|
682
|
-
|
683
691
|
def display(method_attr) # :nodoc:
|
684
692
|
if method_attr.is_a? RDoc::Attr
|
685
693
|
"#{method_attr.definition} #{method_attr.pretty_name}"
|
@@ -695,14 +703,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
695
703
|
# This method exists to make it easy to work with Context subclasses that
|
696
704
|
# aren't part of RDoc.
|
697
705
|
|
698
|
-
def each_ancestor # :nodoc:
|
699
|
-
end
|
700
|
-
|
701
|
-
##
|
702
|
-
# Iterator for attributes
|
703
|
-
|
704
|
-
def each_attribute # :yields: attribute
|
705
|
-
@attributes.each { |a| yield a }
|
706
|
+
def each_ancestor(&_) # :nodoc:
|
706
707
|
end
|
707
708
|
|
708
709
|
##
|
@@ -712,27 +713,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
712
713
|
classes_and_modules.sort.each(&block)
|
713
714
|
end
|
714
715
|
|
715
|
-
##
|
716
|
-
# Iterator for constants
|
717
|
-
|
718
|
-
def each_constant # :yields: constant
|
719
|
-
@constants.each {|c| yield c}
|
720
|
-
end
|
721
|
-
|
722
|
-
##
|
723
|
-
# Iterator for included modules
|
724
|
-
|
725
|
-
def each_include # :yields: include
|
726
|
-
@includes.each do |i| yield i end
|
727
|
-
end
|
728
|
-
|
729
|
-
##
|
730
|
-
# Iterator for extension modules
|
731
|
-
|
732
|
-
def each_extend # :yields: extend
|
733
|
-
@extends.each do |e| yield e end
|
734
|
-
end
|
735
|
-
|
736
716
|
##
|
737
717
|
# Iterator for methods
|
738
718
|
|
@@ -762,7 +742,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
762
742
|
attributes.default = []
|
763
743
|
|
764
744
|
sort_sections.each do |section|
|
765
|
-
yield section, constants[section].sort, attributes[section].sort
|
745
|
+
yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
|
766
746
|
end
|
767
747
|
end
|
768
748
|
|
@@ -832,13 +812,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
832
812
|
end
|
833
813
|
end
|
834
814
|
|
835
|
-
##
|
836
|
-
# Finds a file with +name+ in this context
|
837
|
-
|
838
|
-
def find_file_named name
|
839
|
-
@store.find_file_named name
|
840
|
-
end
|
841
|
-
|
842
815
|
##
|
843
816
|
# Finds an instance method with +name+ in this context
|
844
817
|
|
@@ -856,14 +829,20 @@ class RDoc::Context < RDoc::CodeObject
|
|
856
829
|
find_attribute_named(symbol) or
|
857
830
|
find_external_alias_named(symbol) or
|
858
831
|
find_module_named(symbol) or
|
859
|
-
find_file_named(symbol)
|
832
|
+
@store.find_file_named(symbol)
|
860
833
|
end
|
861
834
|
|
862
835
|
##
|
863
836
|
# Finds a method named +name+ with singleton value +singleton+.
|
864
837
|
|
865
838
|
def find_method(name, singleton)
|
866
|
-
@method_list.find { |m|
|
839
|
+
@method_list.find { |m|
|
840
|
+
if m.singleton
|
841
|
+
m.name == name && m.singleton == singleton
|
842
|
+
else
|
843
|
+
m.name == name && !m.singleton && !singleton
|
844
|
+
end
|
845
|
+
}
|
867
846
|
end
|
868
847
|
|
869
848
|
##
|
@@ -952,10 +931,10 @@ class RDoc::Context < RDoc::CodeObject
|
|
952
931
|
##
|
953
932
|
# URL for this with a +prefix+
|
954
933
|
|
955
|
-
def http_url
|
934
|
+
def http_url
|
956
935
|
path = name_for_path
|
957
936
|
path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<</
|
958
|
-
path =
|
937
|
+
path = path.split('::')
|
959
938
|
|
960
939
|
File.join(*path.compact) + '.html'
|
961
940
|
end
|
@@ -967,13 +946,21 @@ class RDoc::Context < RDoc::CodeObject
|
|
967
946
|
@instance_attributes ||= attributes.reject { |a| a.singleton }
|
968
947
|
end
|
969
948
|
|
949
|
+
##
|
950
|
+
# Instance methods
|
951
|
+
|
952
|
+
def instance_methods
|
953
|
+
@instance_methods ||= method_list.reject { |a| a.singleton }
|
954
|
+
end
|
955
|
+
|
970
956
|
##
|
971
957
|
# Instance methods
|
972
958
|
#--
|
973
|
-
# TODO
|
959
|
+
# TODO remove this later
|
974
960
|
|
975
961
|
def instance_method_list
|
976
|
-
|
962
|
+
warn '#instance_method_list is obsoleted, please use #instance_methods'
|
963
|
+
@instance_methods ||= method_list.reject { |a| a.singleton }
|
977
964
|
end
|
978
965
|
|
979
966
|
##
|
@@ -1079,6 +1066,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1079
1066
|
return if [:private, :nodoc].include? min_visibility
|
1080
1067
|
remove_invisible_in @method_list, min_visibility
|
1081
1068
|
remove_invisible_in @attributes, min_visibility
|
1069
|
+
remove_invisible_in @constants, min_visibility
|
1082
1070
|
end
|
1083
1071
|
|
1084
1072
|
##
|
@@ -1165,6 +1153,17 @@ class RDoc::Context < RDoc::CodeObject
|
|
1165
1153
|
end
|
1166
1154
|
end
|
1167
1155
|
|
1156
|
+
##
|
1157
|
+
# Given an array +names+ of constants, set the visibility of each constant to
|
1158
|
+
# +visibility+
|
1159
|
+
|
1160
|
+
def set_constant_visibility_for(names, visibility)
|
1161
|
+
names.each do |name|
|
1162
|
+
constant = @constants_hash[name] or next
|
1163
|
+
constant.visibility = visibility
|
1164
|
+
end
|
1165
|
+
end
|
1166
|
+
|
1168
1167
|
##
|
1169
1168
|
# Sorts sections alphabetically (default) or in TomDoc fashion (none,
|
1170
1169
|
# Public, Internal, Deprecated)
|
@@ -1218,6 +1217,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
1218
1217
|
klass
|
1219
1218
|
end
|
1220
1219
|
|
1221
|
-
autoload :Section,
|
1220
|
+
autoload :Section, "#{__dir__}/context/section"
|
1222
1221
|
|
1223
1222
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Abstract class representing either a method or an attribute.
|
4
4
|
|
@@ -63,19 +63,13 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
63
63
|
|
64
64
|
attr_reader :arglists
|
65
65
|
|
66
|
-
##
|
67
|
-
# Pretty parameter list for this method
|
68
|
-
|
69
|
-
attr_reader :param_seq
|
70
|
-
|
71
|
-
|
72
66
|
##
|
73
67
|
# Creates a new MethodAttr from token stream +text+ and method or attribute
|
74
68
|
# name +name+.
|
75
69
|
#
|
76
70
|
# Usually this is called by super from a subclass.
|
77
71
|
|
78
|
-
def initialize
|
72
|
+
def initialize(text, name, singleton: false)
|
79
73
|
super()
|
80
74
|
|
81
75
|
@text = text
|
@@ -84,14 +78,13 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
84
78
|
@aliases = []
|
85
79
|
@is_alias_for = nil
|
86
80
|
@parent_name = nil
|
87
|
-
@singleton =
|
81
|
+
@singleton = singleton
|
88
82
|
@visibility = :public
|
89
83
|
@see = false
|
90
84
|
|
91
85
|
@arglists = nil
|
92
86
|
@block_params = nil
|
93
87
|
@call_seq = nil
|
94
|
-
@param_seq = nil
|
95
88
|
@params = nil
|
96
89
|
end
|
97
90
|
|
@@ -114,8 +107,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
114
107
|
return unless other.respond_to?(:singleton) &&
|
115
108
|
other.respond_to?(:name)
|
116
109
|
|
117
|
-
[
|
118
|
-
[other.singleton ? 0 : 1, other.name]
|
110
|
+
[@singleton ? 0 : 1, name_ord_range, name] <=>
|
111
|
+
[other.singleton ? 0 : 1, other.name_ord_range, other.name]
|
119
112
|
end
|
120
113
|
|
121
114
|
def == other # :nodoc:
|
@@ -188,7 +181,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
188
181
|
next if String === ancestor
|
189
182
|
next if parent == ancestor
|
190
183
|
|
191
|
-
other = ancestor.find_method_named('#'
|
184
|
+
other = ancestor.find_method_named('#' + name) ||
|
192
185
|
ancestor.find_attribute_named(name)
|
193
186
|
|
194
187
|
return other if other
|
@@ -268,8 +261,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
268
261
|
when 'const_get' then 'const'
|
269
262
|
when 'new' then
|
270
263
|
$1.split('::').last. # ClassName => class_name
|
271
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
272
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
264
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
265
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
273
266
|
downcase
|
274
267
|
else
|
275
268
|
$2
|
@@ -289,9 +282,9 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
289
282
|
# HTML id-friendly method/attribute name
|
290
283
|
|
291
284
|
def html_name
|
292
|
-
require 'cgi'
|
285
|
+
require 'cgi/util'
|
293
286
|
|
294
|
-
CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
|
287
|
+
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
295
288
|
end
|
296
289
|
|
297
290
|
##
|
@@ -320,19 +313,6 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
320
313
|
@singleton ? '::' : '#'
|
321
314
|
end
|
322
315
|
|
323
|
-
##
|
324
|
-
# Name for output to HTML. For class methods the full name with a "." is
|
325
|
-
# used like +SomeClass.method_name+. For instance methods the class name is
|
326
|
-
# used if +context+ does not match the parent.
|
327
|
-
#
|
328
|
-
# This is to help prevent people from using :: to call class methods.
|
329
|
-
|
330
|
-
def output_name context
|
331
|
-
return "#{name_prefix}#{@name}" if context == parent
|
332
|
-
|
333
|
-
"#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
|
334
|
-
end
|
335
|
-
|
336
316
|
##
|
337
317
|
# Method/attribute name with class/instance indicator
|
338
318
|
|
@@ -415,5 +395,16 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
415
395
|
end
|
416
396
|
end
|
417
397
|
|
398
|
+
def name_ord_range # :nodoc:
|
399
|
+
case name.ord
|
400
|
+
when 0..64 # anything below "A"
|
401
|
+
1
|
402
|
+
when 91..96 # the symbols between "Z" and "a"
|
403
|
+
2
|
404
|
+
when 123..126 # 7-bit symbols above "z": "{", "|", "}", "~"
|
405
|
+
3
|
406
|
+
else # everythig else can be sorted as normal
|
407
|
+
4
|
408
|
+
end
|
409
|
+
end
|
418
410
|
end
|
419
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# A Mixin adds features from a module into another context. RDoc::Include and
|
4
4
|
# RDoc::Extend are both mixins.
|
@@ -118,4 +118,3 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
118
118
|
end
|
119
119
|
|
120
120
|
end
|
121
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# A normal class, neither singleton nor anonymous
|
4
4
|
|
@@ -47,16 +47,16 @@ class RDoc::NormalClass < RDoc::ClassModule
|
|
47
47
|
def to_s # :nodoc:
|
48
48
|
display = "#{self.class.name} #{self.full_name}"
|
49
49
|
if superclass
|
50
|
-
display
|
50
|
+
display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
|
51
51
|
end
|
52
|
-
display
|
52
|
+
display += ' -> ' + is_alias_for.to_s if is_alias_for
|
53
53
|
display
|
54
54
|
end
|
55
55
|
|
56
56
|
def pretty_print q # :nodoc:
|
57
57
|
superclass = @superclass ? " < #{@superclass}" : nil
|
58
58
|
|
59
|
-
q.group 2, "[class #{full_name}#{superclass}
|
59
|
+
q.group 2, "[class #{full_name}#{superclass}", "]" do
|
60
60
|
q.breakable
|
61
61
|
q.text "includes:"
|
62
62
|
q.breakable
|
@@ -90,4 +90,3 @@ class RDoc::NormalClass < RDoc::ClassModule
|
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
93
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# A normal module, like NormalClass
|
4
4
|
|
@@ -30,7 +30,7 @@ class RDoc::NormalModule < RDoc::ClassModule
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def pretty_print q # :nodoc:
|
33
|
-
q.group 2, "[module #{full_name}:
|
33
|
+
q.group 2, "[module #{full_name}:", "]" do
|
34
34
|
q.breakable
|
35
35
|
q.text "includes:"
|
36
36
|
q.breakable
|
@@ -71,4 +71,3 @@ class RDoc::NormalModule < RDoc::ClassModule
|
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
74
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# A file loaded by \#require
|
4
4
|
|
@@ -24,7 +24,7 @@ class RDoc::Require < RDoc::CodeObject
|
|
24
24
|
self.class,
|
25
25
|
object_id,
|
26
26
|
@name,
|
27
|
-
|
27
|
+
@parent ? @parent.base_name : '(unknown)'
|
28
28
|
]
|
29
29
|
end
|
30
30
|
|
@@ -49,4 +49,3 @@ class RDoc::Require < RDoc::CodeObject
|
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
52
|
-
|