Skip to content

Line numbers are wrong if magic comments are used #425

@jeremyevans

Description

@jeremyevans

If you use a magic comment, the line numbers are wrong as they treat the first non-magic comment line as line 1. This probably needs fixing in lib/rdoc/encoding.rb.

Example:

$ cat a.rb && rdoc24 a.rb > /dev/null 2>&1 && fgrep line doc/Object.html
def a; end
            <pre><span class="ruby-comment"># File a.rb, line 1</span>
$ cat a2.rb && rdoc24 a2.rb > /dev/null 2>&1 && fgrep line doc/Object.html
# encoding: utf-8
def a; end
            <pre><span class="ruby-comment"># File a2.rb, line 1</span>
$ cat a3.rb && rdoc24 a3.rb > /dev/null 2>&1 && fgrep line doc/Object.html
# encoding: utf-8
# frozen-string-literal: true
def a; end
            <pre><span class="ruby-comment"># File a3.rb, line 1</span>
$ cat a4.rb && rdoc24 a4.rb > /dev/null 2>&1 && fgrep line doc/Object.html
# encoding: utf-8
# frozen-string-literal: true

def a; end
            <pre><span class="ruby-comment"># File a4.rb, line 2</span>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions