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
This commit is contained in:
parent
41fb243684
commit
95e213d354
@ -62,10 +62,7 @@ module RDoc
|
|||||||
|
|
||||||
class Error < RuntimeError; end
|
class Error < RuntimeError; end
|
||||||
|
|
||||||
##
|
require 'rdoc/version'
|
||||||
# RDoc version you are using
|
|
||||||
|
|
||||||
VERSION = '6.0.4'
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Method visibilities
|
# Method visibilities
|
||||||
@ -146,7 +143,6 @@ module RDoc
|
|||||||
|
|
||||||
autoload :KNOWN_CLASSES, 'rdoc/known_classes'
|
autoload :KNOWN_CLASSES, 'rdoc/known_classes'
|
||||||
|
|
||||||
autoload :RipperStateLex, 'rdoc/parser/ripper_state_lex'
|
|
||||||
autoload :TokenStream, 'rdoc/token_stream'
|
autoload :TokenStream, 'rdoc/token_stream'
|
||||||
|
|
||||||
autoload :Comment, 'rdoc/comment'
|
autoload :Comment, 'rdoc/comment'
|
||||||
|
@ -19,7 +19,7 @@ class RDoc::CrossReference
|
|||||||
#
|
#
|
||||||
# See CLASS_REGEXP_STR
|
# 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
|
# 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
|
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
||||||
type = $2
|
type = $2
|
||||||
type = '' if type == '.' # will find either #method or ::method
|
if '.' == type # will find either #method or ::method
|
||||||
method = "#{type}#{$3}"
|
method = $3
|
||||||
|
else
|
||||||
|
method = "#{type}#{$3}"
|
||||||
|
end
|
||||||
container = @context.find_symbol_module($1)
|
container = @context.find_symbol_module($1)
|
||||||
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
||||||
type = $1
|
type = $1
|
||||||
type = '' if type == '.'
|
if '.' == type
|
||||||
method = "#{type}#{$2}"
|
method = $2
|
||||||
|
else
|
||||||
|
method = "#{type}#{$2}"
|
||||||
|
end
|
||||||
container = @context
|
container = @context
|
||||||
else
|
else
|
||||||
|
type = nil
|
||||||
container = nil
|
container = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if container then
|
if container then
|
||||||
ref = container.find_local_symbol method
|
unless RDoc::TopLevel === container then
|
||||||
|
if '.' == type then
|
||||||
unless ref || RDoc::TopLevel === container then
|
if 'new' == method then # AnyClassName.new will be class method
|
||||||
ref = container.find_ancestor_local_symbol 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,16 +65,6 @@ end
|
|||||||
|
|
||||||
class RDoc::MethodAttr
|
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
|
# Prepend +src+ with line numbers. Relies on the first line of a source
|
||||||
# code listing having:
|
# code listing having:
|
||||||
@ -106,7 +96,7 @@ class RDoc::MethodAttr
|
|||||||
##
|
##
|
||||||
# Turns the method's token stream into HTML.
|
# 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
|
def markup_code
|
||||||
return '' unless @token_stream
|
return '' unless @token_stream
|
||||||
@ -126,7 +116,7 @@ class RDoc::MethodAttr
|
|||||||
end
|
end
|
||||||
src.gsub!(/^#{' ' * indent}/, '') if indent > 0
|
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
|
src
|
||||||
end
|
end
|
||||||
|
@ -59,9 +59,8 @@ Navigation = new function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 13: //Event.KEY_RETURN:
|
case 13: //Event.KEY_RETURN:
|
||||||
if (this.$current)
|
if (this.$current) e.preventDefault();
|
||||||
e.preventDefault();
|
this.select(this.$current);
|
||||||
this.select(this.$current);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (e.ctrlKey && e.shiftKey) this.select(this.$current);
|
if (e.ctrlKey && e.shiftKey) this.select(this.$current);
|
||||||
@ -80,7 +79,7 @@ Navigation = new function() {
|
|||||||
var go = function() {
|
var go = function() {
|
||||||
if (!_this.moveTimeout) return;
|
if (!_this.moveTimeout) return;
|
||||||
_this[isDown ? 'moveDown' : 'moveUp']();
|
_this[isDown ? 'moveDown' : 'moveUp']();
|
||||||
_this.moveTimout = setTimeout(go, 100);
|
_this.moveTimeout = setTimeout(go, 100);
|
||||||
}
|
}
|
||||||
this.moveTimeout = setTimeout(go, 200);
|
this.moveTimeout = setTimeout(go, 200);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|||||||
|
|
||||||
content = if verbatim.ruby? or parseable? text then
|
content = if verbatim.ruby? or parseable? text then
|
||||||
begin
|
begin
|
||||||
tokens = RDoc::RipperStateLex.parse text
|
tokens = RDoc::Parser::RipperStateLex.parse text
|
||||||
klass = ' class="ruby"'
|
klass = ' class="ruby"'
|
||||||
|
|
||||||
result = RDoc::TokenStream.to_html tokens
|
result = RDoc::TokenStream.to_html tokens
|
||||||
|
@ -135,9 +135,6 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|||||||
|
|
||||||
ref = @cross_reference.resolve name, text
|
ref = @cross_reference.resolve name, text
|
||||||
|
|
||||||
text = ref.output_name @context if
|
|
||||||
RDoc::MethodAttr === ref and text == original_name
|
|
||||||
|
|
||||||
case ref
|
case ref
|
||||||
when String then
|
when String then
|
||||||
ref
|
ref
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
require 'ripper'
|
require 'ripper'
|
||||||
|
|
||||||
class RDoc::RipperStateLex
|
class RDoc::Parser::RipperStateLex
|
||||||
# TODO: Remove this constants after Ruby 2.4 EOL
|
# TODO: Remove this constants after Ruby 2.4 EOL
|
||||||
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
|
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
|
||||||
|
|
||||||
|
Token = Struct.new(:line_no, :char_no, :kind, :text, :state)
|
||||||
|
|
||||||
EXPR_NONE = 0
|
EXPR_NONE = 0
|
||||||
EXPR_BEG = 1
|
EXPR_BEG = 1
|
||||||
EXPR_END = 2
|
EXPR_END = 2
|
||||||
@ -48,7 +50,7 @@ class RDoc::RipperStateLex
|
|||||||
@continue = false
|
@continue = false
|
||||||
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
||||||
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
|
end
|
||||||
|
|
||||||
def on_ignored_nl(tok, data)
|
def on_ignored_nl(tok, data)
|
||||||
@ -59,7 +61,7 @@ class RDoc::RipperStateLex
|
|||||||
@continue = false
|
@continue = false
|
||||||
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
||||||
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
|
end
|
||||||
|
|
||||||
def on_op(tok, data)
|
def on_op(tok, data)
|
||||||
@ -101,7 +103,7 @@ class RDoc::RipperStateLex
|
|||||||
@lex_state = EXPR_BEG
|
@lex_state = EXPR_BEG
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def on_kw(tok, data)
|
def on_kw(tok, data)
|
||||||
@ -114,7 +116,7 @@ class RDoc::RipperStateLex
|
|||||||
@continue = true
|
@continue = true
|
||||||
@in_fname = true
|
@in_fname = true
|
||||||
when 'if', 'unless', 'while', 'until'
|
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
|
@lex_state = EXPR_BEG | EXPR_LABEL
|
||||||
else
|
else
|
||||||
@lex_state = EXPR_BEG
|
@lex_state = EXPR_BEG
|
||||||
@ -130,54 +132,54 @@ class RDoc::RipperStateLex
|
|||||||
@lex_state = EXPR_END
|
@lex_state = EXPR_END
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def on_tstring_beg(tok, data)
|
def on_tstring_beg(tok, data)
|
||||||
@lex_state = EXPR_BEG
|
@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
|
end
|
||||||
|
|
||||||
def on_tstring_end(tok, data)
|
def on_tstring_end(tok, data)
|
||||||
@lex_state = EXPR_END | EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_CHAR(tok, data)
|
def on_CHAR(tok, data)
|
||||||
@lex_state = EXPR_END
|
@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
|
end
|
||||||
|
|
||||||
def on_period(tok, data)
|
def on_period(tok, data)
|
||||||
@lex_state = EXPR_DOT
|
@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
|
end
|
||||||
|
|
||||||
def on_int(tok, data)
|
def on_int(tok, data)
|
||||||
@lex_state = EXPR_END | EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_float(tok, data)
|
def on_float(tok, data)
|
||||||
@lex_state = EXPR_END | EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_rational(tok, data)
|
def on_rational(tok, data)
|
||||||
@lex_state = EXPR_END | EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_imaginary(tok, data)
|
def on_imaginary(tok, data)
|
||||||
@lex_state = EXPR_END | EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_symbeg(tok, data)
|
def on_symbeg(tok, data)
|
||||||
@lex_state = EXPR_FNAME
|
@lex_state = EXPR_FNAME
|
||||||
@continue = true
|
@continue = true
|
||||||
@in_fname = 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
|
end
|
||||||
|
|
||||||
private def on_variables(event, tok, data)
|
private def on_variables(event, tok, data)
|
||||||
@ -196,7 +198,7 @@ class RDoc::RipperStateLex
|
|||||||
else
|
else
|
||||||
@lex_state = EXPR_CMDARG
|
@lex_state = EXPR_CMDARG
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def on_ident(tok, data)
|
def on_ident(tok, data)
|
||||||
@ -225,32 +227,32 @@ class RDoc::RipperStateLex
|
|||||||
|
|
||||||
def on_lparen(tok, data)
|
def on_lparen(tok, data)
|
||||||
@lex_state = EXPR_LABEL | EXPR_BEG
|
@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
|
end
|
||||||
|
|
||||||
def on_rparen(tok, data)
|
def on_rparen(tok, data)
|
||||||
@lex_state = EXPR_ENDFN
|
@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
|
end
|
||||||
|
|
||||||
def on_lbrace(tok, data)
|
def on_lbrace(tok, data)
|
||||||
@lex_state = EXPR_LABEL | EXPR_BEG
|
@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
|
end
|
||||||
|
|
||||||
def on_rbrace(tok, data)
|
def on_rbrace(tok, data)
|
||||||
@lex_state = EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_lbracket(tok, data)
|
def on_lbracket(tok, data)
|
||||||
@lex_state = EXPR_LABEL | EXPR_BEG
|
@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
|
end
|
||||||
|
|
||||||
def on_rbracket(tok, data)
|
def on_rbracket(tok, data)
|
||||||
@lex_state = EXPR_ENDARG
|
@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
|
end
|
||||||
|
|
||||||
def on_const(tok, data)
|
def on_const(tok, data)
|
||||||
@ -262,36 +264,36 @@ class RDoc::RipperStateLex
|
|||||||
else
|
else
|
||||||
@lex_state = EXPR_CMDARG
|
@lex_state = EXPR_CMDARG
|
||||||
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
|
end
|
||||||
|
|
||||||
def on_sp(tok, data)
|
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
|
end
|
||||||
|
|
||||||
def on_comma(tok, data)
|
def on_comma(tok, data)
|
||||||
@lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0
|
@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
|
end
|
||||||
|
|
||||||
def on_comment(tok, data)
|
def on_comment(tok, data)
|
||||||
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
@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
|
end
|
||||||
|
|
||||||
def on_ignored_sp(tok, data)
|
def on_ignored_sp(tok, data)
|
||||||
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
@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
|
end
|
||||||
|
|
||||||
def on_heredoc_end(tok, data)
|
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
|
@lex_state = EXPR_BEG
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_default(event, tok, data)
|
def on_default(event, tok, data)
|
||||||
reset
|
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
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
@ -306,7 +308,7 @@ class RDoc::RipperStateLex
|
|||||||
end
|
end
|
||||||
|
|
||||||
def on_default(event, tok, data)
|
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
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
@ -367,7 +369,7 @@ class RDoc::RipperStateLex
|
|||||||
|
|
||||||
private def get_symbol_tk(tk)
|
private def get_symbol_tk(tk)
|
||||||
is_symbol = true
|
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]
|
if ":'" == tk[:text] or ':"' == tk[:text]
|
||||||
tk1 = get_string_tk(tk)
|
tk1 = get_string_tk(tk)
|
||||||
symbol_tk[:text] = tk1[:text]
|
symbol_tk[:text] = tk1[:text]
|
||||||
@ -436,13 +438,7 @@ class RDoc::RipperStateLex
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{
|
Token.new(tk.line_no, tk.char_no, kind, string, state)
|
||||||
:line_no => tk[:line_no],
|
|
||||||
:char_no => tk[:char_no],
|
|
||||||
:kind => kind,
|
|
||||||
:text => string,
|
|
||||||
:state => state
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private def get_regexp_tk(tk)
|
private def get_regexp_tk(tk)
|
||||||
@ -460,13 +456,7 @@ class RDoc::RipperStateLex
|
|||||||
string = string + inner_str_tk[:text]
|
string = string + inner_str_tk[:text]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{
|
Token.new(tk.line_no, tk.char_no, :on_regexp, string, state)
|
||||||
:line_no => tk[:line_no],
|
|
||||||
:char_no => tk[:char_no],
|
|
||||||
:kind => :on_regexp,
|
|
||||||
:text => string,
|
|
||||||
:state => state
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private def get_embdoc_tk(tk)
|
private def get_embdoc_tk(tk)
|
||||||
@ -475,13 +465,7 @@ class RDoc::RipperStateLex
|
|||||||
string = string + embdoc_tk[:text]
|
string = string + embdoc_tk[:text]
|
||||||
end
|
end
|
||||||
string = string + embdoc_tk[:text]
|
string = string + embdoc_tk[:text]
|
||||||
{
|
Token.new(tk.line_no, tk.char_no, :on_embdoc, string, embdoc_tk.state)
|
||||||
:line_no => tk[:line_no],
|
|
||||||
:char_no => tk[:char_no],
|
|
||||||
:kind => :on_embdoc,
|
|
||||||
:text => string,
|
|
||||||
:state => embdoc_tk[:state]
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private def get_heredoc_tk(heredoc_name, indent)
|
private def get_heredoc_tk(heredoc_name, indent)
|
||||||
@ -499,13 +483,7 @@ class RDoc::RipperStateLex
|
|||||||
start_tk = tk unless start_tk
|
start_tk = tk unless start_tk
|
||||||
prev_tk = tk unless prev_tk
|
prev_tk = tk unless prev_tk
|
||||||
@buf.unshift tk # closing heredoc
|
@buf.unshift tk # closing heredoc
|
||||||
heredoc_tk = {
|
heredoc_tk = Token.new(start_tk.line_no, start_tk.char_no, :on_heredoc, string, prev_tk.state)
|
||||||
:line_no => start_tk[:line_no],
|
|
||||||
:char_no => start_tk[:char_no],
|
|
||||||
:kind => :on_heredoc,
|
|
||||||
:text => string,
|
|
||||||
:state => prev_tk[:state]
|
|
||||||
}
|
|
||||||
@buf.unshift heredoc_tk
|
@buf.unshift heredoc_tk
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -561,13 +539,7 @@ class RDoc::RipperStateLex
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
text = "#{start_token}#{string}#{end_token}"
|
text = "#{start_token}#{string}#{end_token}"
|
||||||
{
|
Token.new(line_no, char_no, :on_dstring, text, state)
|
||||||
:line_no => line_no,
|
|
||||||
:char_no => char_no,
|
|
||||||
:kind => :on_dstring,
|
|
||||||
:text => text,
|
|
||||||
:state => state
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private def get_op_tk(tk)
|
private def get_op_tk(tk)
|
||||||
|
@ -141,6 +141,7 @@ $TOKEN_DEBUG ||= nil
|
|||||||
# standard rdocable item following it.
|
# standard rdocable item following it.
|
||||||
|
|
||||||
require 'ripper'
|
require 'ripper'
|
||||||
|
require_relative 'ripper_state_lex'
|
||||||
|
|
||||||
class RDoc::Parser::Ruby < RDoc::Parser
|
class RDoc::Parser::Ruby < RDoc::Parser
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
@size = 0
|
@size = 0
|
||||||
@token_listeners = nil
|
@token_listeners = nil
|
||||||
content = RDoc::Encoding.remove_magic_comment content
|
content = RDoc::Encoding.remove_magic_comment content
|
||||||
@scanner = RDoc::RipperStateLex.parse(content)
|
@scanner = RDoc::Parser::RipperStateLex.parse(content)
|
||||||
@content = content
|
@content = content
|
||||||
@scanner_point = 0
|
@scanner_point = 0
|
||||||
@prev_seek = nil
|
@prev_seek = nil
|
||||||
@ -249,10 +250,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
tk = get_tk
|
tk = get_tk
|
||||||
|
|
||||||
while tk && (:on_comment == tk[:kind] or :on_embdoc == tk[:kind])
|
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
|
skip_tkspace
|
||||||
tk = get_tk
|
tk = get_tk
|
||||||
elsif first_line and tk[:text] =~ /\A#\s*-\*-/ then
|
elsif first_line and comment_body =~ /\A#\s*-\*-/ then
|
||||||
first_line = false
|
first_line = false
|
||||||
skip_tkspace
|
skip_tkspace
|
||||||
tk = get_tk
|
tk = get_tk
|
||||||
@ -261,7 +263,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
first_comment_tk_kind = tk[:kind]
|
first_comment_tk_kind = tk[:kind]
|
||||||
|
|
||||||
first_line = false
|
first_line = false
|
||||||
comment << tk[:text]
|
comment << comment_body
|
||||||
tk = get_tk
|
tk = get_tk
|
||||||
|
|
||||||
if :on_nl === tk then
|
if :on_nl === tk then
|
||||||
@ -444,28 +446,83 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
end
|
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
|
skip_tkspace false
|
||||||
|
get_tkread
|
||||||
|
tk = get_tk
|
||||||
|
end_token = get_end_token tk
|
||||||
|
return '' unless end_token
|
||||||
|
|
||||||
nest = 0
|
nest = 0
|
||||||
|
continue = false
|
||||||
|
only_constant = true
|
||||||
|
|
||||||
while :on_lparen == (tk = peek_tk)[:kind] do
|
while tk != nil do
|
||||||
get_tk
|
is_element_of_constant = false
|
||||||
skip_tkspace
|
case tk[:kind]
|
||||||
nest += 1
|
when :on_semicolon then
|
||||||
end
|
break if nest == 0
|
||||||
|
when :on_lbracket then
|
||||||
name = get_constant
|
nest += 1
|
||||||
|
when :on_rbracket then
|
||||||
while nest > 0
|
nest -= 1
|
||||||
skip_tkspace
|
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
|
tk = get_tk
|
||||||
nest -= 1 if :on_rparen == tk[:kind]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
name
|
if only_constant
|
||||||
|
get_tkread_clean(/\s+/, ' ')
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -479,17 +536,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
def get_end_token tk # :nodoc:
|
def get_end_token tk # :nodoc:
|
||||||
case tk[:kind]
|
case tk[:kind]
|
||||||
when :on_lparen
|
when :on_lparen
|
||||||
{
|
token = RDoc::Parser::RipperStateLex::Token.new
|
||||||
:kind => :on_rparen,
|
token[:kind] = :on_rparen
|
||||||
:text => ')'
|
token[:text] = ')'
|
||||||
}
|
token
|
||||||
when :on_rparen
|
when :on_rparen
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
{
|
token = RDoc::Parser::RipperStateLex::Token.new
|
||||||
:kind => :on_nl,
|
token[:kind] = :on_nl
|
||||||
:text => "\n"
|
token[:text] = "\n"
|
||||||
}
|
token
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -739,9 +796,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
when end_token
|
when end_token
|
||||||
if end_token == :on_rparen
|
if end_token == :on_rparen
|
||||||
nest -= 1
|
nest -= 1
|
||||||
break if RDoc::RipperStateLex.end?(tk) and nest <= 0
|
break if RDoc::Parser::RipperStateLex.end?(tk) and nest <= 0
|
||||||
else
|
else
|
||||||
break if RDoc::RipperStateLex.end?(tk)
|
break if RDoc::Parser::RipperStateLex.end?(tk)
|
||||||
end
|
end
|
||||||
when :on_comment, :on_embdoc
|
when :on_comment, :on_embdoc
|
||||||
unget_tk(tk)
|
unget_tk(tk)
|
||||||
@ -959,7 +1016,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
|
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
|
||||||
nest += 1
|
nest += 1
|
||||||
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
|
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
|
nest += 1
|
||||||
end
|
end
|
||||||
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
|
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
|
||||||
@ -967,7 +1024,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
nest -= 1
|
nest -= 1
|
||||||
elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
|
elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
|
||||||
unget_tk tk
|
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]+/, '')
|
body = get_tkread_clean(/^[ \t]+/, '')
|
||||||
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
|
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
|
||||||
break
|
break
|
||||||
@ -983,7 +1040,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
elsif :on_nl == tk[:kind] then
|
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
|
unget_tk tk
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -1047,10 +1104,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
record_location meth
|
record_location meth
|
||||||
|
|
||||||
meth.start_collecting_tokens
|
meth.start_collecting_tokens
|
||||||
indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
|
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
|
||||||
position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
|
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
|
||||||
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
|
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 [position_comment, newline, indent]
|
||||||
|
|
||||||
meth.params =
|
meth.params =
|
||||||
@ -1090,10 +1147,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
meth.line = line_no
|
meth.line = line_no
|
||||||
|
|
||||||
meth.start_collecting_tokens
|
meth.start_collecting_tokens
|
||||||
indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
|
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
|
||||||
position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
|
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
|
||||||
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
|
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 [position_comment, newline, indent]
|
||||||
|
|
||||||
meth.call_seq = signature
|
meth.call_seq = signature
|
||||||
@ -1117,7 +1174,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
loop do
|
loop do
|
||||||
skip_tkspace_comment
|
skip_tkspace_comment
|
||||||
|
|
||||||
name = get_constant_with_optional_parens
|
name = get_included_module_with_optional_parens
|
||||||
|
|
||||||
unless name.empty? then
|
unless name.empty? then
|
||||||
obj = container.add klass, name, comment
|
obj = container.add klass, name, comment
|
||||||
@ -1258,10 +1315,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
remove_token_listener self
|
remove_token_listener self
|
||||||
|
|
||||||
meth.start_collecting_tokens
|
meth.start_collecting_tokens
|
||||||
indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
|
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
|
||||||
position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
|
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
|
||||||
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
|
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 [position_comment, newline, indent]
|
||||||
meth.add_tokens @token_stream
|
meth.add_tokens @token_stream
|
||||||
|
|
||||||
@ -1361,10 +1418,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
meth.line = line_no
|
meth.line = line_no
|
||||||
|
|
||||||
meth.start_collecting_tokens
|
meth.start_collecting_tokens
|
||||||
indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
|
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
|
||||||
token = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
|
token = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
|
||||||
token[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
|
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, newline, indent]
|
||||||
meth.add_tokens @token_stream
|
meth.add_tokens @token_stream
|
||||||
|
|
||||||
@ -1530,6 +1587,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
case tk[:kind]
|
case tk[:kind]
|
||||||
when :on_semicolon then
|
when :on_semicolon then
|
||||||
break if nest == 0
|
break if nest == 0
|
||||||
|
when :on_lbracket then
|
||||||
|
nest += 1
|
||||||
|
when :on_rbracket then
|
||||||
|
nest -= 1
|
||||||
when :on_lbrace then
|
when :on_lbrace then
|
||||||
nest += 1
|
nest += 1
|
||||||
when :on_rbrace then
|
when :on_rbrace then
|
||||||
@ -1553,7 +1614,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
when :on_comment, :on_embdoc then
|
when :on_comment, :on_embdoc then
|
||||||
@read.pop
|
@read.pop
|
||||||
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
|
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
|
if method && method.block_params.nil? then
|
||||||
unget_tk tk
|
unget_tk tk
|
||||||
read_documentation_modifiers method, modifiers
|
read_documentation_modifiers method, modifiers
|
||||||
@ -1654,6 +1715,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
end
|
end
|
||||||
end
|
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.
|
# The core of the Ruby parser.
|
||||||
|
|
||||||
@ -1707,10 +1779,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
end
|
end
|
||||||
|
|
||||||
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
|
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
|
||||||
comment += tk[:text]
|
comment_body = retrieve_comment_body(tk)
|
||||||
comment += "\n" unless "\n" == tk[:text].chars.to_a.last
|
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
|
skip_tkspace false # leading spaces
|
||||||
end
|
end
|
||||||
tk = get_tk
|
tk = get_tk
|
||||||
@ -1758,7 +1831,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
end
|
end
|
||||||
|
|
||||||
when 'until', 'while' then
|
when 'until', 'while' then
|
||||||
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
|
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
|
||||||
nest += 1
|
nest += 1
|
||||||
skip_optional_do_after_expression
|
skip_optional_do_after_expression
|
||||||
end
|
end
|
||||||
@ -1774,7 +1847,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|||||||
skip_optional_do_after_expression
|
skip_optional_do_after_expression
|
||||||
|
|
||||||
when 'case', 'do', 'if', 'unless', 'begin' then
|
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
|
nest += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -180,12 +180,19 @@ class RDoc::TomDoc < RDoc::Markup::Parser
|
|||||||
|
|
||||||
case type
|
case type
|
||||||
when :TEXT then
|
when :TEXT then
|
||||||
@section = 'Returns' if data =~ /\AReturns/
|
@section = 'Returns' if data =~ /\A(Returns|Raises)/
|
||||||
|
|
||||||
paragraph << data
|
paragraph << data
|
||||||
when :NEWLINE then
|
when :NEWLINE then
|
||||||
if :TEXT == peek_token[0] 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
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -255,4 +262,3 @@ class RDoc::TomDoc < RDoc::Markup::Parser
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
8
lib/rdoc/version.rb
Normal file
8
lib/rdoc/version.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module RDoc
|
||||||
|
|
||||||
|
##
|
||||||
|
# RDoc version you are using
|
||||||
|
|
||||||
|
VERSION = '6.1.0.beta1'
|
||||||
|
|
||||||
|
end
|
@ -85,6 +85,33 @@ method(a, b) { |c, d| ... }
|
|||||||
assert_equal expected, @c2_a.markup_code
|
assert_equal expected, @c2_a.markup_code
|
||||||
end
|
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
|
def test_markup_code_empty
|
||||||
assert_equal '', @c2_a.markup_code
|
assert_equal '', @c2_a.markup_code
|
||||||
end
|
end
|
||||||
@ -165,7 +192,7 @@ method(a, b) { |c, d| ... }
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_marshal_load_class_method
|
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::m', class_method.full_name
|
||||||
assert_equal 'C1', class_method.parent_name
|
assert_equal 'C1', class_method.parent_name
|
||||||
@ -174,7 +201,7 @@ method(a, b) { |c, d| ... }
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_marshal_load_instance_method
|
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#m', instance_method.full_name
|
||||||
assert_equal 'C1', instance_method.parent_name
|
assert_equal 'C1', instance_method.parent_name
|
||||||
|
@ -91,6 +91,7 @@ class TestRDocClassModule < XrefTestCase
|
|||||||
|
|
||||||
assert @c1.document_self_or_methods
|
assert @c1.document_self_or_methods
|
||||||
|
|
||||||
|
@c1_plus.document_self = false
|
||||||
@c1_m.document_self = false
|
@c1_m.document_self = false
|
||||||
|
|
||||||
assert @c1.document_self_or_methods
|
assert @c1.document_self_or_methods
|
||||||
|
@ -660,7 +660,7 @@ class TestRDocContext < XrefTestCase
|
|||||||
'instance' => {
|
'instance' => {
|
||||||
:private => [],
|
:private => [],
|
||||||
:protected => [],
|
:protected => [],
|
||||||
:public => [@c1_m],
|
:public => [@c1_plus, @c1_m],
|
||||||
},
|
},
|
||||||
'class' => {
|
'class' => {
|
||||||
:private => [],
|
:private => [],
|
||||||
|
@ -107,18 +107,24 @@ class TestRDocCrossReference < XrefTestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_resolve_method
|
def test_resolve_method
|
||||||
assert_ref @c1__m, 'm'
|
assert_ref @c1__m, 'm'
|
||||||
assert_ref @c1_m, '#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_m, 'C1#m'
|
||||||
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_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()'
|
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(*)'
|
assert_ref @c2_c3_m, '::C2::C3#m(*)'
|
||||||
end
|
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
|
def test_resolve_method_equals3
|
||||||
m = RDoc::AnyMethod.new '', '==='
|
m = RDoc::AnyMethod.new '', '==='
|
||||||
@c1.add_method m
|
@c1.add_method m
|
||||||
|
@ -59,7 +59,7 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|||||||
def test_convert_RDOCLINK_rdoc_ref_method
|
def test_convert_RDOCLINK_rdoc_ref_method
|
||||||
result = @to.convert 'rdoc-ref:C1#m'
|
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
|
end
|
||||||
|
|
||||||
def test_convert_RDOCLINK_rdoc_ref_method_label
|
def test_convert_RDOCLINK_rdoc_ref_method_label
|
||||||
@ -75,13 +75,13 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|||||||
|
|
||||||
result = @to.convert 'rdoc-ref:C1#%'
|
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
|
m.singleton = true
|
||||||
|
|
||||||
result = @to.convert 'rdoc-ref:C1::%'
|
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
|
end
|
||||||
|
|
||||||
def test_convert_RDOCLINK_rdoc_ref_method_percent_label
|
def test_convert_RDOCLINK_rdoc_ref_method_percent_label
|
||||||
@ -200,11 +200,16 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|||||||
def test_link
|
def test_link
|
||||||
assert_equal 'n', @to.link('n', 'n')
|
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
|
end
|
||||||
|
|
||||||
def test_link_class_method_full
|
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')
|
@to.link('Parent::m', 'Parent::m')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class C; end
|
|||||||
|
|
||||||
comment = parser.collect_first_comment
|
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
|
end
|
||||||
|
|
||||||
def test_get_class_or_module
|
def test_get_class_or_module
|
||||||
@ -1313,8 +1313,16 @@ EOF
|
|||||||
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
|
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
|
||||||
{ :line_no => 1, :char_no => 1, :kind => :on_sp, :text => '' }
|
{ :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
|
end
|
||||||
|
|
||||||
def test_parse_comment_method_args
|
def test_parse_comment_method_args
|
||||||
@ -2310,6 +2318,31 @@ end
|
|||||||
assert_equal 'C#bar', methods[1].full_name
|
assert_equal 'C#bar', methods[1].full_name
|
||||||
end
|
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
|
def test_parse_statements_class_nested
|
||||||
comment = RDoc::Comment.new "##\n# my method\n", @top_level
|
comment = RDoc::Comment.new "##\n# my method\n", @top_level
|
||||||
|
|
||||||
@ -3349,11 +3382,11 @@ end
|
|||||||
|
|
||||||
foo = @top_level.classes.first
|
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
|
m = foo.method_list.first
|
||||||
|
|
||||||
assert_equal "=begin\nm comment\n=end", m.comment.text
|
assert_equal 'm comment', m.comment.text
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_scan_block_comment_nested # Issue #41
|
def test_scan_block_comment_nested # Issue #41
|
||||||
@ -3375,7 +3408,7 @@ end
|
|||||||
foo = @top_level.modules.first
|
foo = @top_level.modules.first
|
||||||
|
|
||||||
assert_equal 'Foo', foo.full_name
|
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
|
bar = foo.classes.first
|
||||||
|
|
||||||
@ -3386,9 +3419,10 @@ end
|
|||||||
def test_scan_block_comment_notflush
|
def test_scan_block_comment_notflush
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
# The previous test assumes that between the =begin/=end blocs that there is
|
# The previous test assumes that between the =begin/=end blocks that there
|
||||||
# only one line, or minima formatting directives. This test tests for those
|
# is only one line, or minima formatting directives. This test tests for
|
||||||
# who use the =begin bloc with longer / more advanced formatting within.
|
# those who use the =begin bloc with longer / more advanced formatting
|
||||||
|
# within.
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
content = <<-CONTENT
|
content = <<-CONTENT
|
||||||
@ -3422,12 +3456,12 @@ end
|
|||||||
|
|
||||||
foo = @top_level.classes.first
|
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
|
foo.comment.text
|
||||||
|
|
||||||
m = foo.method_list.first
|
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
|
end
|
||||||
|
|
||||||
def test_scan_class_nested_nodoc
|
def test_scan_class_nested_nodoc
|
||||||
@ -4018,4 +4052,155 @@ end
|
|||||||
assert_equal ['A', 'B', 'B::C'], visible
|
assert_equal ['A', 'B', 'B::C'], visible
|
||||||
end
|
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
|
end
|
||||||
|
@ -699,6 +699,21 @@ class TestRDocRIDriver < RDoc::TestCase
|
|||||||
refute_match %r%must not be displayed%, out
|
refute_match %r%must not be displayed%, out
|
||||||
end
|
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
|
def test_display_name_not_found_class
|
||||||
util_store
|
util_store
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class TestRDocStore < XrefTestCase
|
|||||||
|
|
||||||
def test_all_classes_and_modules
|
def test_all_classes_and_modules
|
||||||
expected = %w[
|
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
|
Child
|
||||||
M1 M1::M2
|
M1 M1::M2
|
||||||
Parent
|
Parent
|
||||||
@ -213,7 +213,7 @@ class TestRDocStore < XrefTestCase
|
|||||||
|
|
||||||
def test_classes
|
def test_classes
|
||||||
expected = %w[
|
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
|
Child
|
||||||
Parent
|
Parent
|
||||||
]
|
]
|
||||||
|
@ -301,6 +301,44 @@ Returns another thing
|
|||||||
assert_equal expected, @TD.parse(text)
|
assert_equal expected, @TD.parse(text)
|
||||||
end
|
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
|
def test_parse_returns_multiline
|
||||||
text = <<-TEXT
|
text = <<-TEXT
|
||||||
Do some stuff
|
Do some stuff
|
||||||
@ -320,6 +358,27 @@ Returns a thing
|
|||||||
assert_equal expected, @TD.parse(text)
|
assert_equal expected, @TD.parse(text)
|
||||||
end
|
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
|
def test_parse_signature
|
||||||
text = <<-TEXT
|
text = <<-TEXT
|
||||||
Do some stuff
|
Do some stuff
|
||||||
@ -518,4 +577,3 @@ Returns a thing
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ class C1
|
|||||||
def m foo
|
def m foo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def +
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class C2
|
class C2
|
||||||
@ -101,6 +103,18 @@ class C8
|
|||||||
end
|
end
|
||||||
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
|
module M1
|
||||||
def m
|
def m
|
||||||
end
|
end
|
||||||
|
@ -31,9 +31,10 @@ class XrefTestCase < RDoc::TestCase
|
|||||||
@rdoc.options = @options
|
@rdoc.options = @options
|
||||||
@rdoc.generator = generator
|
@rdoc.generator = generator
|
||||||
|
|
||||||
@c1 = @xref_data.find_module_named 'C1'
|
@c1 = @xref_data.find_module_named 'C1'
|
||||||
@c1_m = @c1.method_list.last # C1#m
|
@c1__m = @c1.find_class_method_named 'm' # C1::m
|
||||||
@c1__m = @c1.method_list.first # 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 = @xref_data.find_module_named 'C2'
|
||||||
@c2_a = @c2.method_list.last
|
@c2_a = @c2.method_list.last
|
||||||
@ -56,6 +57,14 @@ class XrefTestCase < RDoc::TestCase
|
|||||||
@c8 = @xref_data.find_module_named 'C8'
|
@c8 = @xref_data.find_module_named 'C8'
|
||||||
@c8_s1 = @xref_data.find_module_named 'C8::S1'
|
@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 = @xref_data.find_module_named 'M1'
|
||||||
@m1_m = @m1.method_list.first
|
@m1_m = @m1.method_list.first
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user