summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 01:30:18 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 01:30:18 +0000
commit95e213d3542034e0fd2613de6990a7ddfe5718ca (patch)
tree76ec64fccb338dbcbc4d3f07c2f494ef9b7fe1ff
parent41fb243684f60e231fc77ec54752fe4e844523d5 (diff)
Merge rdoc-6.1.0.beta1.
* https://github.com/ruby/rdoc/compare/v6.0.4...v6.1.0.beta1 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rdoc.rb6
-rw-r--r--lib/rdoc/cross_reference.rb36
-rw-r--r--lib/rdoc/generator/markup.rb14
-rw-r--r--lib/rdoc/generator/template/json_index/js/navigation.js7
-rw-r--r--lib/rdoc/markup/to_html.rb2
-rw-r--r--lib/rdoc/markup/to_html_crossref.rb3
-rw-r--r--lib/rdoc/parser/ripper_state_lex.rb104
-rw-r--r--lib/rdoc/parser/ruby.rb173
-rw-r--r--lib/rdoc/rdoc.gemspec14
-rw-r--r--lib/rdoc/tom_doc.rb12
-rw-r--r--lib/rdoc/version.rb8
-rw-r--r--test/rdoc/test_rdoc_any_method.rb31
-rw-r--r--test/rdoc/test_rdoc_class_module.rb1
-rw-r--r--test/rdoc/test_rdoc_context.rb2
-rw-r--r--test/rdoc/test_rdoc_cross_reference.rb29
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_crossref.rb15
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb205
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb15
-rw-r--r--test/rdoc/test_rdoc_store.rb4
-rw-r--r--test/rdoc/test_rdoc_tom_doc.rb60
-rw-r--r--test/rdoc/xref_data.rb14
-rw-r--r--test/rdoc/xref_test_case.rb15
22 files changed, 576 insertions, 194 deletions
diff --git a/lib/rdoc.rb b/lib/rdoc.rb
index a428867..fc8ad9e 100644
--- a/lib/rdoc.rb
+++ b/lib/rdoc.rb
@@ -62,10 +62,7 @@ module RDoc
class Error < RuntimeError; end
- ##
- # RDoc version you are using
-
- VERSION = '6.0.4'
+ require 'rdoc/version'
##
# Method visibilities
@@ -146,7 +143,6 @@ module RDoc
autoload :KNOWN_CLASSES, 'rdoc/known_classes'
- autoload :RipperStateLex, 'rdoc/parser/ripper_state_lex'
autoload :TokenStream, 'rdoc/token_stream'
autoload :Comment, 'rdoc/comment'
diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb
index d76ebaf..3f5f33b 100644
--- a/lib/rdoc/cross_reference.rb
+++ b/lib/rdoc/cross_reference.rb
@@ -19,7 +19,7 @@ class RDoc::CrossReference
#
# See CLASS_REGEXP_STR
- METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>)(?:\([\w.+*/=<>-]*\))?'
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
##
# Regular expressions matching text that should potentially have
@@ -127,23 +127,41 @@ class RDoc::CrossReference
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
type = $2
- type = '' if type == '.' # will find either #method or ::method
- method = "#{type}#{$3}"
+ if '.' == type # will find either #method or ::method
+ method = $3
+ else
+ method = "#{type}#{$3}"
+ end
container = @context.find_symbol_module($1)
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
type = $1
- type = '' if type == '.'
- method = "#{type}#{$2}"
+ if '.' == type
+ method = $2
+ else
+ method = "#{type}#{$2}"
+ end
container = @context
else
+ type = nil
container = nil
end
if container then
- ref = container.find_local_symbol method
-
- unless ref || RDoc::TopLevel === container then
- ref = container.find_ancestor_local_symbol method
+ unless RDoc::TopLevel === container then
+ if '.' == type then
+ if 'new' == method then # AnyClassName.new will be class method
+ ref = container.find_local_symbol method
+ ref = container.find_ancestor_local_symbol method unless ref
+ else
+ ref = container.find_local_symbol "::#{method}"
+ ref = container.find_ancestor_local_symbol "::#{method}" unless ref
+ ref = container.find_local_symbol "##{method}" unless ref
+ ref = container.find_ancestor_local_symbol "##{method}" unless ref
+ end
+ else
+ ref = container.find_local_symbol method
+ ref = container.find_ancestor_local_symbol method unless ref
+ end
end
end
diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb
index fef982d..41e1324 100644
--- a/lib/rdoc/generator/markup.rb
+++ b/lib/rdoc/generator/markup.rb
@@ -65,16 +65,6 @@ end
class RDoc::MethodAttr
- @add_line_numbers = false
-
- class << self
- ##
- # Allows controlling whether <tt>#markup_code</tt> adds line numbers to
- # the source code.
-
- attr_accessor :add_line_numbers
- end
-
##
# Prepend +src+ with line numbers. Relies on the first line of a source
# code listing having:
@@ -106,7 +96,7 @@ class RDoc::MethodAttr
##
# Turns the method's token stream into HTML.
#
- # Prepends line numbers if +add_line_numbers+ is true.
+ # Prepends line numbers if +options.line_numbers+ is true.
def markup_code
return '' unless @token_stream
@@ -126,7 +116,7 @@ class RDoc::MethodAttr
end
src.gsub!(/^#{' ' * indent}/, '') if indent > 0
- add_line_numbers(src) if RDoc::MethodAttr.add_line_numbers
+ add_line_numbers(src) if options.line_numbers
src
end
diff --git a/lib/rdoc/generator/template/json_index/js/navigation.js b/lib/rdoc/generator/template/json_index/js/navigation.js
index e412681..43c5118 100644
--- a/lib/rdoc/generator/template/json_index/js/navigation.js
+++ b/lib/rdoc/generator/template/json_index/js/navigation.js
@@ -59,9 +59,8 @@ Navigation = new function() {
}
break;
case 13: //Event.KEY_RETURN:
- if (this.$current)
- e.preventDefault();
- this.select(this.$current);
+ if (this.$current) e.preventDefault();
+ this.select(this.$current);
break;
}
if (e.ctrlKey && e.shiftKey) this.select(this.$current);
@@ -80,7 +79,7 @@ Navigation = new function() {
var go = function() {
if (!_this.moveTimeout) return;
_this[isDown ? 'moveDown' : 'moveUp']();
- _this.moveTimout = setTimeout(go, 100);
+ _this.moveTimeout = setTimeout(go, 100);
}
this.moveTimeout = setTimeout(go, 200);
}
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb
index c5e1f07..79b13e1 100644
--- a/lib/rdoc/markup/to_html.rb
+++ b/lib/rdoc/markup/to_html.rb
@@ -200,7 +200,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
content = if verbatim.ruby? or parseable? text then
begin
- tokens = RDoc::RipperStateLex.parse text
+ tokens = RDoc::Parser::RipperStateLex.parse text
klass = ' class="ruby"'
result = RDoc::TokenStream.to_html tokens
diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb
index 2911aee..cc93021 100644
--- a/lib/rdoc/markup/to_html_crossref.rb
+++ b/lib/rdoc/markup/to_html_crossref.rb
@@ -135,9 +135,6 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
ref = @cross_reference.resolve name, text
- text = ref.output_name @context if
- RDoc::MethodAttr === ref and text == original_name
-
case ref
when String then
ref
diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb
index 43f7dc1..773a830 100644
--- a/lib/rdoc/parser/ripper_state_lex.rb
+++ b/lib/rdoc/parser/ripper_state_lex.rb
@@ -1,10 +1,12 @@
# frozen_string_literal: true
require 'ripper'
-class RDoc::RipperStateLex
+class RDoc::Parser::RipperStateLex
# TODO: Remove this constants after Ruby 2.4 EOL
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
+ Token = Struct.new(:line_no, :char_no, :kind, :text, :state)
+
EXPR_NONE = 0
EXPR_BEG = 1
EXPR_END = 2
@@ -48,7 +50,7 @@ class RDoc::RipperStateLex
@continue = false
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
end
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_ignored_nl(tok, data)
@@ -59,7 +61,7 @@ class RDoc::RipperStateLex
@continue = false
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
end
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_op(tok, data)
@@ -101,7 +103,7 @@ class RDoc::RipperStateLex
@lex_state = EXPR_BEG
end
end
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_kw(tok, data)
@@ -114,7 +116,7 @@ class RDoc::RipperStateLex
@continue = true
@in_fname = true
when 'if', 'unless', 'while', 'until'
- if ((EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if
+ if ((EXPR_MID | EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if
@lex_state = EXPR_BEG | EXPR_LABEL
else
@lex_state = EXPR_BEG
@@ -130,54 +132,54 @@ class RDoc::RipperStateLex
@lex_state = EXPR_END
end
end
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_tstring_beg(tok, data)
@lex_state = EXPR_BEG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_tstring_end(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_CHAR(tok, data)
@lex_state = EXPR_END
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_period(tok, data)
@lex_state = EXPR_DOT
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_int(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_float(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_rational(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_imaginary(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_symbeg(tok, data)
@lex_state = EXPR_FNAME
@continue = true
@in_fname = true
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
private def on_variables(event, tok, data)
@@ -196,7 +198,7 @@ class RDoc::RipperStateLex
else
@lex_state = EXPR_CMDARG
end
- @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, event, tok, @lex_state))
end
def on_ident(tok, data)
@@ -225,32 +227,32 @@ class RDoc::RipperStateLex
def on_lparen(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_rparen(tok, data)
@lex_state = EXPR_ENDFN
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_lbrace(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_rbrace(tok, data)
@lex_state = EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_lbracket(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_rbracket(tok, data)
@lex_state = EXPR_ENDARG
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_const(tok, data)
@@ -262,36 +264,36 @@ class RDoc::RipperStateLex
else
@lex_state = EXPR_CMDARG
end
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_sp(tok, data)
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_comma(tok, data)
@lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_comment(tok, data)
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_ignored_sp(tok, data)
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
end
def on_heredoc_end(tok, data)
- @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, __method__, tok, @lex_state))
@lex_state = EXPR_BEG
end
def on_default(event, tok, data)
reset
- @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => @lex_state})
+ @callback.call(Token.new(lineno, column, event, tok, @lex_state))
end
def each(&block)
@@ -306,7 +308,7 @@ class RDoc::RipperStateLex
end
def on_default(event, tok, data)
- @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => state})
+ @callback.call(Token.new(lineno, column, event, tok, state))
end
def each(&block)
@@ -367,7 +369,7 @@ class RDoc::RipperStateLex
private def get_symbol_tk(tk)
is_symbol = true
- symbol_tk = { :line_no => tk[:line_no], :char_no => tk[:char_no], :kind => :on_symbol }
+ symbol_tk = Token.new(tk.line_no, tk.char_no, :on_symbol)
if ":'" == tk[:text] or ':"' == tk[:text]
tk1 = get_string_tk(tk)
symbol_tk[:text] = tk1[:text]
@@ -436,13 +438,7 @@ class RDoc::RipperStateLex
end
end
end
- {
- :line_no => tk[:line_no],
- :char_no => tk[:char_no],
- :kind => kind,
- :text => string,
- :state => state
- }
+ Token.new(tk.line_no, tk.char_no, kind, string, state)
end
private def get_regexp_tk(tk)
@@ -460,13 +456,7 @@ class RDoc::RipperStateLex
string = string + inner_str_tk[:text]
end
end
- {
- :line_no => tk[:line_no],
- :char_no => tk[:char_no],
- :kind => :on_regexp,
- :text => string,
- :state => state
- }
+ Token.new(tk.line_no, tk.char_no, :on_regexp, string, state)
end
private def get_embdoc_tk(tk)
@@ -475,13 +465,7 @@ class RDoc::RipperStateLex
string = string + embdoc_tk[:text]
end
string = string + embdoc_tk[:text]
- {
- :line_no => tk[:line_no],
- :char_no => tk[:char_no],
- :kind => :on_embdoc,
- :text => string,
- :state => embdoc_tk[:state]
- }
+ Token.new(tk.line_no, tk.char_no, :on_embdoc, string, embdoc_tk.state)
end
private def get_heredoc_tk(heredoc_name, indent)
@@ -499,13 +483,7 @@ class RDoc::RipperStateLex
start_tk = tk unless start_tk
prev_tk = tk unless prev_tk
@buf.unshift tk # closing heredoc
- heredoc_tk = {
- :line_no => start_tk[:line_no],
- :char_no => start_tk[:char_no],
- :kind => :on_heredoc,
- :text => string,
- :state => prev_tk[:state]
- }
+ heredoc_tk = Token.new(start_tk.line_no, start_tk.char_no, :on_heredoc, string, prev_tk.state)
@buf.unshift heredoc_tk
end
@@ -561,13 +539,7 @@ class RDoc::RipperStateLex
end
end
text = "#{start_token}#{string}#{end_token}"
- {
- :line_no => line_no,
- :char_no => char_no,
- :kind => :on_dstring,
- :text => text,
- :state => state
- }
+ Token.new(line_no, char_no, :on_dstring, text, state)
end
private def get_op_tk(tk)
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index a90622f..8b9ecc1 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -141,6 +141,7 @@ $TOKEN_DEBUG ||= nil
# standard rdocable item following it.
require 'ripper'
+require_relative 'ripper_state_lex'
class RDoc::Parser::Ruby < RDoc::Parser
@@ -178,7 +179,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
@size = 0
@token_listeners = nil
content = RDoc::Encoding.remove_magic_comment content
- @scanner = RDoc::RipperStateLex.parse(content)
+ @scanner = RDoc::Parser::RipperStateLex.parse(content)
@content = content
@scanner_point = 0
@prev_seek = nil
@@ -249,10 +250,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
tk = get_tk
while tk && (:on_comment == tk[:kind] or :on_embdoc == tk[:kind])
- if first_line and tk[:text] =~ /\A#!/ then
+ comment_body = retrieve_comment_body(tk)
+ if first_line and comment_body =~ /\A#!/ then
skip_tkspace
tk = get_tk
- elsif first_line and tk[:text] =~ /\A#\s*-\*-/ then
+ elsif first_line and comment_body =~ /\A#\s*-\*-/ then
first_line = false
skip_tkspace
tk = get_tk
@@ -261,7 +263,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
first_comment_tk_kind = tk[:kind]
first_line = false
- comment << tk[:text]
+ comment << comment_body
tk = get_tk
if :on_nl === tk then
@@ -444,28 +446,83 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
##
- # Get a constant that may be surrounded by parens
+ # Get an included module that may be surrounded by parens
- def get_constant_with_optional_parens
+ def get_included_module_with_optional_parens
skip_tkspace false
+ get_tkread
+ tk = get_tk
+ end_token = get_end_token tk
+ return '' unless end_token
nest = 0
+ continue = false
+ only_constant = true
- while :on_lparen == (tk = peek_tk)[:kind] do
- get_tk
- skip_tkspace
- nest += 1
- end
-
- name = get_constant
-
- while nest > 0
- skip_tkspace
+ while tk != nil do
+ is_element_of_constant = false
+ case tk[:kind]
+ when :on_semicolon then
+ break if nest == 0
+ when :on_lbracket then
+ nest += 1
+ when :on_rbracket then
+ nest -= 1
+ when :on_lbrace then
+ nest += 1
+ when :on_rbrace then
+ nest -= 1
+ if nest <= 0
+ # we might have a.each { |i| yield i }
+ unget_tk(tk) if nest < 0
+ break
+ end
+ when :on_lparen then
+ nest += 1
+ when end_token[:kind] then
+ if end_token[:kind] == :on_rparen
+ nest -= 1
+ break if nest <= 0
+ else
+ break if nest <= 0
+ end
+ when :on_rparen then
+ nest -= 1
+ when :on_comment, :on_embdoc then
+ @read.pop
+ if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
+ (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
+ break if !continue and nest <= 0
+ end
+ when :on_comma then
+ continue = true
+ when :on_ident then
+ continue = false if continue
+ when :on_kw then
+ case tk[:text]
+ when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
+ nest += 1
+ when 'if', 'unless', 'while', 'until', 'rescue'
+ # postfix if/unless/while/until/rescue must be EXPR_LABEL
+ nest += 1 unless (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0
+ when 'end'
+ nest -= 1
+ break if nest == 0
+ end
+ when :on_const then
+ is_element_of_constant = true
+ when :on_op then
+ is_element_of_constant = true if '::' == tk[:text]
+ end
+ only_constant = false unless is_element_of_constant
tk = get_tk
- nest -= 1 if :on_rparen == tk[:kind]
end
- name
+ if only_constant
+ get_tkread_clean(/\s+/, ' ')
+ else
+ ''
+ end
end
##
@@ -479,17 +536,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
def get_end_token tk # :nodoc:
case tk[:kind]
when :on_lparen
- {
- :kind => :on_rparen,
- :text => ')'
- }
+ token = RDoc::Parser::RipperStateLex::Token.new
+ token[:kind] = :on_rparen
+ token[:text] = ')'
+ token
when :on_rparen
nil
else
- {
- :kind => :on_nl,
- :text => "\n"
- }
+ token = RDoc::Parser::RipperStateLex::Token.new
+ token[:kind] = :on_nl
+ token[:text] = "\n"
+ token
end
end
@@ -739,9 +796,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
when end_token
if end_token == :on_rparen
nest -= 1
- break if RDoc::RipperStateLex.end?(tk) and nest <= 0
+ break if RDoc::Parser::RipperStateLex.end?(tk) and nest <= 0
else
- break if RDoc::RipperStateLex.end?(tk)
+ break if RDoc::Parser::RipperStateLex.end?(tk)
end
when :on_comment, :on_embdoc
unget_tk(tk)
@@ -959,7 +1016,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
nest += 1
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
- if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
+ if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
nest += 1
end
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
@@ -967,7 +1024,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
nest -= 1
elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
unget_tk tk
- if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
+ if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
body = get_tkread_clean(/^[ \t]+/, '')
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
break
@@ -983,7 +1040,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
break
end
elsif :on_nl == tk[:kind] then
- if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
+ if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
unget_tk tk
break
end
@@ -1047,10 +1104,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
record_location meth
meth.start_collecting_tokens
- indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
- position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
+ indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
+ position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
+ newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [position_comment, newline, indent]
meth.params =
@@ -1090,10 +1147,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth.line = line_no
meth.start_collecting_tokens
- indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
- position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
+ indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
+ position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
+ newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [position_comment, newline, indent]
meth.call_seq = signature
@@ -1117,7 +1174,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
loop do
skip_tkspace_comment
- name = get_constant_with_optional_parens
+ name = get_included_module_with_optional_parens
unless name.empty? then
obj = container.add klass, name, comment
@@ -1258,10 +1315,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
remove_token_listener self
meth.start_collecting_tokens
- indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
- position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
+ indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
+ position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
+ newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [position_comment, newline, indent]
meth.add_tokens @token_stream
@@ -1361,10 +1418,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth.line = line_no
meth.start_collecting_tokens
- indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
- token = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
+ indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
+ token = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
token[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
+ newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [token, newline, indent]
meth.add_tokens @token_stream
@@ -1530,6 +1587,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
case tk[:kind]
when :on_semicolon then
break if nest == 0
+ when :on_lbracket then
+ nest += 1
+ when :on_rbracket then
+ nest -= 1
when :on_lbrace then
nest += 1
when :on_rbrace then
@@ -1553,7 +1614,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
when :on_comment, :on_embdoc then
@read.pop
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
- (!continue or (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) != 0) then
+ (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
if method && method.block_params.nil? then
unget_tk tk
read_documentation_modifiers method, modifiers
@@ -1655,6 +1716,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
##
+ # Retrieve comment body without =begin/=end
+
+ def retrieve_comment_body(tk)
+ if :on_embdoc == tk[:kind]
+ tk[:text].gsub(/\A=begin.*\n/, '').gsub(/=end\n?\z/, '')
+ else
+ tk[:text]
+ end
+ end
+
+ ##
# The core of the Ruby parser.
def parse_statements(container, single = NORMAL, current_method = nil,
@@ -1707,10 +1779,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
- comment += tk[:text]
- comment += "\n" unless "\n" == tk[:text].chars.to_a.last
+ comment_body = retrieve_comment_body(tk)
+ comment += comment_body
+ comment += "\n" unless "\n" == comment_body.chars.to_a.last
- if tk[:text].size > 1 && "\n" == tk[:text].chars.to_a.last then
+ if comment_body.size > 1 && "\n" == comment_body.chars.to_a.last then
skip_tkspace false # leading spaces
end
tk = get_tk
@@ -1758,7 +1831,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
when 'until', 'while' then
- if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
+ if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
nest += 1
skip_optional_do_after_expression
end
@@ -1774,7 +1847,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
skip_optional_do_after_expression
when 'case', 'do', 'if', 'unless', 'begin' then
- if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
+ if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
nest += 1
end
diff --git a/lib/rdoc/rdoc.gemspec b/lib/rdoc/rdoc.gemspec
index 59d8fb5..efef186 100644
--- a/lib/rdoc/rdoc.gemspec
+++ b/lib/rdoc/rdoc.gemspec
@@ -1,14 +1,8 @@
begin
- require_relative "lib/rdoc"
+ require_relative "lib/rdoc/version"
rescue LoadError
- begin
- # for Ruby repository
- require_relative "../rdoc"
- rescue LoadError
- # for JRuby
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
- require "rdoc"
- end
+ # for Ruby repository
+ require_relative "version"
end
Gem::Specification.new do |s|
@@ -38,7 +32,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
s.executables = ["rdoc", "ri"]
s.require_paths = ["lib"]
# for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/inline.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/special.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "rdoc.gemspec"]
+ s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/inline.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/special.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "lib/rdoc/version.rb", "rdoc.gemspec"]
# files from .gitignore
s.files << "lib/rdoc/rd/block_parser.rb" << "lib/rdoc/rd/inline_parser.rb" << "lib/rdoc/markdown.rb" << "lib/rdoc/markdown/literals.rb"
diff --git a/lib/rdoc/tom_doc.rb b/lib/rdoc/tom_doc.rb
index 2b594b7..625a6b5 100644
--- a/lib/rdoc/tom_doc.rb
+++ b/lib/rdoc/tom_doc.rb
@@ -180,12 +180,19 @@ class RDoc::TomDoc < RDoc::Markup::Parser
case type
when :TEXT then
- @section = 'Returns' if data =~ /\AReturns/
+ @section = 'Returns' if data =~ /\A(Returns|Raises)/
paragraph << data
when :NEWLINE then
if :TEXT == peek_token[0] then
- paragraph << ' '
+ # Lines beginning with 'Raises' in the Returns section should not be
+ # treated as multiline text
+ if 'Returns' == @section and
+ peek_token[1].start_with?('Raises') then
+ break
+ else
+ paragraph << ' '
+ end
else
break
end
@@ -255,4 +262,3 @@ class RDoc::TomDoc < RDoc::Markup::Parser
end
end
-
diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb
new file mode 100644
index 0000000..5139f8d
--- /dev/null
+++ b/lib/rdoc/version.rb
@@ -0,0 +1,8 @@
+module RDoc
+
+ ##
+ # RDoc version you are using
+
+ VERSION = '6.1.0.beta1'
+
+end
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb
index b5281f6..6dd46b0 100644
--- a/test/rdoc/test_rdoc_any_method.rb
+++ b/test/rdoc/test_rdoc_any_method.rb
@@ -85,6 +85,33 @@ method(a, b) { |c, d| ... }
assert_equal expected, @c2_a.markup_code
end
+ def test_markup_code_with_line_numbers
+ position_comment = "# File #{@file_name}, line 1"
+ tokens = [
+ { :line_no => 1, :char_no => 0, :kind => :on_comment, :text => position_comment },
+ { :line_no => 1, :char_no => position_comment.size, :kind => :on_nl, :text => "\n" },
+ { :line_no => 2, :char_no => 0, :kind => :on_const, :text => 'A' },
+ { :line_no => 2, :char_no => 1, :kind => :on_nl, :text => "\n" },
+ { :line_no => 3, :char_no => 0, :kind => :on_const, :text => 'B' }
+ ]
+
+ @c2_a.collect_tokens
+ @c2_a.add_tokens(*tokens)
+
+ assert_equal <<-EXPECTED.chomp, @c2_a.markup_code
+<span class="ruby-comment"># File xref_data.rb, line 1</span>
+<span class="ruby-constant">A</span>
+<span class="ruby-constant">B</span>
+ EXPECTED
+
+ @options.line_numbers = true
+ assert_equal <<-EXPECTED.chomp, @c2_a.markup_code
+ <span class="ruby-comment"># File xref_data.rb</span>
+<span class="line-num">1</span> <span class="ruby-constant">A</span>
+<span class="line-num">2</span> <span class="ruby-constant">B</span>
+ EXPECTED
+ end
+
def test_markup_code_empty
assert_equal '', @c2_a.markup_code
end
@@ -165,7 +192,7 @@ method(a, b) { |c, d| ... }
end
def test_marshal_load_class_method
- class_method = Marshal.load Marshal.dump(@c1.method_list.first)
+ class_method = Marshal.load Marshal.dump(@c1.find_class_method_named 'm')
assert_equal 'C1::m', class_method.full_name
assert_equal 'C1', class_method.parent_name
@@ -174,7 +201,7 @@ method(a, b) { |c, d| ... }
end
def test_marshal_load_instance_method
- instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
+ instance_method = Marshal.load Marshal.dump(@c1.find_instance_method_named 'm')
assert_equal 'C1#m', instance_method.full_name
assert_equal 'C1', instance_method.parent_name
diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb
index 3dc2a42..cc53a13 100644
--- a/test/rdoc/test_rdoc_class_module.rb
+++ b/test/rdoc/test_rdoc_class_module.rb
@@ -91,6 +91,7 @@ class TestRDocClassModule < XrefTestCase
assert @c1.document_self_or_methods
+ @c1_plus.document_self = false
@c1_m.document_self = false
assert @c1.document_self_or_methods
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index 5a9c5db..be17496 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -660,7 +660,7 @@ class TestRDocContext < XrefTestCase
'instance' => {
:private => [],
:protected => [],
- :public => [@c1_m],
+ :public => [@c1_plus, @c1_m],
},
'class' => {
:private => [],
diff --git a/test/rdoc/test_rdoc_cross_reference.rb b/test/rdoc/test_rdoc_cross_reference.rb
index a294553..8233fe3 100644
--- a/test/rdoc/test_rdoc_cross_reference.rb
+++ b/test/rdoc/test_rdoc_cross_reference.rb
@@ -107,18 +107,24 @@ class TestRDocCrossReference < XrefTestCase
end
def test_resolve_method
- assert_ref @c1__m, 'm'
- assert_ref @c1_m, '#m'
- assert_ref @c1__m, '::m'
-
- assert_ref @c1_m, 'C1#m'
- assert_ref @c1__m, 'C1.m'
- assert_ref @c1__m, 'C1::m'
+ assert_ref @c1__m, 'm'
+ assert_ref @c1__m, '::m'
+ assert_ref @c1_m, '#m'
+ assert_ref @c1_plus, '#+'
+
+ assert_ref @c1_m, 'C1#m'
+ assert_ref @c1_plus, 'C1#+'
+ assert_ref @c1__m, 'C1.m'
+ assert_ref @c1__m, 'C1::m'
assert_ref @c1_m, 'C1#m'
assert_ref @c1_m, 'C1#m()'
assert_ref @c1_m, 'C1#m(*)'
+ assert_ref @c1_plus, 'C1#+'
+ assert_ref @c1_plus, 'C1#+()'
+ assert_ref @c1_plus, 'C1#+(*)'
+
assert_ref @c1__m, 'C1.m'
assert_ref @c1__m, 'C1.m()'
assert_ref @c1__m, 'C1.m(*)'
@@ -139,6 +145,15 @@ class TestRDocCrossReference < XrefTestCase
assert_ref @c2_c3_m, '::C2::C3#m(*)'
end
+ def test_resolve_the_same_name_in_instance_and_class_method
+ assert_ref @c9_a_i_foo, 'C9::A#foo'
+ assert_ref @c9_a_c_bar, 'C9::A::bar'
+ assert_ref @c9_b_c_foo, 'C9::B::foo'
+ assert_ref @c9_b_i_bar, 'C9::B#bar'
+ assert_ref @c9_b_c_foo, 'C9::B.foo'
+ assert_ref @c9_a_c_bar, 'C9::B.bar'
+ end
+
def test_resolve_method_equals3
m = RDoc::AnyMethod.new '', '==='
@c1.add_method m
diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
index 73b76de..63fc95f 100644
--- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb
+++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
@@ -59,7 +59,7 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
def test_convert_RDOCLINK_rdoc_ref_method
result = @to.convert 'rdoc-ref:C1#m'
- assert_equal para("<a href=\"C1.html#method-i-m\">#m</a>"), result
+ assert_equal para("<a href=\"C1.html#method-i-m\">C1#m</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method_label
@@ -75,13 +75,13 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
result = @to.convert 'rdoc-ref:C1#%'
- assert_equal para("<a href=\"C1.html#method-i-25\">#%</a>"), result
+ assert_equal para("<a href=\"C1.html#method-i-25\">C1#%</a>"), result
m.singleton = true
result = @to.convert 'rdoc-ref:C1::%'
- assert_equal para("<a href=\"C1.html#method-c-25\">::%</a>"), result
+ assert_equal para("<a href=\"C1.html#method-c-25\">C1::%</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method_percent_label
@@ -200,11 +200,16 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
def test_link
assert_equal 'n', @to.link('n', 'n')
- assert_equal '<a href="C1.html#method-c-m">::m</a>', @to.link('m', 'm')
+ assert_equal '<a href="C1.html#method-c-m">m</a>', @to.link('m', 'm')
+ end
+
+ def test_link_for_method_traverse
+ @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c9
+ assert_equal '<a href="C9/A.html#method-i-foo">C9::B#foo</a>', @to.link('C9::B#foo', 'C9::B#foo')
end
def test_link_class_method_full
- assert_equal '<a href="Parent.html#method-c-m">Parent.m</a>',
+ assert_equal '<a href="Parent.html#method-c-m">Parent::m</a>',
@to.link('Parent::m', 'Parent::m')
end
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index eb9c6b2..8e31141 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -73,7 +73,7 @@ class C; end
comment = parser.collect_first_comment
- assert_equal RDoc::Comment.new("=begin\nfirst\n=end\n", @top_level), comment
+ assert_equal RDoc::Comment.new("first\n", @top_level), comment
end
def test_get_class_or_module
@@ -1313,8 +1313,16 @@ EOF
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
{ :line_no => 1, :char_no => 1, :kind => :on_sp, :text => '' }
]
+ parsed_stream = foo.token_stream.map { |t|
+ {
+ :line_no => t[:line_no],
+ :char_no => t[:char_no],
+ :kind => t[:kind],
+ :text => t[:text]
+ }
+ }
- assert_equal stream, foo.token_stream
+ assert_equal stream, parsed_stream
end
def test_parse_comment_method_args
@@ -2310,6 +2318,31 @@ end
assert_equal 'C#bar', methods[1].full_name
end
+ def test_parse_statements_postfix_if_unless_with_expr_mid
+ util_parser <<-CODE
+class A
+ class B
+ def foo
+ return if nil
+ end
+ end
+
+ class C
+ end
+end
+ CODE
+
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
+
+ a = @top_level.classes.first
+ assert_equal 'A', a.full_name, 'class A'
+ assert_equal 2, a.classes.length
+ b = a.classes[0]
+ assert_equal 'A::B', b.full_name, 'class A::B'
+ c = a.classes[1]
+ assert_equal 'A::C', c.full_name, 'class A::C'
+ end
+
def test_parse_statements_class_nested
comment = RDoc::Comment.new "##\n# my method\n", @top_level
@@ -3349,11 +3382,11 @@ end
foo = @top_level.classes.first
- assert_equal "=begin rdoc\nFoo comment\n=end", foo.comment.text
+ assert_equal 'Foo comment', foo.comment.text
m = foo.method_list.first
- assert_equal "=begin\nm comment\n=end", m.comment.text
+ assert_equal 'm comment', m.comment.text
end
def test_scan_block_comment_nested # Issue #41
@@ -3375,7 +3408,7 @@ end
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
- assert_equal "=begin rdoc\nfindmeindoc\n=end", foo.comment.text
+ assert_equal 'findmeindoc', foo.comment.text
bar = foo.classes.first
@@ -3386,9 +3419,10 @@ end
def test_scan_block_comment_notflush
##
#
- # The previous test assumes that between the =begin/=end blocs that there is
- # only one line, or minima formatting directives. This test tests for those
- # who use the =begin bloc with longer / more advanced formatting within.
+ # The previous test assumes that between the =begin/=end blocks that there
+ # is only one line, or minima formatting directives. This test tests for
+ # those who use the =begin bloc with longer / more advanced formatting
+ # within.
#
##
content = <<-CONTENT
@@ -3422,12 +3456,12 @@ end
foo = @top_level.classes.first
- assert_equal "=begin rdoc\n\n= DESCRIPTION\n\nThis is a simple test class\n\n= RUMPUS\n\nIs a silly word\n\n=end",
+ assert_equal "= DESCRIPTION\n\nThis is a simple test class\n\n= RUMPUS\n\nIs a silly word",
foo.comment.text
m = foo.method_list.first
- assert_equal "=begin rdoc\nA nice girl\n=end", m.comment.text
+ assert_equal 'A nice girl', m.comment.text
end
def test_scan_class_nested_nodoc
@@ -4018,4 +4052,155 @@ end
assert_equal ['A', 'B', 'B::C'], visible
end
+ def test_parse_include_by_dynamic_definition
+ util_parser <<-CLASS
+module A
+ class B
+ include(Module.new do
+ def e(m)
+ end
+ end)
+ end
+
+ class C
+ end
+
+ class D
+ end
+end
+ CLASS
+
+ @parser.scan
+
+ a = @store.find_module_named 'A'
+ assert_equal 'A', a.full_name
+ a_b = a.find_class_named 'B'
+ assert_equal 'A::B', a_b.full_name
+ a_c = a.find_class_named 'C'
+ assert_equal 'A::C', a_c.full_name
+ a_d = a.find_class_named 'D'
+ assert_equal 'A::D', a_d.full_name
+ end
+
+ def test_parse_include_by_dynamic_definition_without_paren
+ util_parser <<-CLASS
+module A
+ class B
+ include(Module.new do
+ def e m
+ end
+ end)
+ end
+
+ class C
+ end
+
+ class D
+ end
+end
+ CLASS
+
+ @parser.scan
+
+ a = @store.find_module_named 'A'
+ assert_equal 'A', a.full_name
+ a_b = a.find_class_named 'B'
+ assert_equal 'A::B', a_b.full_name
+ a_c = a.find_class_named 'C'
+ assert_equal 'A::C', a_c.full_name
+ a_d = a.find_class_named 'D'
+ assert_equal 'A::D', a_d.full_name
+ end
+
+ def test_parse_include_by_dynamic_definition_via_variable
+ util_parser <<-CLASS
+module A
+ class B
+ m = Module.new do
+ def e(m)
+ end
+ end
+ include m
+ end
+
+ class C
+ end
+
+ class D
+ end
+end
+ CLASS
+
+ @parser.scan
+
+ a = @store.find_module_named 'A'
+ assert_equal 'A', a.full_name
+ a_b = a.find_class_named 'B'
+ assert_equal 'A::B', a_b.full_name
+ a_c = a.find_class_named 'C'
+ assert_equal 'A::C', a_c.full_name
+ a_d = a.find_class_named 'D'
+ assert_equal 'A::D', a_d.full_name
+ end
+
+ def test_parse_include_by_dynamic_definition_with_brace
+ util_parser <<-CLASS
+module A
+ class B
+ extend(e {
+ def f(g)
+ end
+ })
+ end
+
+ class C
+ end
+
+ class D
+ end
+end
+ CLASS
+
+ @parser.scan
+
+ a = @store.find_module_named 'A'
+ assert_equal 'A', a.full_name
+ a_b = a.find_class_named 'B'
+ assert_equal 'A::B', a_b.full_name
+ a_c = a.find_class_named 'C'
+ assert_equal 'A::C', a_c.full_name
+ a_d = a.find_class_named 'D'
+ assert_equal 'A::D', a_d.full_name
+ end
+
+ def test_parse_include_by_dynamic_definition_directly
+ util_parser <<-CLASS
+module A
+ class B
+ include Module.new do
+ def e m
+ end
+ end
+ end
+
+ class C
+ end
+
+ class D
+ end
+end
+ CLASS
+
+ @parser.scan
+
+ a = @store.find_module_named 'A'
+ assert_equal 'A', a.full_name
+ a_b = a.find_class_named 'B'
+ assert_equal 'A::B', a_b.full_name
+ a_c = a.find_class_named 'C'
+ assert_equal 'A::C', a_c.full_name
+ a_d = a.find_class_named 'D'
+ assert_equal 'A::D', a_d.full_name
+ end
+
end
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index 590c109..f636c63 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -699,6 +699,21 @@ class TestRDocRIDriver < RDoc::TestCase
refute_match %r%must not be displayed%, out
end
+ def test_display_name
+ util_store
+
+ out, = capture_io do
+ assert_equal true, @driver.display_name('home:README.rdoc')
+ end
+
+ expected = <<-EXPECTED
+= README
+This is a README
+ EXPECTED
+
+ assert_equal expected, out
+ end
+
def test_display_name_not_found_class
util_store
diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb
index 4246b4c..e5cf752 100644
--- a/test/rdoc/test_rdoc_store.rb
+++ b/test/rdoc/test_rdoc_store.rb
@@ -162,7 +162,7 @@ class TestRDocStore < XrefTestCase
def test_all_classes_and_modules
expected = %w[
- C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1
+ C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 C9 C9::A C9::B
Child
M1 M1::M2
Parent
@@ -213,7 +213,7 @@ class TestRDocStore < XrefTestCase
def test_classes
expected = %w[
- C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1
+ C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 C9 C9::A C9::B
Child
Parent
]
diff --git a/test/rdoc/test_rdoc_tom_doc.rb b/test/rdoc/test_rdoc_tom_doc.rb
index 6a6822d..27a3e6f 100644
--- a/test/rdoc/test_rdoc_tom_doc.rb
+++ b/test/rdoc/test_rdoc_tom_doc.rb
@@ -301,6 +301,44 @@ Returns another thing
assert_equal expected, @TD.parse(text)
end
+ def test_parse_returns_with_raises
+ text = <<-TEXT
+Do some stuff
+
+Returns a thing
+Raises ArgumentError when stuff
+Raises StandardError when stuff
+ TEXT
+ expected =
+ doc(
+ para('Do some stuff'),
+ blank_line,
+ head(3, 'Returns'),
+ blank_line,
+ para('Returns a thing'),
+ para('Raises ArgumentError when stuff'),
+ para('Raises StandardError when stuff'))
+
+ assert_equal expected, @TD.parse(text)
+ end
+
+ def test_parse_raises_without_returns
+ text = <<-TEXT
+Do some stuff
+
+Raises ArgumentError when stuff
+ TEXT
+ expected =
+ doc(
+ para('Do some stuff'),
+ blank_line,
+ head(3, 'Returns'),
+ blank_line,
+ para('Raises ArgumentError when stuff'))
+
+ assert_equal expected, @TD.parse(text)
+ end
+
def test_parse_returns_multiline
text = <<-TEXT
Do some stuff
@@ -320,6 +358,27 @@ Returns a thing
assert_equal expected, @TD.parse(text)
end
+ def test_parse_returns_multiline_and_raises
+ text = <<-TEXT
+Do some stuff
+
+Returns a thing
+ that is multiline
+Raises ArgumentError
+ TEXT
+
+ expected =
+ doc(
+ para('Do some stuff'),
+ blank_line,
+ head(3, 'Returns'),
+ blank_line,
+ para('Returns a thing', ' ', 'that is multiline'),
+ para('Raises ArgumentError'))
+
+ assert_equal expected, @TD.parse(text)
+ end
+
def test_parse_signature
text = <<-TEXT
Do some stuff
@@ -518,4 +577,3 @@ Returns a thing
end
end
-
diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb
index d002b42..aa9faae 100644
--- a/test/rdoc/xref_data.rb
+++ b/test/rdoc/xref_data.rb
@@ -20,6 +20,8 @@ class C1
def m foo
end
+ def +
+ end
end
class C2
@@ -101,6 +103,18 @@ class C8
end
end
+class C9
+ class A
+ def foo() end
+ def self.bar() end
+ end
+
+ class B < A
+ def self.foo() end
+ def bar() end
+ end
+end
+
module M1
def m
end
diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb
index 70b7df4..d42cf39 100644
--- a/test/rdoc/xref_test_case.rb
+++ b/test/rdoc/xref_test_case.rb
@@ -31,9 +31,10 @@ class XrefTestCase < RDoc::TestCase
@rdoc.options = @options
@rdoc.generator = generator
- @c1 = @xref_data.find_module_named 'C1'
- @c1_m = @c1.method_list.last # C1#m
- @c1__m = @c1.method_list.first # C1::m
+ @c1 = @xref_data.find_module_named 'C1'
+ @c1__m = @c1.find_class_method_named 'm' # C1::m
+ @c1_m = @c1.find_instance_method_named 'm' # C1#m
+ @c1_plus = @c1.find_instance_method_named '+'
@c2 = @xref_data.find_module_named 'C2'
@c2_a = @c2.method_list.last
@@ -56,6 +57,14 @@ class XrefTestCase < RDoc::TestCase
@c8 = @xref_data.find_module_named 'C8'
@c8_s1 = @xref_data.find_module_named 'C8::S1'
+ @c9 = @xref_data.find_module_named 'C9'
+ @c9_a = @xref_data.find_module_named 'C9::A'
+ @c9_a_i_foo = @c9_a.method_list.first
+ @c9_a_c_bar = @c9_a.method_list.last
+ @c9_b = @xref_data.find_module_named 'C9::B'
+ @c9_b_c_foo = @c9_b.method_list.first
+ @c9_b_i_bar = @c9_b.method_list.last
+
@m1 = @xref_data.find_module_named 'M1'
@m1_m = @m1.method_list.first