Commit 0b27ebcc authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement @return as builtin tag class.

parent 84e3c754
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
require "jsduck/builtins/tag"

module JsDuck::Builtins
  class Return < Tag
    def initialize
      @pattern = ["return", "returns"]
    end

    # @return {Type} return.name ...
    def parse(p)
      p.add_tag(:return)
      p.maybe_type
      maybe_object_property(p)
    end

    def maybe_object_property(p)
      p.skip_horiz_white
      if p.look(/return\.\w/)
        p.current_tag[:name] = p.ident_chain
      else
        p.current_tag[:name] = "return"
      end
    end
  end
end
+3 −14
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ module JsDuck
      "ftype" => [:at_xtype, "feature"],
      "ptype" => [:at_xtype, "plugin"],

      "return" => [:at_return],
      "returns" => [:at_return],
      "type" => [:at_type],
      "inheritdoc" => [:at_inheritdoc],
      "inheritDoc" => [:at_inheritdoc],
@@ -200,18 +198,6 @@ module JsDuck
    # Routines for parsing of concrete tags...
    #

    # matches @return {type} [ return.name ] ...
    def at_return
      add_tag(:return)
      maybe_type
      skip_horiz_white
      if look(/return\.\w/)
        @current_tag[:name] = ident_chain
      else
        @current_tag[:name] = "return"
      end
    end

    # matches @enum {type} name ...
    def at_enum
      # @enum is a special case of class
@@ -304,6 +290,9 @@ module JsDuck
    # Parsing helpers ...
    #

    # Provides access to the tag that's currently being parsed
    attr_reader :current_tag

    # Appends new @tag to parsed tags list
    def add_tag(tag)
      @tags << @current_tag = {:tagname => tag, :doc => ""}