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

Add #member_type field to member type Tag classes.

That is for tags: @cfg, @property, @method, @event, @css_mixin,
@css_var.  For the latter introduced also a Tag class (although
there is no corresponding @tag).

The regex for matching member types now gets constructed in TagRegistry
class, which has the central knowledge of the available member types.
Similarly exporting uses TagRegistry.member_types to loop over all
available member types (removing hardcoded member types list from
JsDuck::Class#each_member_type).
parent 25bd6057
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -193,12 +193,6 @@ module JsDuck
      "#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{name}"
    end

    # Loops through all available member types,
    # passing the tagname of the member to the block.
    def self.each_member_type(&block)
      [:cfg, :property, :method, :event, :css_var, :css_mixin].each(&block)
    end

    # True if the given member is a constructor method
    def self.constructor?(member)
      member[:tagname] == :method && member[:name] == "constructor"
+3 −1
Original line number Diff line number Diff line
require 'jsduck/tag_registry'

module JsDuck

  # Abstract base class for parsing doc-comments.
@@ -104,7 +106,7 @@ module JsDuck
          @current_tag[:static] = true
          match(/static-/)
        end
        if look(/(cfg|property|method|event|css_var|css_mixin)-/)
        if look(TagRegistry.member_type_regex)
          @current_tag[:type] = ident.to_sym
          match(/-/)
        end
+2 −2
Original line number Diff line number Diff line
require 'jsduck/class'
require 'jsduck/tag_registry'

module JsDuck
  module Exporter
@@ -18,7 +18,7 @@ module JsDuck

        h[:members] = {}
        h[:statics] = {}
        Class.each_member_type do |tagname|
        TagRegistry.member_types.each do |tagname|
          h[:members][tagname] = export_members(cls, {:tagname => tagname, :static => false})
          h[:statics][tagname] = export_members(cls, {:tagname => tagname, :static => true})
        end
+2 −1
Original line number Diff line number Diff line
require 'jsduck/util/html'
require 'jsduck/logger'
require 'jsduck/tag_registry'

module JsDuck
  module Inline
@@ -58,7 +59,7 @@ module JsDuck

      # applies the link template
      def apply_tpl(target, text, full_link)
        if target =~ /^(.*)#(static-)?(?:(cfg|property|method|event|css_var|css_mixin)-)?(.*)$/
        if target =~ /^(.*)#(static-)?#{TagRegistry.member_type_regex}?(.*)$/
          cls = $1.empty? ? @class_context : $1
          static = $2 ? true : nil
          type = $3 ? $3.intern : nil
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ module JsDuck::Tag
  class Cfg < Tag
    def initialize
      @pattern = "cfg"
      @member_type = :cfg
    end

    # @cfg {Type} [name=default] (required) ...
Loading