summaryrefslogtreecommitdiff
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.rb43
1 files changed, 14 insertions, 29 deletions
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index 2c8a19f608..e546fe2141 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -8,9 +8,6 @@
# by Keiju ISHITSUKA (Nippon Rational Inc.)
#
-require 'ripper'
-require_relative 'ripper_state_lex'
-
##
# Extracts code elements from a source file returning a TopLevel object
# containing the constituent file elements.
@@ -141,6 +138,9 @@ require_relative 'ripper_state_lex'
# Note that by default, the :method: directive will be ignored if there is a
# standard rdocable item following it.
+require 'ripper'
+require_relative 'ripper_state_lex'
+
class RDoc::Parser::Ruby < RDoc::Parser
parse_files_matching(/\.rbw?$/)
@@ -164,7 +164,15 @@ class RDoc::Parser::Ruby < RDoc::Parser
def initialize(top_level, file_name, content, options, stats)
super
- content = handle_tab_width(content)
+ if /\t/ =~ content then
+ tab_width = @options.tab_width
+ content = content.split(/\n/).map do |line|
+ 1 while line.gsub!(/\t+/) {
+ ' ' * (tab_width*$&.length - $`.length % tab_width)
+ } && $~
+ line
+ end.join("\n")
+ end
@size = 0
@token_listeners = nil
@@ -392,29 +400,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
##
- # Skip opening parentheses and yield the block.
- # Skip closing parentheses too when exists.
-
- def skip_parentheses(&block)
- left_tk = peek_tk
-
- if :on_lparen == left_tk[:kind]
- get_tk
-
- ret = skip_parentheses(&block)
-
- right_tk = peek_tk
- if :on_rparen == right_tk[:kind]
- get_tk
- end
-
- ret
- else
- yield
- end
- end
-
- ##
# Return a superclass, which can be either a constant of an expression
def get_class_specification
@@ -848,7 +833,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
cls = parse_class_regular container, declaration_context, single,
name_t, given_name, comment
elsif name_t[:kind] == :on_op && name_t[:text] == '<<'
- case name = skip_parentheses { get_class_specification }
+ case name = get_class_specification
when 'self', container.name
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
parse_statements container, SINGLE
@@ -2134,7 +2119,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then
return
elsif :on_comment == tk[:kind] or :on_embdoc == tk[:kind] then
- return unless tk[:text] =~ /:?\b([\w-]+):\s*(.*)/
+ return unless tk[:text] =~ /\s*:?([\w-]+):\s*(.*)/
directive = $1.downcase