Class: YARD::CLI::Stats
- Inherits:
-
Object
- Object
- YARD::CLI::Stats
- Defined in:
- lib/puppet-strings/yard.rb
Overview
Monkey patch the stats object to return statistics for our objects. This is the recommended way to add custom stats.
Instance Method Summary collapse
- #output(name, data, undoc = nil) ⇒ Object
- #stats_for_puppet_classes ⇒ Object
- #stats_for_puppet_data_type_aliases ⇒ Object
- #stats_for_puppet_data_types ⇒ Object
- #stats_for_puppet_defined_types ⇒ Object
- #stats_for_puppet_functions ⇒ Object
- #stats_for_puppet_plans ⇒ Object
- #stats_for_puppet_providers ⇒ Object
- #stats_for_puppet_tasks ⇒ Object
- #stats_for_puppet_types ⇒ Object
-
#type_statistics_all(type) ⇒ Object
This differs from the YARD implementation in that it considers a docstring without text but with tags to be undocumented.
Instance Method Details
#output(name, data, undoc = nil) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/puppet-strings/yard.rb', line 108 def output(name, data, undoc = nil) # Monkey patch output to accommodate our larger header widths @total += data if data.is_a?(Integer) && undoc @undocumented += undoc if undoc.is_a?(Integer) data = if undoc ('%5s (% 5d undocumented)' % [data, undoc]) else '%5s' % data end log.puts('%-21s %s' % [name + ':', data]) end |
#stats_for_puppet_classes ⇒ Object
71 72 73 |
# File 'lib/puppet-strings/yard.rb', line 71 def stats_for_puppet_classes output 'Puppet Classes', *type_statistics_all(:puppet_class) end |
#stats_for_puppet_data_type_aliases ⇒ Object
79 80 81 |
# File 'lib/puppet-strings/yard.rb', line 79 def stats_for_puppet_data_type_aliases output 'Puppet Data Type Aliases', *type_statistics_all(:puppet_data_type_alias) end |
#stats_for_puppet_data_types ⇒ Object
75 76 77 |
# File 'lib/puppet-strings/yard.rb', line 75 def stats_for_puppet_data_types output 'Puppet Data Types', *type_statistics_all(:puppet_data_type) end |
#stats_for_puppet_defined_types ⇒ Object
83 84 85 |
# File 'lib/puppet-strings/yard.rb', line 83 def stats_for_puppet_defined_types output 'Puppet Defined Types', *type_statistics_all(:puppet_defined_type) end |
#stats_for_puppet_functions ⇒ Object
95 96 97 |
# File 'lib/puppet-strings/yard.rb', line 95 def stats_for_puppet_functions output 'Puppet Functions', *type_statistics_all(:puppet_function) end |
#stats_for_puppet_plans ⇒ Object
103 104 105 106 |
# File 'lib/puppet-strings/yard.rb', line 103 def stats_for_puppet_plans return unless PuppetStrings.puppet_5? output 'Puppet Plans', *type_statistics_all(:puppet_plan) end |
#stats_for_puppet_providers ⇒ Object
91 92 93 |
# File 'lib/puppet-strings/yard.rb', line 91 def stats_for_puppet_providers output 'Puppet Providers', *type_statistics_all(:puppet_provider) end |
#stats_for_puppet_tasks ⇒ Object
99 100 101 |
# File 'lib/puppet-strings/yard.rb', line 99 def stats_for_puppet_tasks output 'Puppet Tasks', *type_statistics_all(:puppet_task) end |
#stats_for_puppet_types ⇒ Object
87 88 89 |
# File 'lib/puppet-strings/yard.rb', line 87 def stats_for_puppet_types output 'Puppet Types', *type_statistics_all(:puppet_type) end |
#type_statistics_all(type) ⇒ Object
This differs from the YARD implementation in that it considers a docstring without text but with tags to be undocumented.
123 124 125 126 127 128 |
# File 'lib/puppet-strings/yard.rb', line 123 def type_statistics_all(type) objs = all_objects.select {|m| m.type == type } undoc = objs.find_all {|m| m.docstring.all.empty? } @undoc_list |= undoc if @undoc_list [objs.size, undoc.size] end |