class JsDuck::Warning::Nodoc

Missing documentation warning.

Constants

TYPES
VISIBILITIES

Public Class Methods

new() click to toggle source

Creates the :nodoc warning type

# File lib/jsduck/warning/nodoc.rb, line 14
def initialize
  @rules = []
  # disable by default
  set(false)
end

Public Instance Methods

doc() click to toggle source

Extensive documentation for :nodoc warning

# 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=[]) click to toggle source

True when the warning is enabled for the given filename and params combination, where the params contain type and visibility setting.

# 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=[]) click to toggle source

Enables or disables a particular sub-warning

# 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