Commit 84e3c754 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement @param & @throws as builtin tag classes.

parent 0f643b70
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
require "jsduck/builtins/tag"

module JsDuck::Builtins
  class Param < Tag
    def initialize
      @pattern = "param"
    end

    # @param {Type} [name=default] (optional) ...
    def parse(p)
      p.add_tag(:param)
      p.maybe_type
      p.maybe_name_with_default
      p.maybe_optional
    end
  end
end
+15 −0
Original line number Diff line number Diff line
require "jsduck/builtins/tag"

module JsDuck::Builtins
  class Throws < Tag
    def initialize
      @pattern = "throws"
    end

    # @throws {Type} ...
    def parse(p)
      p.add_tag(:throws)
      p.maybe_type
    end
  end
end
+0 −16
Original line number Diff line number Diff line
@@ -37,14 +37,12 @@ module JsDuck
      "ftype" => [:at_xtype, "feature"],
      "ptype" => [:at_xtype, "plugin"],

      "param" => [:at_param],
      "return" => [:at_return],
      "returns" => [:at_return],
      "type" => [:at_type],
      "inheritdoc" => [:at_inheritdoc],
      "inheritDoc" => [:at_inheritdoc],
      "alias" => [:at_alias_or_inheritdoc],
      "throws" => [:at_throws],
      "enum" => [:at_enum],
      "override" => [:at_override],
    }
@@ -202,14 +200,6 @@ module JsDuck
    # Routines for parsing of concrete tags...
    #

    # matches @param {type} [name] (optional) ...
    def at_param
      add_tag(:param)
      maybe_type
      maybe_name_with_default
      maybe_optional
    end

    # matches @return {type} [ return.name ] ...
    def at_return
      add_tag(:return)
@@ -222,12 +212,6 @@ module JsDuck
      end
    end

    # matches @throws {type} ...
    def at_throws
      add_tag(:throws)
      maybe_type
    end

    # matches @enum {type} name ...
    def at_enum
      # @enum is a special case of class