aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/parser/ruby.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/parser/ruby.rb')
-rw-r--r--lib/rdoc/parser/ruby.rb54
1 files changed, 48 insertions, 6 deletions
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index fe461ff389..31e31b5ce9 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -240,7 +240,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# with :: separated named) and return the ultimate name, the associated
# container, and the given name (with the ::).
- def get_class_or_module container
+ def get_class_or_module container, ignore_constants = false
skip_tkspace
name_t = get_tk
given_name = ''
@@ -259,9 +259,16 @@ class RDoc::Parser::Ruby < RDoc::Parser
while TkCOLON2 === peek_tk do
prev_container = container
container = container.find_module_named name_t.name
- container ||= prev_container.add_module RDoc::NormalModule, name_t.name
+ container ||=
+ if ignore_constants then
+ RDoc::Context.new
+ else
+ c = prev_container.add_module RDoc::NormalModule, name_t.name
+ c.ignore unless prev_container.document_children
+ c
+ end
- container.ignore unless prev_container.document_children
+ container.record_location @top_level
get_tk
skip_tkspace false
@@ -663,9 +670,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
##
- # Parses a constant in +context+ with +comment+
+ # Parses a constant in +context+ with +comment+. If +ignore_constants+ is
+ # true, no found constants will be added to RDoc.
- def parse_constant container, tk, comment
+ def parse_constant container, tk, comment, ignore_constants = false
offset = tk.seek
line_no = tk.line_no
@@ -676,6 +684,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
eq_tk = get_tk
+ if TkCOLON2 === eq_tk then
+ unget_tk eq_tk
+ unget_tk tk
+
+ container, name_t, = get_class_or_module container, ignore_constants
+
+ name = name_t.name
+
+ eq_tk = get_tk
+ end
+
unless TkASSIGN === eq_tk then
unget_tk eq_tk
return false
@@ -1335,6 +1354,26 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
##
+ # Parses a rescue
+
+ def parse_rescue
+ skip_tkspace false
+
+ while tk = get_tk
+ case tk
+ when TkNL, TkSEMICOLON then
+ break
+ when TkCOMMA then
+ skip_tkspace false
+
+ get_tk if TkNL === peek_tk
+ end
+
+ skip_tkspace false
+ end
+ end
+
+ ##
# The core of the ruby parser.
def parse_statements(container, single = NORMAL, current_method = nil,
@@ -1407,7 +1446,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
parse_method container, single, tk, comment
when TkCONSTANT then
- unless parse_constant container, tk, comment then
+ unless parse_constant container, tk, comment, current_method then
try_parse_comment = true
end
@@ -1441,6 +1480,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
when TkSUPER then
current_method.calls_super = true if current_method
+ when TkRESCUE then
+ parse_rescue
+
when TkIDENTIFIER then
if nest == 1 and current_method.nil? then
case tk.name