class Jazzy::Stats

Collect + report metadata about a processed module

Attributes

acl_skipped[R]
documented[R]
spi_skipped[R]
undocumented_decls[R]

Public Class Methods

new() click to toggle source
# File lib/jazzy/stats.rb, line 38
def initialize
  @documented = @acl_skipped = @spi_skipped = 0
  @undocumented_decls = []
end

Public Instance Methods

acl_included() click to toggle source
# File lib/jazzy/stats.rb, line 30
def acl_included
  documented + undocumented
end
add_acl_skipped() click to toggle source
# File lib/jazzy/stats.rb, line 14
def add_acl_skipped
  @acl_skipped += 1
end
add_documented() click to toggle source
# File lib/jazzy/stats.rb, line 10
def add_documented
  @documented += 1
end
add_spi_skipped() click to toggle source
# File lib/jazzy/stats.rb, line 18
def add_spi_skipped
  @spi_skipped += 1
end
add_undocumented(decl) click to toggle source
# File lib/jazzy/stats.rb, line 22
def add_undocumented(decl)
  @undocumented_decls << decl
end
doc_coverage() click to toggle source
# File lib/jazzy/stats.rb, line 68
def doc_coverage
  return 0 if acl_included == 0

  (100 * documented) / acl_included
end
remove_undocumented(decl) click to toggle source
# File lib/jazzy/stats.rb, line 26
def remove_undocumented(decl)
  @undocumented_decls.delete(decl)
end
report() click to toggle source
# File lib/jazzy/stats.rb, line 43
def report
  puts "#{doc_coverage}% documentation coverage " \
    "with #{undocumented} undocumented " \
    "#{symbol_or_symbols(undocumented)}"

  if acl_included > 0
    swift_acls = comma_list(config.min_acl.included_levels)
    puts "included #{acl_included} " +
         (config.objc_mode ? '' : "#{swift_acls} ") +
         symbol_or_symbols(acl_included)
  end

  if !config.objc_mode && acl_skipped > 0
    puts "skipped #{acl_skipped} " \
      "#{comma_list(config.min_acl.excluded_levels)} " \
      "#{symbol_or_symbols(acl_skipped)} " \
      '(use `--min-acl` to specify a different minimum ACL)'
  end

  if spi_skipped > 0
    puts "skipped #{spi_skipped} SPI #{symbol_or_symbols(spi_skipped)} " \
      '(use `--include-spi-declarations` to include these)'
  end
end
undocumented() click to toggle source
# File lib/jazzy/stats.rb, line 34
def undocumented
  undocumented_decls.count
end

Private Instance Methods

comma_list(items) click to toggle source
# File lib/jazzy/stats.rb, line 76
def comma_list(items)
  case items.count
  when 0 then ''
  when 1 then items[0]
  when 2 then "#{items[0]} or #{items[1]}"
  else "#{items[0..-2].join(', ')}, or #{items[-1]}"
  end
end
symbol_or_symbols(count) click to toggle source
# File lib/jazzy/stats.rb, line 85
def symbol_or_symbols(count)
  count == 1 ? 'symbol' : 'symbols'
end