Commit 65b8b0e6 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make Inheritdoc & Alias class return tagdef hash.

The member_reference parsing has now moved completely inside Inheritdoc
class.
parent 9e155ce8
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -103,23 +103,6 @@ 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(TagRegistry.member_type_regex)
          @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 "]".
+4 −2
Original line number Diff line number Diff line
@@ -23,8 +23,10 @@ module JsDuck::Tag

    # @alias widget.foo
    def parse_as_alias(p)
      p.add_tag(:aliases)
      p.maybe_ident_chain(:name)
      {
        :tagname => :aliases,
        :name => p.hw.ident_chain,
      }
    end

    def process_doc(tags)
+24 −3
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/tag_registry"

module JsDuck::Tag
  class Inheritdoc < Tag
@@ -14,10 +15,30 @@ module JsDuck::Tag

    # This separate method exits to allow it to be also called from
    # @alias tag implementation.
    #
    # Matches a member reference: <class.name> "#" <static> "-" <type> "-" <member>
    #
    # Returns :inheritdoc tag definition with corresponding fields.
    def parse_as_inheritdoc(p)
      p.add_tag(:inheritdoc)
      p.maybe_ident_chain(:cls)
      p.maybe_member_reference
      tag = {
        :tagname => :inheritdoc,
        :cls => p.hw.ident_chain,
      }

      if p.look(/#\w/)
        p.match(/#/)
        if p.look(/static-/)
          tag[:static] = true
          p.match(/static-/)
        end
        if p.look(JsDuck::TagRegistry.member_type_regex)
          tag[:type] = p.match(/\w+/).to_sym
          p.match(/-/)
        end
        tag[:member] = p.ident
      end

      tag
    end

    def process_doc(docs)