Sha256: b08edb3d42bf9466756045d07ba44d9ac570ae4bda6e835f8d6401d30f125fc3

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

require "jsduck/tag/tag"
require "jsduck/tag_registry"

module JsDuck::Tag
  class Inheritdoc < Tag
    def initialize
      @pattern = ["inheritdoc", "inheritDoc"]
      @tagname = :inheritdoc
    end

    # @inheritdoc class.name#static-type-member
    def parse_doc(p, pos)
      parse_as_inheritdoc(p)
    end

    # 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)
      tag = {
        :tagname => :inheritdoc,
        :cls => p.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(h, docs, pos)
      h[:inheritdoc] = docs.first
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jsduck-5.3.4 lib/jsduck/tag/inheritdoc.rb
jsduck-5.3.3 lib/jsduck/tag/inheritdoc.rb
jsduck-5.3.2 lib/jsduck/tag/inheritdoc.rb
jsduck-5.3.1 lib/jsduck/tag/inheritdoc.rb
jsduck-5.3.0 lib/jsduck/tag/inheritdoc.rb
jsduck-5.2.0 lib/jsduck/tag/inheritdoc.rb
jsduck-5.1.0 lib/jsduck/tag/inheritdoc.rb
jsduck-5.0.1 lib/jsduck/tag/inheritdoc.rb
jsduck-5.0.0 lib/jsduck/tag/inheritdoc.rb
jsduck-5.0.0.beta5 lib/jsduck/tag/inheritdoc.rb
jsduck-5.0.0.beta4 lib/jsduck/tag/inheritdoc.rb
jsduck-5.0.0.beta3 lib/jsduck/tag/inheritdoc.rb
jsduck-5.0.0.beta2 lib/jsduck/tag/inheritdoc.rb