Commit 2d7e6641 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Links to exact line numbers.

Source code links in documentation now reference the exact line number.
parent 0cb17f24
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@ module JsDuck
      Parser.new(input).parse.each do |docset|
        doc = @doc_parser.parse(docset[:comment])
        code = docset[:code]
        register(add_href(@merger.merge(doc, code), filename))
        href = filename + "#line-" + docset[:linenr].to_s
        register(add_href(@merger.merge(doc, code), href))
      end
    end

+8 −4
Original line number Diff line number Diff line
@@ -9,9 +9,10 @@ module JsDuck
    end

    # Parses the whole JavaScript block and returns array where for
    # each doc-comment there is a hash of two values: the comment
    # itself as string and parsed structure of the code that
    # immediately follows the comment.
    # each doc-comment there is a hash of three values: the comment
    # itself as string, number of the line where the comment starts,
    # and parsed structure of the code that immediately follows the
    # comment.
    #
    # For example with the following JavaScript input:
    #
@@ -26,6 +27,7 @@ module JsDuck
    # [
    #   {
    #     :comment => "/**\n * @param {String} foo\n */",
    #     :linenr => 1,
    #     :code => {
    #       :type => :assignment,
    #       :left => ["MyClass", "doIt"],
@@ -44,8 +46,10 @@ module JsDuck
    def parse
      while !@lex.empty? do
        if look(:doc_comment) then
          comment = @lex.next(true)
          @docs << {
            :comment => match(:doc_comment),
            :comment => comment[:value],
            :linenr => comment[:linenr],
            :code => code_block
          }
        else