Class: JsDuck::Warning::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/warning/tag.rb

Overview

Unknown tag warning.

Instance Method Summary collapse

Constructor Details

#initializeTag

Creates the :tag warning type



8
9
10
11
12
# File 'lib/jsduck/warning/tag.rb', line 8

def initialize
  @rules = []
  # disable by default
  set(false)
end

Instance Method Details

#docObject

Extensive documentation for :nodoc warning



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jsduck/warning/tag.rb', line 38

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

#enabled?(filename = "", params = []) ⇒ Boolean

True when the warning is enabled for the given filename and params combination where params contains one tagname.

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jsduck/warning/tag.rb', line 25

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

#set(enabled, path_pattern = nil, tagnames = []) ⇒ Object

Enables or disables a particular sub-warning



15
16
17
18
19
20
21
# File 'lib/jsduck/warning/tag.rb', line 15

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