Class: JsDuck::Warning::Nodoc
- Inherits:
-
Object
- Object
- JsDuck::Warning::Nodoc
- Defined in:
- lib/jsduck/warning/nodoc.rb
Overview
Missing documentation warning.
Constant Summary collapse
- TYPES =
Set[nil, :class, :member, :param]
- VISIBILITIES =
Set[nil, :public, :protected, :private]
Instance Method Summary collapse
-
#doc ⇒ Object
Extensive documentation for :nodoc warning.
-
#enabled?(filename = "", params = []) ⇒ Boolean
True when the warning is enabled for the given filename and params combination, where the params contain type and visibility setting.
-
#initialize ⇒ Nodoc
constructor
Creates the :nodoc warning type.
-
#set(enabled, path_pattern = nil, params = []) ⇒ Object
Enables or disables a particular sub-warning.
Constructor Details
#initialize ⇒ Nodoc
Creates the :nodoc warning type
14 15 16 17 18 |
# File 'lib/jsduck/warning/nodoc.rb', line 14 def initialize @rules = [] # disable by default set(false) end |
Instance Method Details
#doc ⇒ Object
Extensive documentation for :nodoc warning
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/jsduck/warning/nodoc.rb', line 55 def doc [ "", " -nodoc(<type>,<visibility>) - Missing documentation", "", " This warning can take parameters with the following values:", "", " <type> = class | member | param", " <visibility> = public | protected | private", "", " So, to report missing documentation of public classes:", "", " --warnings='+nodoc(class,public)'", "", " Or, to report missing docs of all protected items in /etc:", "", " --warnings='+nodoc(,protected):/etc/'", "", ] end |
#enabled?(filename = "", params = []) ⇒ Boolean
True when the warning is enabled for the given filename and params combination, where the params contain type and visibility setting.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jsduck/warning/nodoc.rb', line 40 def enabled?(filename="", params=[]) type = params[0] visibility = params[1] # Filter out the most recently added rule that applies to our current item match = @rules.find do |r| (r[:type].nil? || r[:type] == type) && (r[:visibility].nil? || r[:visibility] == visibility) && (r[:path_re].nil? || r[:path_re] =~ filename) end return match[:enabled] end |
#set(enabled, path_pattern = nil, params = []) ⇒ Object
Enables or disables a particular sub-warning
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jsduck/warning/nodoc.rb', line 21 def set(enabled, path_pattern=nil, params=[]) type = params[0] visibility = params[1] unless TYPES.include?(type) && VISIBILITIES.include?(visibility) raise WarnException, "Invalid warning parameters: nodoc(#{type},#{visibility})" end @rules.unshift({ :enabled => enabled, :type => type, :visibility => visibility, :path_re => path_pattern ? Regexp.new(Regexp.escape(path_pattern)) : nil }) end |