Commit c5e351c5 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement @type as builtin tag class.

parent d029feb1
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
require "jsduck/builtins/tag"

module JsDuck::Builtins
  class Type < Tag
    def initialize
      @pattern = "type"
    end

    # matches @type {type}  or  @type type
    #
    # The presence of @type implies that we are dealing with property.
    # ext-doc allows type name to be either inside curly braces or
    # without them at all.
    def parse(p)
      p.add_tag(:type)
      p.maybe_type
      maybe_curlyless_type(p) unless p.current_tag[:type]
    end

    def maybe_curlyless_type(p)
      if p.look(/\S/)
        p.current_tag[:type] = p.match(/\S+/)
      end
    end

  end
end
+0 −14
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ module JsDuck
      "ftype" => [:at_xtype, "feature"],
      "ptype" => [:at_xtype, "plugin"],

      "type" => [:at_type],
      "inheritdoc" => [:at_inheritdoc],
      "inheritDoc" => [:at_inheritdoc],
      "alias" => [:at_alias_or_inheritdoc],
@@ -196,19 +195,6 @@ module JsDuck
    # Routines for parsing of concrete tags...
    #

    # matches @type {type}  or  @type type
    #
    # The presence of @type implies that we are dealing with property.
    # ext-doc allows type name to be either inside curly braces or
    # without them at all.
    def at_type
      add_tag(:type)
      maybe_type
      if !@current_tag[:type] && look(/\S/)
        @current_tag[:type] = match(/\S+/)
      end
    end

    # matches @xtype/ptype/ftype/... name
    def at_xtype(namespace)
      add_tag(:alias)