Commit 7139830e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Refactor @inheritdoc implementation.

Extract parts of the parsing routine into separate methods so
that the #at_inheritdoc method works at a more higher level.
parent ed552a51
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
@@ -212,24 +212,8 @@ module JsDuck
    # matches @inheritdoc class.name#static-type-member
    def at_inheritdoc
      add_tag(:inheritdoc)
      skip_horiz_white

      if look(@ident_chain_pattern)
        @current_tag[:cls] = ident_chain
      end

      if look(/#\w/)
        match(/#/)
        if look(/static-/)
          @current_tag[:static] = true
          match(/static-/)
        end
        if look(/(cfg|property|method|event|css_var|css_mixin)-/)
          @current_tag[:type] = ident.to_sym
          match(/-/)
        end
        @current_tag[:member] = ident
      end
      maybe_ident_chain(:cls)
      maybe_member_reference
    end

    #
@@ -315,6 +299,23 @@ module JsDuck
      end
    end

    # matches a member reference: "#" <static> "-" <type> "-" <member>
    # setting the corresponding properties on @current_tag
    def maybe_member_reference
      if look(/#\w/)
        match(/#/)
        if look(/static-/)
          @current_tag[:static] = true
          match(/static-/)
        end
        if look(/(cfg|property|method|event|css_var|css_mixin)-/)
          @current_tag[:type] = ident.to_sym
          match(/-/)
        end
        @current_tag[:member] = ident
      end
    end

    # Attempts to allow balanced braces in default value.
    # When the nested parsing doesn't finish at closing "]",
    # roll back to beginning and simply grab anything up to closing "]".