diff options
author | aycabta <[email protected]> | 2019-11-27 11:58:38 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2019-11-28 08:19:05 +0900 |
commit | 2d0a1a1869e601dc0d50a86a89fe98edcbd24f09 (patch) | |
tree | 6b856f051311fb18f1db133e19bec2ee8af68dbc /lib/rdoc/parser | |
parent | f9debf343788a6460e1e67bd7efc470d73e69f21 (diff) |
Fix ghost method line no
Diffstat (limited to 'lib/rdoc/parser')
-rw-r--r-- | lib/rdoc/parser/ruby.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 4d6c038deb..c87765b75a 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -244,6 +244,7 @@ class RDoc::Parser::Ruby < RDoc::Parser comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding first_line = true first_comment_tk_kind = nil + line_no = nil tk = get_tk @@ -260,6 +261,7 @@ class RDoc::Parser::Ruby < RDoc::Parser break if first_comment_tk_kind and not first_comment_tk_kind === tk[:kind] first_comment_tk_kind = tk[:kind] + line_no = tk[:line_no] if first_line first_line = false comment << comment_body tk = get_tk @@ -273,7 +275,7 @@ class RDoc::Parser::Ruby < RDoc::Parser unget_tk tk - new_comment comment + new_comment comment, line_no end ## @@ -666,8 +668,9 @@ class RDoc::Parser::Ruby < RDoc::Parser ## # Creates a comment with the correct format - def new_comment comment + def new_comment comment, line_no = nil c = RDoc::Comment.new comment, @top_level, :ruby + c.line = line_no c.format = @markup c end @@ -1058,13 +1061,14 @@ class RDoc::Parser::Ruby < RDoc::Parser def parse_comment container, tk, comment return parse_comment_tomdoc container, tk, comment if @markup == 'tomdoc' column = tk[:char_no] - line_no = tk[:line_no] + line_no = comment.line.nil? ? tk[:line_no] : comment.line comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3') singleton = !!$~ co = if (comment.text = comment.text.sub(/^# +:?method: *(\S*).*?\n/i, '')) && !!$~ then + line_no += $`.count("\n") parse_comment_ghost container, comment.text, $1, column, line_no, comment elsif (comment.text = comment.text.sub(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '')) && !!$~ then parse_comment_attr container, $1, $3, comment @@ -1776,8 +1780,10 @@ class RDoc::Parser::Ruby < RDoc::Parser comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding end + line_no = nil while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do comment_body = retrieve_comment_body(tk) + line_no = tk[:line_no] if comment.empty? comment += comment_body comment << "\n" unless comment_body =~ /\n\z/ @@ -1787,7 +1793,7 @@ class RDoc::Parser::Ruby < RDoc::Parser tk = get_tk end - comment = new_comment comment + comment = new_comment comment, line_no unless comment.empty? then look_for_directives_in container, comment |