rdoc 3.12.2 → 4.0.0.preview2
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.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +3 -2
- data/DEVELOPERS.rdoc +53 -0
- data/History.rdoc +159 -25
- data/LEGAL.rdoc +12 -0
- data/Manifest.txt +56 -3
- data/README.rdoc +87 -19
- data/Rakefile +11 -2
- data/TODO.rdoc +20 -13
- data/bin/rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +1 -1
- data/lib/rdoc.rb +32 -71
- data/lib/rdoc/any_method.rb +75 -21
- data/lib/rdoc/attr.rb +49 -10
- data/lib/rdoc/class_module.rb +182 -32
- data/lib/rdoc/code_object.rb +54 -12
- data/lib/rdoc/comment.rb +8 -1
- data/lib/rdoc/constant.rb +100 -6
- data/lib/rdoc/context.rb +93 -41
- data/lib/rdoc/context/section.rb +143 -28
- data/lib/rdoc/cross_reference.rb +58 -50
- data/lib/rdoc/encoding.rb +34 -29
- data/lib/rdoc/erb_partial.rb +18 -0
- data/lib/rdoc/extend.rb +117 -0
- data/lib/rdoc/generator.rb +11 -6
- data/lib/rdoc/generator/darkfish.rb +250 -62
- data/lib/rdoc/generator/json_index.rb +20 -12
- data/lib/rdoc/generator/markup.rb +10 -12
- data/lib/rdoc/generator/ri.rb +7 -60
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/include.rb +12 -3
- data/lib/rdoc/markdown.kpeg +1186 -0
- data/lib/rdoc/markdown.rb +16336 -0
- data/lib/rdoc/markdown/entities.rb +2128 -0
- data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
- data/lib/rdoc/markdown/literals_1_8.rb +454 -0
- data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
- data/lib/rdoc/markdown/literals_1_9.rb +417 -0
- data/lib/rdoc/markup.rb +69 -10
- data/lib/rdoc/markup/attr_changer.rb +2 -5
- data/lib/rdoc/markup/attribute_manager.rb +23 -14
- data/lib/rdoc/markup/attributes.rb +70 -0
- data/lib/rdoc/markup/block_quote.rb +14 -0
- data/lib/rdoc/markup/document.rb +20 -4
- data/lib/rdoc/markup/formatter.rb +17 -6
- data/lib/rdoc/markup/formatter_test_case.rb +93 -24
- data/lib/rdoc/markup/hard_break.rb +31 -0
- data/lib/rdoc/markup/heading.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +14 -0
- data/lib/rdoc/markup/list.rb +23 -4
- data/lib/rdoc/markup/list_item.rb +17 -4
- data/lib/rdoc/markup/paragraph.rb +14 -0
- data/lib/rdoc/markup/parser.rb +107 -60
- data/lib/rdoc/markup/raw.rb +4 -4
- data/lib/rdoc/markup/special.rb +3 -3
- data/lib/rdoc/markup/to_ansi.rb +7 -1
- data/lib/rdoc/markup/to_html.rb +42 -14
- data/lib/rdoc/markup/to_html_crossref.rb +10 -9
- data/lib/rdoc/markup/to_html_snippet.rb +20 -4
- data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
- data/lib/rdoc/markup/to_label.rb +20 -1
- data/lib/rdoc/markup/to_markdown.rb +134 -0
- data/lib/rdoc/markup/to_rdoc.rb +36 -5
- data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
- data/lib/rdoc/markup/to_tt_only.rb +11 -2
- data/lib/rdoc/markup/verbatim.rb +19 -0
- data/lib/rdoc/method_attr.rb +33 -19
- data/lib/rdoc/normal_class.rb +26 -7
- data/lib/rdoc/normal_module.rb +10 -5
- data/lib/rdoc/options.rb +95 -21
- data/lib/rdoc/parser.rb +6 -2
- data/lib/rdoc/parser/c.rb +212 -97
- data/lib/rdoc/parser/markdown.rb +23 -0
- data/lib/rdoc/parser/ruby.rb +115 -35
- data/lib/rdoc/parser/ruby_tools.rb +8 -3
- data/lib/rdoc/rd.rb +8 -4
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/block_parser.ry +1 -1
- data/lib/rdoc/rdoc.rb +45 -21
- data/lib/rdoc/ri/driver.rb +322 -76
- data/lib/rdoc/ri/paths.rb +90 -31
- data/lib/rdoc/ri/store.rb +2 -353
- data/lib/rdoc/ruby_lex.rb +5 -21
- data/lib/rdoc/ruby_token.rb +2 -3
- data/lib/rdoc/rubygems_hook.rb +21 -9
- data/lib/rdoc/servlet.rb +302 -0
- data/lib/rdoc/stats.rb +28 -20
- data/lib/rdoc/store.rb +881 -0
- data/lib/rdoc/task.rb +2 -1
- data/lib/rdoc/test_case.rb +103 -1
- data/lib/rdoc/text.rb +5 -4
- data/lib/rdoc/tom_doc.rb +17 -16
- data/lib/rdoc/top_level.rb +43 -285
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
- data/test/test_attribute_manager.rb +7 -4
- data/test/test_rdoc_any_method.rb +84 -13
- data/test/test_rdoc_attr.rb +59 -9
- data/test/test_rdoc_class_module.rb +670 -73
- data/test/test_rdoc_code_object.rb +21 -1
- data/test/test_rdoc_comment.rb +1 -1
- data/test/test_rdoc_constant.rb +132 -0
- data/test/test_rdoc_context.rb +84 -18
- data/test/test_rdoc_context_section.rb +99 -15
- data/test/test_rdoc_cross_reference.rb +1 -1
- data/test/test_rdoc_encoding.rb +17 -1
- data/test/test_rdoc_extend.rb +94 -0
- data/test/test_rdoc_generator_darkfish.rb +45 -19
- data/test/test_rdoc_generator_json_index.rb +27 -7
- data/test/test_rdoc_generator_markup.rb +3 -3
- data/test/test_rdoc_generator_ri.rb +11 -9
- data/test/test_rdoc_include.rb +12 -0
- data/test/test_rdoc_markdown.rb +977 -0
- data/test/test_rdoc_markdown_test.rb +1891 -0
- data/test/test_rdoc_markup.rb +1 -1
- data/test/test_rdoc_markup_attribute_manager.rb +2 -2
- data/test/test_rdoc_markup_attributes.rb +39 -0
- data/test/test_rdoc_markup_document.rb +16 -1
- data/test/test_rdoc_markup_formatter.rb +7 -4
- data/test/test_rdoc_markup_hard_break.rb +31 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
- data/test/test_rdoc_markup_paragraph.rb +15 -1
- data/test/test_rdoc_markup_parser.rb +152 -89
- data/test/test_rdoc_markup_to_ansi.rb +23 -2
- data/test/test_rdoc_markup_to_bs.rb +24 -0
- data/test/test_rdoc_markup_to_html.rb +50 -19
- data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
- data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
- data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
- data/test/test_rdoc_markup_to_label.rb +63 -1
- data/test/test_rdoc_markup_to_markdown.rb +352 -0
- data/test/test_rdoc_markup_to_rdoc.rb +22 -2
- data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
- data/test/test_rdoc_markup_to_tt_only.rb +20 -0
- data/test/test_rdoc_markup_verbatim.rb +13 -0
- data/test/test_rdoc_method_attr.rb +5 -0
- data/test/test_rdoc_normal_class.rb +24 -5
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_options.rb +21 -6
- data/test/test_rdoc_parser.rb +24 -0
- data/test/test_rdoc_parser_c.rb +151 -26
- data/test/test_rdoc_parser_markdown.rb +55 -0
- data/test/test_rdoc_parser_rd.rb +2 -2
- data/test/test_rdoc_parser_ruby.rb +468 -109
- data/test/test_rdoc_parser_simple.rb +2 -2
- data/test/test_rdoc_rd_block_parser.rb +0 -4
- data/test/test_rdoc_rdoc.rb +110 -22
- data/test/test_rdoc_ri_driver.rb +415 -80
- data/test/test_rdoc_ri_paths.rb +122 -13
- data/test/test_rdoc_ruby_lex.rb +5 -61
- data/test/test_rdoc_ruby_token.rb +19 -0
- data/test/test_rdoc_rubygems_hook.rb +64 -43
- data/test/test_rdoc_servlet.rb +429 -0
- data/test/test_rdoc_stats.rb +83 -24
- data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
- data/test/test_rdoc_task.rb +2 -2
- data/test/test_rdoc_text.rb +37 -11
- data/test/test_rdoc_tom_doc.rb +59 -62
- data/test/test_rdoc_top_level.rb +71 -113
- data/test/xref_test_case.rb +7 -9
- metadata +122 -39
- metadata.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/lib/rdoc/markup/attribute.rb +0 -51
data/lib/rdoc/code_object.rb
CHANGED
@@ -75,9 +75,9 @@ class RDoc::CodeObject
|
|
75
75
|
attr_accessor :offset
|
76
76
|
|
77
77
|
##
|
78
|
-
#
|
78
|
+
# Sets the parent CodeObject
|
79
79
|
|
80
|
-
|
80
|
+
attr_writer :parent
|
81
81
|
|
82
82
|
##
|
83
83
|
# Did we ever receive a +:nodoc:+ directive?
|
@@ -85,9 +85,14 @@ class RDoc::CodeObject
|
|
85
85
|
attr_reader :received_nodoc
|
86
86
|
|
87
87
|
##
|
88
|
-
#
|
88
|
+
# Set the section this CodeObject is in
|
89
89
|
|
90
|
-
|
90
|
+
attr_writer :section
|
91
|
+
|
92
|
+
##
|
93
|
+
# The RDoc::Store for this object.
|
94
|
+
|
95
|
+
attr_accessor :store
|
91
96
|
|
92
97
|
##
|
93
98
|
# We are the model of the code, but we know that at some point we will be
|
@@ -100,11 +105,16 @@ class RDoc::CodeObject
|
|
100
105
|
# Creates a new CodeObject that will document itself and its children
|
101
106
|
|
102
107
|
def initialize
|
103
|
-
@metadata
|
104
|
-
@comment
|
105
|
-
@parent
|
106
|
-
@
|
107
|
-
@
|
108
|
+
@metadata = {}
|
109
|
+
@comment = ''
|
110
|
+
@parent = nil
|
111
|
+
@parent_name = nil # for loading
|
112
|
+
@parent_class = nil # for loading
|
113
|
+
@section = nil
|
114
|
+
@section_title = nil # for loading
|
115
|
+
@file = nil
|
116
|
+
@full_name = nil
|
117
|
+
@store = nil
|
108
118
|
|
109
119
|
@document_children = true
|
110
120
|
@document_self = true
|
@@ -126,7 +136,6 @@ class RDoc::CodeObject
|
|
126
136
|
if comment and not comment.empty? then
|
127
137
|
normalize_comment comment
|
128
138
|
else
|
129
|
-
# TODO is this sufficient?
|
130
139
|
# HACK correct fix is to have #initialize create @comment
|
131
140
|
# with the correct encoding
|
132
141
|
if String === @comment and
|
@@ -214,7 +223,7 @@ class RDoc::CodeObject
|
|
214
223
|
|
215
224
|
##
|
216
225
|
# Force the documentation of this object unless documentation
|
217
|
-
# has been turned off by :
|
226
|
+
# has been turned off by :enddoc:
|
218
227
|
#--
|
219
228
|
# HACK untested, was assigning to an ivar
|
220
229
|
|
@@ -259,6 +268,29 @@ class RDoc::CodeObject
|
|
259
268
|
@ignored
|
260
269
|
end
|
261
270
|
|
271
|
+
##
|
272
|
+
# Our parent CodeObject. The parent may be missing for classes loaded from
|
273
|
+
# legacy RI data stores.
|
274
|
+
|
275
|
+
def parent
|
276
|
+
return @parent if @parent
|
277
|
+
return nil unless @parent_name
|
278
|
+
|
279
|
+
if @parent_class == RDoc::TopLevel then
|
280
|
+
@parent = @store.add_file @parent_name
|
281
|
+
else
|
282
|
+
@parent = @store.find_class_or_module @parent_name
|
283
|
+
|
284
|
+
return @parent if @parent
|
285
|
+
|
286
|
+
begin
|
287
|
+
@parent = @store.load_class @parent_name
|
288
|
+
rescue RDoc::Store::MissingFileError
|
289
|
+
nil
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
262
294
|
##
|
263
295
|
# File name of our parent
|
264
296
|
|
@@ -281,9 +313,19 @@ class RDoc::CodeObject
|
|
281
313
|
@file = top_level
|
282
314
|
end
|
283
315
|
|
316
|
+
##
|
317
|
+
# The section this CodeObject is in. Sections allow grouping of constants,
|
318
|
+
# attributes and methods inside a class or module.
|
319
|
+
|
320
|
+
def section
|
321
|
+
return @section if @section
|
322
|
+
|
323
|
+
@section = parent.add_section @section_title if parent
|
324
|
+
end
|
325
|
+
|
284
326
|
##
|
285
327
|
# Enable capture of documentation unless documentation has been
|
286
|
-
# turned off by :
|
328
|
+
# turned off by :enddoc:
|
287
329
|
|
288
330
|
def start_doc
|
289
331
|
return if @done_documenting
|
data/lib/rdoc/comment.rb
CHANGED
@@ -22,6 +22,11 @@ class RDoc::Comment
|
|
22
22
|
|
23
23
|
attr_accessor :location
|
24
24
|
|
25
|
+
##
|
26
|
+
# For duck-typing when merging classes at load time
|
27
|
+
|
28
|
+
alias file location # :nodoc:
|
29
|
+
|
25
30
|
##
|
26
31
|
# The text for this comment
|
27
32
|
|
@@ -143,7 +148,9 @@ class RDoc::Comment
|
|
143
148
|
end
|
144
149
|
|
145
150
|
def inspect # :nodoc:
|
146
|
-
|
151
|
+
location = @location ? @location.relative_name : '(unknown)'
|
152
|
+
|
153
|
+
"#<%s:%x %s %p>" % [self.class, object_id, location, @text]
|
147
154
|
end
|
148
155
|
|
149
156
|
##
|
data/lib/rdoc/constant.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
|
4
4
|
class RDoc::Constant < RDoc::CodeObject
|
5
5
|
|
6
|
+
MARSHAL_VERSION = 0 # :nodoc:
|
7
|
+
|
6
8
|
##
|
7
|
-
#
|
8
|
-
# this is the RDoc::ClassModule it is an alias for.
|
9
|
-
# +nil+ otherwise.
|
9
|
+
# Sets the module or class this is constant is an alias for.
|
10
10
|
|
11
|
-
|
11
|
+
attr_writer :is_alias_for
|
12
12
|
|
13
13
|
##
|
14
14
|
# The constant's name
|
@@ -20,14 +20,23 @@ class RDoc::Constant < RDoc::CodeObject
|
|
20
20
|
|
21
21
|
attr_accessor :value
|
22
22
|
|
23
|
+
##
|
24
|
+
# The constant's visibility
|
25
|
+
|
26
|
+
attr_accessor :visibility
|
27
|
+
|
23
28
|
##
|
24
29
|
# Creates a new constant with +name+, +value+ and +comment+
|
25
30
|
|
26
31
|
def initialize(name, value, comment)
|
27
32
|
super()
|
28
|
-
|
33
|
+
|
34
|
+
@name = name
|
29
35
|
@value = value
|
36
|
+
|
30
37
|
@is_alias_for = nil
|
38
|
+
@visibility = nil
|
39
|
+
|
31
40
|
self.comment = comment
|
32
41
|
end
|
33
42
|
|
@@ -57,6 +66,27 @@ class RDoc::Constant < RDoc::CodeObject
|
|
57
66
|
super or is_alias_for && is_alias_for.documented?
|
58
67
|
end
|
59
68
|
|
69
|
+
##
|
70
|
+
# Full constant name including namespace
|
71
|
+
|
72
|
+
def full_name
|
73
|
+
@full_name ||= "#{parent_name}::#{@name}"
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# The module or class this constant is an alias for
|
78
|
+
|
79
|
+
def is_alias_for
|
80
|
+
case @is_alias_for
|
81
|
+
when String then
|
82
|
+
found = @store.find_class_or_module @is_alias_for
|
83
|
+
@is_alias_for = found if found
|
84
|
+
@is_alias_for
|
85
|
+
else
|
86
|
+
@is_alias_for
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
60
90
|
def inspect # :nodoc:
|
61
91
|
"#<%s:0x%x %s::%s>" % [
|
62
92
|
self.class, object_id,
|
@@ -65,12 +95,76 @@ class RDoc::Constant < RDoc::CodeObject
|
|
65
95
|
end
|
66
96
|
|
67
97
|
##
|
68
|
-
#
|
98
|
+
# Dumps this Constant for use by ri. See also #marshal_load
|
99
|
+
|
100
|
+
def marshal_dump
|
101
|
+
alias_name = case found = is_alias_for
|
102
|
+
when RDoc::CodeObject then found.full_name
|
103
|
+
else found
|
104
|
+
end
|
105
|
+
|
106
|
+
[ MARSHAL_VERSION,
|
107
|
+
@name,
|
108
|
+
full_name,
|
109
|
+
@visibility,
|
110
|
+
alias_name,
|
111
|
+
parse(@comment),
|
112
|
+
@file.relative_name,
|
113
|
+
parent.name,
|
114
|
+
parent.class,
|
115
|
+
section.title,
|
116
|
+
]
|
117
|
+
end
|
118
|
+
|
119
|
+
##
|
120
|
+
# Loads this Constant from +array+. For a loaded Constant the following
|
121
|
+
# methods will return cached values:
|
122
|
+
#
|
123
|
+
# * #full_name
|
124
|
+
# * #parent_name
|
125
|
+
|
126
|
+
def marshal_load array
|
127
|
+
initialize array[1], nil, array[5]
|
128
|
+
|
129
|
+
@full_name = array[2]
|
130
|
+
@visibility = array[3]
|
131
|
+
@is_alias_for = array[4]
|
132
|
+
# 5 handled above
|
133
|
+
# 6 handled below
|
134
|
+
@parent_name = array[7]
|
135
|
+
@parent_class = array[8]
|
136
|
+
@section_title = array[9]
|
137
|
+
|
138
|
+
@file = RDoc::TopLevel.new array[6]
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Path to this constant for use with HTML generator output.
|
69
143
|
|
70
144
|
def path
|
71
145
|
"#{@parent.path}##{@name}"
|
72
146
|
end
|
73
147
|
|
148
|
+
def pretty_print q # :nodoc:
|
149
|
+
q.group 2, "[#{self.class.name} #{full_name}", "]" do
|
150
|
+
unless comment.empty? then
|
151
|
+
q.breakable
|
152
|
+
q.text "comment:"
|
153
|
+
q.breakable
|
154
|
+
q.pp @comment
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# Sets the store for this class or module and its contained code objects.
|
161
|
+
|
162
|
+
def store= store
|
163
|
+
super
|
164
|
+
|
165
|
+
@file = @store.add_file @file.full_name if @file
|
166
|
+
end
|
167
|
+
|
74
168
|
def to_s # :nodoc:
|
75
169
|
parent_name = parent ? parent.full_name : '(unknown)'
|
76
170
|
if is_alias_for
|
data/lib/rdoc/context.rb
CHANGED
@@ -30,6 +30,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
30
30
|
|
31
31
|
attr_reader :attributes
|
32
32
|
|
33
|
+
##
|
34
|
+
# Block params to be used in the next MethodAttr parsed under this context
|
35
|
+
|
36
|
+
attr_accessor :block_params
|
37
|
+
|
33
38
|
##
|
34
39
|
# Constants defined
|
35
40
|
|
@@ -50,6 +55,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
50
55
|
|
51
56
|
attr_reader :includes
|
52
57
|
|
58
|
+
##
|
59
|
+
# Modules this context is extended with
|
60
|
+
|
61
|
+
attr_reader :extends
|
62
|
+
|
53
63
|
##
|
54
64
|
# Methods defined in this context
|
55
65
|
|
@@ -78,7 +88,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
78
88
|
attr_accessor :unmatched_alias_lists
|
79
89
|
|
80
90
|
##
|
81
|
-
# Aliases that could not
|
91
|
+
# Aliases that could not be resolved.
|
82
92
|
|
83
93
|
attr_reader :external_aliases
|
84
94
|
|
@@ -93,6 +103,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
93
103
|
|
94
104
|
attr_reader :methods_hash
|
95
105
|
|
106
|
+
##
|
107
|
+
# Params to be used in the next MethodAttr parsed under this context
|
108
|
+
|
109
|
+
attr_accessor :params
|
110
|
+
|
96
111
|
##
|
97
112
|
# Hash of registered constants.
|
98
113
|
|
@@ -129,6 +144,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
129
144
|
@aliases = []
|
130
145
|
@requires = []
|
131
146
|
@includes = []
|
147
|
+
@extends = []
|
132
148
|
@constants = []
|
133
149
|
@external_aliases = []
|
134
150
|
|
@@ -136,8 +152,12 @@ class RDoc::Context < RDoc::CodeObject
|
|
136
152
|
# a method not yet encountered).
|
137
153
|
@unmatched_alias_lists = {}
|
138
154
|
|
139
|
-
@methods_hash
|
155
|
+
@methods_hash = {}
|
140
156
|
@constants_hash = {}
|
157
|
+
|
158
|
+
@params = nil
|
159
|
+
|
160
|
+
@store ||= nil
|
141
161
|
end
|
142
162
|
|
143
163
|
##
|
@@ -260,12 +280,12 @@ class RDoc::Context < RDoc::CodeObject
|
|
260
280
|
if full_name =~ /^(.+)::(\w+)$/ then
|
261
281
|
name = $2
|
262
282
|
ename = $1
|
263
|
-
enclosing =
|
264
|
-
RDoc::TopLevel.modules_hash[ename]
|
283
|
+
enclosing = @store.classes_hash[ename] || @store.modules_hash[ename]
|
265
284
|
# HACK: crashes in actionpack/lib/action_view/helpers/form_helper.rb (metaprogramming)
|
266
285
|
unless enclosing then
|
267
286
|
# try the given name at top level (will work for the above example)
|
268
|
-
enclosing =
|
287
|
+
enclosing = @store.classes_hash[given_name] ||
|
288
|
+
@store.modules_hash[given_name]
|
269
289
|
return enclosing if enclosing
|
270
290
|
# not found: create the parent(s)
|
271
291
|
names = ename.split('::')
|
@@ -304,7 +324,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
304
324
|
end
|
305
325
|
|
306
326
|
# did we believe it was a module?
|
307
|
-
mod =
|
327
|
+
mod = @store.modules_hash.delete superclass
|
308
328
|
|
309
329
|
upgrade_to_class mod, RDoc::NormalClass, mod.parent if mod
|
310
330
|
|
@@ -312,7 +332,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
312
332
|
superclass = nil if superclass == full_name
|
313
333
|
end
|
314
334
|
|
315
|
-
klass =
|
335
|
+
klass = @store.classes_hash[full_name]
|
316
336
|
|
317
337
|
if klass then
|
318
338
|
# if TopLevel, it may not be registered in the classes:
|
@@ -329,7 +349,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
329
349
|
end
|
330
350
|
else
|
331
351
|
# this is a new class
|
332
|
-
mod =
|
352
|
+
mod = @store.modules_hash.delete full_name
|
333
353
|
|
334
354
|
if mod then
|
335
355
|
klass = upgrade_to_class mod, RDoc::NormalClass, enclosing
|
@@ -339,10 +359,12 @@ class RDoc::Context < RDoc::CodeObject
|
|
339
359
|
klass = class_type.new name, superclass
|
340
360
|
|
341
361
|
enclosing.add_class_or_module(klass, enclosing.classes_hash,
|
342
|
-
|
362
|
+
@store.classes_hash)
|
343
363
|
end
|
344
364
|
end
|
345
365
|
|
366
|
+
klass.parent = self
|
367
|
+
|
346
368
|
klass
|
347
369
|
end
|
348
370
|
|
@@ -357,6 +379,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
357
379
|
mod.section = current_section # TODO declaring context? something is
|
358
380
|
# wrong here...
|
359
381
|
mod.parent = self
|
382
|
+
mod.store = @store
|
360
383
|
|
361
384
|
unless @done_documenting then
|
362
385
|
self_hash[mod.name] = mod
|
@@ -403,6 +426,15 @@ class RDoc::Context < RDoc::CodeObject
|
|
403
426
|
include
|
404
427
|
end
|
405
428
|
|
429
|
+
##
|
430
|
+
# Adds extension module +ext+ which should be an RDoc::Extend
|
431
|
+
|
432
|
+
def add_extend ext
|
433
|
+
add_to @extends, ext
|
434
|
+
|
435
|
+
ext
|
436
|
+
end
|
437
|
+
|
406
438
|
##
|
407
439
|
# Adds +method+ if not already there. If it is (as method or attribute),
|
408
440
|
# updates the comment if it was empty.
|
@@ -416,6 +448,10 @@ class RDoc::Context < RDoc::CodeObject
|
|
416
448
|
|
417
449
|
if known then
|
418
450
|
known.comment = method.comment if known.comment.empty?
|
451
|
+
previously = ", previously in #{known.file}" unless
|
452
|
+
method.file == known.file
|
453
|
+
@store.rdoc.options.warn \
|
454
|
+
"Duplicate method #{known.full_name} in #{method.file}#{previously}"
|
419
455
|
else
|
420
456
|
@methods_hash[key] = method
|
421
457
|
method.visibility = @visibility
|
@@ -435,9 +471,9 @@ class RDoc::Context < RDoc::CodeObject
|
|
435
471
|
return mod if mod
|
436
472
|
|
437
473
|
full_name = child_name name
|
438
|
-
mod =
|
474
|
+
mod = @store.modules_hash[full_name] || class_type.new(name)
|
439
475
|
|
440
|
-
add_class_or_module
|
476
|
+
add_class_or_module mod, @modules, @store.modules_hash
|
441
477
|
end
|
442
478
|
|
443
479
|
##
|
@@ -447,31 +483,34 @@ class RDoc::Context < RDoc::CodeObject
|
|
447
483
|
def add_module_alias from, name, file
|
448
484
|
return from if @done_documenting
|
449
485
|
|
450
|
-
to_name = child_name
|
486
|
+
to_name = child_name name
|
451
487
|
|
452
488
|
# if we already know this name, don't register an alias:
|
453
489
|
# see the metaprogramming in lib/active_support/basic_object.rb,
|
454
|
-
# where we already know BasicObject
|
490
|
+
# where we already know BasicObject is a class when we find
|
455
491
|
# BasicObject = BlankSlate
|
456
|
-
return from if
|
492
|
+
return from if @store.find_class_or_module to_name
|
457
493
|
|
458
|
-
|
459
|
-
|
460
|
-
|
494
|
+
to = from.dup
|
495
|
+
to.name = name
|
496
|
+
to.full_name = nil
|
497
|
+
|
498
|
+
if to.module? then
|
499
|
+
@store.modules_hash[to_name] = to
|
500
|
+
@modules[name] = to
|
461
501
|
else
|
462
|
-
|
463
|
-
@classes[name] =
|
502
|
+
@store.classes_hash[to_name] = to
|
503
|
+
@classes[name] = to
|
464
504
|
end
|
465
505
|
|
466
|
-
#
|
467
|
-
#
|
468
|
-
|
469
|
-
const = RDoc::Constant.new name, nil, ''
|
506
|
+
# Registers a constant for this alias. The constant value and comment
|
507
|
+
# will be updated later, when the Ruby parser adds the constant
|
508
|
+
const = RDoc::Constant.new name, nil, to.comment
|
470
509
|
const.record_location file
|
471
510
|
const.is_alias_for = from
|
472
511
|
add_constant const
|
473
512
|
|
474
|
-
|
513
|
+
to
|
475
514
|
end
|
476
515
|
|
477
516
|
##
|
@@ -497,7 +536,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
497
536
|
|
498
537
|
def add_section title, comment = nil
|
499
538
|
if section = @sections[title] then
|
500
|
-
section.
|
539
|
+
section.add_comment comment if comment
|
501
540
|
else
|
502
541
|
section = Section.new self, title, comment
|
503
542
|
@sections[title] = section
|
@@ -509,9 +548,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
509
548
|
##
|
510
549
|
# Adds +thing+ to the collection +array+
|
511
550
|
|
512
|
-
def add_to
|
551
|
+
def add_to array, thing
|
513
552
|
array << thing if @document_self
|
514
|
-
|
553
|
+
|
554
|
+
thing.parent = self
|
555
|
+
thing.store = @store if @store
|
515
556
|
thing.section = current_section
|
516
557
|
end
|
517
558
|
|
@@ -521,7 +562,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
521
562
|
# This means any of: comment, aliases, methods, attributes, external
|
522
563
|
# aliases, require, constant.
|
523
564
|
#
|
524
|
-
# Includes are also checked unless <tt>includes == false</tt>.
|
565
|
+
# Includes and extends are also checked unless <tt>includes == false</tt>.
|
525
566
|
|
526
567
|
def any_content(includes = true)
|
527
568
|
@any_content ||= !(
|
@@ -533,7 +574,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
533
574
|
@requires.empty? &&
|
534
575
|
@constants.empty?
|
535
576
|
)
|
536
|
-
@any_content || (includes &&
|
577
|
+
@any_content || (includes && !(@includes + @extends).empty? )
|
537
578
|
end
|
538
579
|
|
539
580
|
##
|
@@ -616,6 +657,9 @@ class RDoc::Context < RDoc::CodeObject
|
|
616
657
|
##
|
617
658
|
# Iterator for ancestors for duck-typing. Does nothing. See
|
618
659
|
# RDoc::ClassModule#each_ancestor.
|
660
|
+
#
|
661
|
+
# This method exists to make it easy to work with Context subclasses that
|
662
|
+
# aren't part of RDoc.
|
619
663
|
|
620
664
|
def each_ancestor # :nodoc:
|
621
665
|
end
|
@@ -648,6 +692,13 @@ class RDoc::Context < RDoc::CodeObject
|
|
648
692
|
@includes.each do |i| yield i end
|
649
693
|
end
|
650
694
|
|
695
|
+
##
|
696
|
+
# Iterator for extension modules
|
697
|
+
|
698
|
+
def each_extend # :yields: extend
|
699
|
+
@extends.each do |e| yield e end
|
700
|
+
end
|
701
|
+
|
651
702
|
##
|
652
703
|
# Iterator for methods
|
653
704
|
|
@@ -671,9 +722,9 @@ class RDoc::Context < RDoc::CodeObject
|
|
671
722
|
return enum_for __method__ unless block_given?
|
672
723
|
|
673
724
|
constants = @constants.group_by do |constant| constant.section end
|
674
|
-
constants.default = []
|
675
|
-
|
676
725
|
attributes = @attributes.group_by do |attribute| attribute.section end
|
726
|
+
|
727
|
+
constants.default = []
|
677
728
|
attributes.default = []
|
678
729
|
|
679
730
|
sort_sections.each do |section|
|
@@ -748,8 +799,8 @@ class RDoc::Context < RDoc::CodeObject
|
|
748
799
|
##
|
749
800
|
# Finds a file with +name+ in this context
|
750
801
|
|
751
|
-
def find_file_named
|
752
|
-
|
802
|
+
def find_file_named name
|
803
|
+
@store.find_file_named name
|
753
804
|
end
|
754
805
|
|
755
806
|
##
|
@@ -819,21 +870,21 @@ class RDoc::Context < RDoc::CodeObject
|
|
819
870
|
# look for a class or module 'symbol'
|
820
871
|
case symbol
|
821
872
|
when /^::/ then
|
822
|
-
result =
|
873
|
+
result = @store.find_class_or_module symbol
|
823
874
|
when /^(\w+):+(.+)$/
|
824
875
|
suffix = $2
|
825
876
|
top = $1
|
826
877
|
searched = self
|
827
|
-
|
878
|
+
while searched do
|
828
879
|
mod = searched.find_module_named(top)
|
829
880
|
break unless mod
|
830
|
-
result =
|
881
|
+
result = @store.find_class_or_module "#{mod.full_name}::#{suffix}"
|
831
882
|
break if result || searched.is_a?(RDoc::TopLevel)
|
832
883
|
searched = searched.parent
|
833
884
|
end
|
834
885
|
else
|
835
886
|
searched = self
|
836
|
-
|
887
|
+
while searched do
|
837
888
|
result = searched.find_module_named(symbol)
|
838
889
|
break if result || searched.is_a?(RDoc::TopLevel)
|
839
890
|
searched = searched.parent
|
@@ -1079,8 +1130,8 @@ class RDoc::Context < RDoc::CodeObject
|
|
1079
1130
|
end
|
1080
1131
|
|
1081
1132
|
##
|
1082
|
-
# Sorts sections alphabetically (default) or in TomDoc
|
1083
|
-
# Internal, Deprecated)
|
1133
|
+
# Sorts sections alphabetically (default) or in TomDoc fashion (none,
|
1134
|
+
# Public, Internal, Deprecated)
|
1084
1135
|
|
1085
1136
|
def sort_sections
|
1086
1137
|
titles = @sections.map { |title, _| title }
|
@@ -1122,10 +1173,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
1122
1173
|
enclosing.modules_hash.delete mod.name
|
1123
1174
|
|
1124
1175
|
klass = RDoc::ClassModule.from_module class_type, mod
|
1176
|
+
klass.store = @store
|
1125
1177
|
|
1126
1178
|
# if it was there, then we keep it even if done_documenting
|
1127
|
-
|
1128
|
-
enclosing.classes_hash[mod.name]
|
1179
|
+
@store.classes_hash[mod.full_name] = klass
|
1180
|
+
enclosing.classes_hash[mod.name] = klass
|
1129
1181
|
|
1130
1182
|
klass
|
1131
1183
|
end
|