From 95e213d3542034e0fd2613de6990a7ddfe5718ca Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 27 Aug 2018 01:30:18 +0000 Subject: 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 --- lib/rdoc.rb | 6 +- lib/rdoc/cross_reference.rb | 36 +++-- lib/rdoc/generator/markup.rb | 14 +- .../generator/template/json_index/js/navigation.js | 7 +- lib/rdoc/markup/to_html.rb | 2 +- lib/rdoc/markup/to_html_crossref.rb | 3 - lib/rdoc/parser/ripper_state_lex.rb | 104 +++++-------- lib/rdoc/parser/ruby.rb | 173 +++++++++++++++------ lib/rdoc/rdoc.gemspec | 14 +- lib/rdoc/tom_doc.rb | 12 +- lib/rdoc/version.rb | 8 + 11 files changed, 216 insertions(+), 163 deletions(-) create mode 100644 lib/rdoc/version.rb (limited to 'lib') diff --git a/lib/rdoc.rb b/lib/rdoc.rb index a4288679c0..fc8ad9e144 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 d76ebaf2d0..3f5f33ba42 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 fef982d378..41e132450d 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 #markup_code 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 e41268123e..43c5118abd 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 c5e1f073f8..79b13e1819 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 2911aee954..cc93021540 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 43f7dc1e9b..773a830450 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 a90622f0f3..8b9ecc1141 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 @@ -1654,6 +1715,17 @@ class RDoc::Parser::Ruby < RDoc::Parser 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. @@ -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 59d8fb52c3..efef1863b9 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 2b594b7d84..625a6b5cfa 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 0000000000..5139f8dd4b --- /dev/null +++ b/lib/rdoc/version.rb @@ -0,0 +1,8 @@ +module RDoc + + ## + # RDoc version you are using + + VERSION = '6.1.0.beta1' + +end -- cgit v1.2.3