Sha256: c485c9ad59570250a811a6dd52d51a86f3274403120b78e77f881480e1289e7b

Contents?: true

Size: 1.55 KB

Versions: 16

Compression:

Stored size: 1.55 KB

Contents

module JsDuck
  module Warning

    # Unknown tag warning.
    class Tag

      # Creates the :tag warning type
      def initialize
        @rules = []
        # disable by default
        set(false)
      end

      # Enables or disables a particular sub-warning
      def set(enabled, path_pattern=nil, tagnames=[])
        @rules.unshift({
          :enabled => enabled,
          :tagnames => tagnames,
          :path_re => path_pattern ? Regexp.new(Regexp.escape(path_pattern)) : nil
        })
      end

      # True when the warning is enabled for the given filename and
      # params combination where params contains one tagname.
      def enabled?(filename="", params=[])
        tagname = params[0]

        # Filter out the most recently added rule that applies to our current item
        match = @rules.find do |r|
          (r[:tagnames].empty? || r[:tagnames].include?(tagname)) &&
            (r[:path_re].nil? || r[:path_re] =~ filename)
        end

        return match[:enabled]
      end

      # Extensive documentation for :nodoc warning
      def doc
        [
          "",
          " +tag(<name1>,<name2>,...) - Use of unsupported @tag",
          "",
          "     This warning type can optionally take a list of tag names",
          "     to limit its effect to only these tags.",
          "",
          "     So, to disable warnings for JavaDoc tags @file and @overview",
          "     which aren't supported by JSDuck:",
          "",
          "         --warnings='-tag(file,overview)'",
          "",
        ]
      end

    end

  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/warning/tag.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/warning/tag.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/warning/tag.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/warning/tag.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/warning/tag.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/warning/tag.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.10 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.9 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.8 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.7 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.5 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.4 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.3 lib/jsduck/warning/tag.rb
jsduck-troopjs-0.0.1 lib/jsduck/warning/tag.rb
jsduck-6.0.0beta lib/jsduck/warning/tag.rb