Commit 9df204d4 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support @inheritdoc links to static members.

parent 89ea5d1b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ module JsDuck
      skip_white
    end

    # matches @inheritdoc class.name#type-member
    # matches @inheritdoc class.name#static-type-member
    def at_inheritdoc
      match(/@inherit[dD]oc|@alias/)

@@ -342,7 +342,11 @@ module JsDuck
        @current_tag[:cls] = ident_chain
        if look(/#\w/)
          @input.scan(/#/)
          if look(/\w+-\w+/)
          if look(/static-/)
            @current_tag[:static] = true
            @input.scan(/static-/)
          end
          if look(/(cfg|property|method|event|css_var|css_mixin)-/)
            @current_tag[:type] = ident.to_sym
            @input.scan(/-/)
          end
+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ module JsDuck
          warn("@inheritdoc #{inherit[:cls]}##{inherit[:member]} - class not found", context)
          return m
        end
        parent = parent_cls.get_members(inherit[:member], inherit[:type] || m[:tagname])[0]
        parent = parent_cls.get_members(inherit[:member], inherit[:type] || m[:tagname], inherit[:static] || m[:attributes][:static])[0]
        unless parent
          warn("@inheritdoc #{inherit[:cls]}##{inherit[:member]} - member not found", context)
          return m
@@ -53,7 +53,7 @@ module JsDuck
          warn("@inheritdoc - parent class not found", context)
          return m
        end
        parent = parent_cls.get_members(m[:name], m[:tagname])[0]
        parent = parent_cls.get_members(m[:name], m[:tagname], m[:attributes][:static])[0]
        unless parent
          warn("@inheritdoc - parent member not found", context)
          return m
+57 −0
Original line number Diff line number Diff line
@@ -255,6 +255,63 @@ describe JsDuck::Aggregator do
    it_behaves_like "@inheritdoc"
  end

  describe "@inheritdoc with staticality info" do
    before do
      @docs = parse(<<-EOF)
        /** @class Foo */
          /**
           * @method bar
           * @static
           * Original comment.
           */
          /**
           * @method bar
           * Method comment.
           */

        /** @class Core */
          /**
           * @method foobar
           * New comment.
           * @inheritdoc Foo#static-bar
           */
      EOF
      @orig = @docs["Foo"][:statics][:method][0]
      @inheritdoc = @docs["Core"][:members][:method][0]
    end

    it_behaves_like "@inheritdoc"
  end

  describe "@inheritdoc without staticality info uses the statics of itself" do
    before do
      @docs = parse(<<-EOF)
        /** @class Foo */
          /**
           * @method bar
           * @static
           * Original comment.
           */
          /**
           * @method bar
           * Method comment.
           */

        /** @class Core */
          /**
           * @method foobar
           * @static
           * New comment.
           * @inheritdoc Foo#bar
           */
      EOF
      @orig = @docs["Foo"][:statics][:method][0]
      @inheritdoc = @docs["Core"][:statics][:method][0]
    end

    it_behaves_like "@inheritdoc"
  end

  describe "recursive @inheritdocs" do
    before do
      @docs = parse(<<-EOF)