Commit 396de19b authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Extract MemberTag class.

Require all member classes to be subclasses of this.
parent 99b491a7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/tag/member_tag"
require "jsduck/doc/subproperties"
require "jsduck/render/property_signature"

module JsDuck::Tag
  class Cfg < Tag
  class Cfg < MemberTag
    def initialize
      @pattern = "cfg"
      @tagname = :cfg
+2 −2
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/tag/member_tag"
require "jsduck/render/method_signature"

module JsDuck::Tag
  # As of now there is no @css_mixin tag available in CSS files.  This
  # class just exists to define that we have a member type called
  # :css_mixin.
  class CssMixin < Tag
  class CssMixin < MemberTag
    def initialize
      @member_type = {
        :name => :css_mixin,
+2 −2
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/tag/member_tag"
require "jsduck/render/property_signature"

module JsDuck::Tag
  class CssVar < Tag
  class CssVar < MemberTag
    def initialize
      @pattern = "var"
      @tagname = :css_var
+2 −2
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/tag/member_tag"
require "jsduck/render/method_signature"

module JsDuck::Tag
  class Event < Tag
  class Event < MemberTag
    def initialize
      @pattern = "event"
      @tagname = :event
+68 −0
Original line number Diff line number Diff line
require 'jsduck/tag/tag'

module JsDuck::Tag
  # Base class for all builtin members.
  class MemberTag < Tag
    # Defines a class member type and specifies a name and several
    # other settings.  For example:
    #
    #     {
    #       :name => :event,
    #       :category => :method_like,
    #       :title => "Events",
    #       :position => MEMBER_POS_EVENT,
    #       # The following are optional
    #       :toolbar_title => "Events",
    #       :subsections => [
    #         {:title => "Static events",
    #          :filter => {:static => false},
    #          :default => true},
    #         {:title => "Instance events",
    #          :filter => {:static => true}},
    #       ]
    #     }
    #
    # The category must be either :property_like or :method_like.
    #
    # Position defines the ordering of member section in final HTML
    # output.
    #
    # Title is shown at the top of each such section and also as a
    # label on Docs app toolbar button unless :toolbar_title is
    # specified.
    #
    # Subsections allows splitting the list of members to several
    # subgroups.  For example methods get split into static and
    # instance methods.
    #
    # - The :filter field defines how to filter out the members for
    #   this subcategory.  :static=>true filters out all members that
    #   have a :static field with a truthy value.  Conversely,
    #   :static=>false filters out members not having a :static field
    #   or having it with a falsy value.
    #
    # - Setting :default=>true will hide the subsection title when all
    #   the members end up in that subsection.  For example when there
    #   are only instance methods, the docs will only contain the
    #   section title "Methods", as by default one should assume all
    #   methods are instance methods if not stated otherwise.
    #
    attr_reader :member_type

    MEMBER_POS_CFG = 1
    MEMBER_POS_PROPERTY = 2
    MEMBER_POS_METHOD = 3
    MEMBER_POS_EVENT = 4
    MEMBER_POS_CSS_VAR = 5
    MEMBER_POS_CSS_MIXIN = 6

    # This method defines the signature-line of the member.
    # For example it might return something like this:
    #
    #     "apply(source, target) : Object"
    #
    def to_html(context, cls)
    end

  end
end
Loading