### Home Classes Methods

### In Files

- lib/yard/cli/stats.rb

### Parent

Yardoc

### Methods

- ::new
- #all_objects
- #description
- #output
- #print_statistics
- #print_undocumented_objects
- #run
- #stats_for_classes
- #stats_for_constants
- #stats_for_files
- #stats_for_methods
- #stats_for_modules

### Included Modules

- YARD::Templates::Helpers::BaseHelper

### Files

- LICENSE.txt
- MIT.txt

### Class/Module Index

Quicksearch

- YARD
- YARD::CLI
- YARD::CLI::Command
- YARD::CLI::CommandParser
- YARD::CLI::Config
- YARD::CLI::Diff
- YARD::CLI::Display
- YARD::CLI::Gems
- YARD::CLI::Graph
- YARD::CLI::GraphOptions
- YARD::CLI::Help
- YARD::CLI::I18n
- YARD::CLI::List
- YARD::CLI::MarkupTypes
- YARD::CLI::Server
- YARD::CLI::Stats
- YARD::CLI::YRI
- YARD::CLI::Yardoc
- YARD::CLI::YardocOptions
- YARD::CLI::YardoptsCommand
- YARD::CodeObjects
- YARD::CodeObjects::Base
- YARD::CodeObjects::ClassObject
- YARD::CodeObjects::ClassVariableObject
- YARD::CodeObjects::CodeObjectList
- YARD::CodeObjects::ConstantObject
- YARD::CodeObjects::ExtendedMethodObject
- YARD::CodeObjects::ExtraFileObject
- YARD::CodeObjects::MacroObject
- YARD::CodeObjects::MethodObject
- YARD::CodeObjects::ModuleObject
- YARD::CodeObjects::NamespaceObject
- YARD::CodeObjects::Proxy
- YARD::CodeObjects::ProxyMethodError
- YARD::CodeObjects::RootObject
- YARD::Config
- YARD::Docstring
- YARD::DocstringParser
- YARD::Handlers
- YARD::Handlers::Base
- YARD::Handlers::C
- YARD::Handlers::C::AliasHandler
- YARD::Handlers::C::AttributeHandler
- YARD::Handlers::C::Base
- YARD::Handlers::C::ClassHandler
- YARD::Handlers::C::ConstantHandler
- YARD::Handlers::C::HandlerMethods
- YARD::Handlers::C::InitHandler
- YARD::Handlers::C::MethodHandler
- YARD::Handlers::C::MixinHandler
- YARD::Handlers::C::ModuleHandler
- YARD::Handlers::C::OverrideCommentHandler
- YARD::Handlers::C::PathHandler
- YARD::Handlers::C::StructHandler
- YARD::Handlers::C::SymbolHandler
- YARD::Handlers::HandlerAborted
- YARD::Handlers::NamespaceMissingError
- YARD::Handlers::Processor
- YARD::Handlers::Ruby
- YARD::Handlers::Ruby::AliasHandler
- YARD::Handlers::Ruby::AttributeHandler
- YARD::Handlers::Ruby::Base
- YARD::Handlers::Ruby::ClassConditionHandler
- YARD::Handlers::Ruby::ClassHandler
- YARD::Handlers::Ruby::ClassVariableHandler
- YARD::Handlers::Ruby::CommentHandler
- YARD::Handlers::Ruby::ConstantHandler
- YARD::Handlers::Ruby::DSLHandler
- YARD::Handlers::Ruby::DSLHandlerMethods
- YARD::Handlers::Ruby::ExceptionHandler
- YARD::Handlers::Ruby::ExtendHandler
- YARD::Handlers::Ruby::HandlesExtension
- YARD::Handlers::Ruby::Legacy
- YARD::Handlers::Ruby::Legacy::AliasHandler
- YARD::Handlers::Ruby::Legacy::AttributeHandler
- YARD::Handlers::Ruby::Legacy::Base
- YARD::Handlers::Ruby::Legacy::ClassConditionHandler
- YARD::Handlers::Ruby::Legacy::ClassHandler
- YARD::Handlers::Ruby::Legacy::ClassVariableHandler
- YARD::Handlers::Ruby::Legacy::CommentHandler
- YARD::Handlers::Ruby::Legacy::ConstantHandler
- YARD::Handlers::Ruby::Legacy::DSLHandler
- YARD::Handlers::Ruby::Legacy::ExceptionHandler
- YARD::Handlers::Ruby::Legacy::ExtendHandler
- YARD::Handlers::Ruby::Legacy::MethodHandler
- YARD::Handlers::Ruby::Legacy::MixinHandler
- YARD::Handlers::Ruby::Legacy::ModuleFunctionHandler
- YARD::Handlers::Ruby::Legacy::ModuleHandler
- YARD::Handlers::Ruby::Legacy::PrivateConstantHandler
- YARD::Handlers::Ruby::Legacy::VisibilityHandler
- YARD::Handlers::Ruby::Legacy::YieldHandler
- YARD::Handlers::Ruby::MethodCallWrapper
- YARD::Handlers::Ruby::MethodConditionHandler
- YARD::Handlers::Ruby::MethodHandler
- YARD::Handlers::Ruby::MixinHandler
- YARD::Handlers::Ruby::ModuleFunctionHandler
- YARD::Handlers::Ruby::ModuleHandler
- YARD::Handlers::Ruby::PrivateConstantHandler
- YARD::Handlers::Ruby::StructHandlerMethods
- YARD::Handlers::Ruby::TestNodeWrapper
- YARD::Handlers::Ruby::VisibilityHandler
- YARD::Handlers::Ruby::YieldHandler
- YARD::I18n
- YARD::I18n::Locale
- YARD::I18n::Message
- YARD::I18n::Messages
- YARD::I18n::PotGenerator
- YARD::I18n::Text
- YARD::Logger
- YARD::Options
- YARD::Parser
- YARD::Parser::Base
- YARD::Parser::C
- YARD::Parser::C::BodyStatement
- YARD::Parser::C::CParser
- YARD::Parser::C::Comment
- YARD::Parser::C::CommentParser
- YARD::Parser::C::Statement
- YARD::Parser::C::ToplevelStatement
- YARD::Parser::OrderedParser
- YARD::Parser::ParserSyntaxError
- YARD::Parser::Ruby
- YARD::Parser::Ruby::AstNode
- YARD::Parser::Ruby::ClassNode
- YARD::Parser::Ruby::CommentNode
- YARD::Parser::Ruby::ConditionalNode
- YARD::Parser::Ruby::KeywordNode
- YARD::Parser::Ruby::Legacy
- YARD::Parser::Ruby::Legacy::RubyLex
- YARD::Parser::Ruby::Legacy::RubyLex::BufferedReader
- YARD::Parser::Ruby::Legacy::RubyParser
- YARD::Parser::Ruby::Legacy::RubyToken
- YARD::Parser::Ruby::Legacy::RubyToken::TkBlockContents
- YARD::Parser::Ruby::Legacy::RubyToken::TkError
- YARD::Parser::Ruby::Legacy::RubyToken::TkId
- YARD::Parser::Ruby::Legacy::RubyToken::TkKW
- YARD::Parser::Ruby::Legacy::RubyToken::TkNode
- YARD::Parser::Ruby::Legacy::RubyToken::TkOPASGN
- YARD::Parser::Ruby::Legacy::RubyToken::TkOp
- YARD::Parser::Ruby::Legacy::RubyToken::TkStatementEnd
- YARD::Parser::Ruby::Legacy::RubyToken::TkUnknownChar
- YARD::Parser::Ruby::Legacy::RubyToken::TkVal
- YARD::Parser::Ruby::Legacy::RubyToken::TkWhitespace
- YARD::Parser::Ruby::Legacy::RubyToken::Token
- YARD::Parser::Ruby::Legacy::Statement
- YARD::Parser::Ruby::Legacy::StatementList
- YARD::Parser::Ruby::Legacy::TokenList
- YARD::Parser::Ruby::LiteralNode
- YARD::Parser::Ruby::LoopNode
- YARD::Parser::Ruby::MethodCallNode
- YARD::Parser::Ruby::MethodDefinitionNode
- YARD::Parser::Ruby::ModuleNode
- YARD::Parser::Ruby::ParameterNode
- YARD::Parser::Ruby::ReferenceNode
- YARD::Parser::Ruby::RipperParser
- YARD::Parser::Ruby::RubyParser
- YARD::Parser::SourceParser
- YARD::Parser::UndocumentableError
- YARD::Rake
- YARD::Rake::YardocTask
- YARD::Registry
- YARD::RegistryStore
- YARD::Serializers
- YARD::Serializers::Base
- YARD::Serializers::FileSystemSerializer
- YARD::Serializers::ProcessSerializer
- YARD::Serializers::StdoutSerializer
- YARD::Serializers::YardocSerializer
- YARD::Server
- YARD::Server::Adapter
- YARD::Server::Commands
- YARD::Server::Commands::Base
- YARD::Server::Commands::DisplayFileCommand
- YARD::Server::Commands::DisplayObjectCommand
- YARD::Server::Commands::FramesCommand
- YARD::Server::Commands::LibraryCommand
- YARD::Server::Commands::LibraryIndexCommand
- YARD::Server::Commands::LibraryOptions
- YARD::Server::Commands::ListCommand
- YARD::Server::Commands::SearchCommand
- YARD::Server::Commands::StaticFileCommand
- YARD::Server::DocServerHelper
- YARD::Server::DocServerSerializer
- YARD::Server::FinishRequest
- YARD::Server::LibraryNotPreparedError
- YARD::Server::LibraryVersion
- YARD::Server::NotFoundError
- YARD::Server::RackAdapter
- YARD::Server::RackMiddleware
- YARD::Server::Router
- YARD::Server::StaticCaching
- YARD::Server::WebrickAdapter
- YARD::Server::WebrickServlet
- YARD::StubProxy
- YARD::Tags
- YARD::Tags::AttributeDirective
- YARD::Tags::DefaultFactory
- YARD::Tags::DefaultTag
- YARD::Tags::Directive
- YARD::Tags::EndGroupDirective
- YARD::Tags::GroupDirective
- YARD::Tags::Library
- YARD::Tags::MacroDirective
- YARD::Tags::MethodDirective
- YARD::Tags::OptionTag
- YARD::Tags::OverloadTag
- YARD::Tags::ParseDirective
- YARD::Tags::RefTag
- YARD::Tags::RefTagList
- YARD::Tags::ScopeDirective
- YARD::Tags::Tag
- YARD::Tags::TagFormatError
- YARD::Tags::VisibilityDirective
- YARD::Templates
- YARD::Templates::Engine
- YARD::Templates::ErbCache
- YARD::Templates::Helpers
- YARD::Templates::Helpers::BaseHelper
- YARD::Templates::Helpers::FilterHelper
- YARD::Templates::Helpers::HtmlHelper
- YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
- YARD::Templates::Helpers::Markup
- YARD::Templates::Helpers::Markup::RDocMarkdown
- YARD::Templates::Helpers::Markup::RDocMarkup
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkup
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkup::RDocMarkupToHtml
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkupToHtml
- YARD::Templates::Helpers::MarkupHelper
- YARD::Templates::Helpers::MethodHelper
- YARD::Templates::Helpers::ModuleHelper
- YARD::Templates::Helpers::TextHelper
- YARD::Templates::Helpers::UMLHelper
- YARD::Templates::Section
- YARD::Templates::Template
- YARD::Templates::Template::ClassMethods
- YARD::Templates::TemplateOptions
- YARD::Verifier
- Gem
- Gem::DocManager
- Gem::SourceIndex
- Gem::Specification
- Rack
- Rack::Request
- WEBrick
- WEBrick::HTTPRequest
- Array
- File
- Hash
- Insertion
- Module
- Object
- String
- SymbolHash

No matching classes.

# YARD::CLI::Stats

@since 0.6.0

### Constants

STATS_ORDER

  Maintains the order in which `stats_for_` statistics methods should be printed.

  @see print_statistics

### Attributes

parse[RW]

@return [Boolean] whether to parse and load registry

### Public Class Methods

new(parse = true) click to toggle source

@param [Boolean] parse whether to parse and load registry (see {parse})

    # File lib/yard/cli/stats.rb, line 17
    def initialize(parse = true)
      super()
      @parse = parse
      @undoc_list = nil
      @compact = false
    end

### Public Instance Methods

all_objects() click to toggle source

@return [Array<CodeObjects::Base>] all the parsed objects in the registry,

    removing any objects that are not visible (private, protected) depending
    on the arguments passed to the command.

    # File lib/yard/cli/stats.rb, line 99
    def all_objects
      @all_objects ||= run_verifier Registry.all
    end

description() click to toggle source

    # File lib/yard/cli/stats.rb, line 24
    def description
      "Prints documentation statistics on a set of files"
    end

output(name, data, undoc = nil) click to toggle source

Prints a statistic to standard out. This method is optimized for getting Integer values, though it allows any data to be printed.

@param [String] name the statistic name @param [Integer, String] data the numeric (or any) data representing

    the statistic. If +data+ is an Integer, it should represent the
    total objects of a type.

@param [Integer, nil] undoc number of undocumented objects for the type @return [void]

    # File lib/yard/cli/stats.rb, line 143
    def output(name, data, undoc = nil)
      @total += data if data.is_a?(Integer) && undoc
      @undocumented += undoc if undoc.is_a?(Integer)
      if undoc
        data = ("%5s (% 5d undocumented)" % [data, undoc])
      else
        data = "%5s" % data
      end
      log.puts("%-12s %s" % [name + ":", data])
    end

print_statistics() click to toggle source

Prints statistics for different object types

To add statistics for a specific type, add a method `#stats_for_TYPE` to this class that calls {output}.

    # File lib/yard/cli/stats.rb, line 51
    def print_statistics
      @total, @undocumented = 0, 0
      meths = methods.map {|m| m.to_s }.grep(/^stats_for_/)
      STATS_ORDER.each do |meth|
        mname = "stats_for_#{meth}"
        if meths.include?(mname)
          send(mname)
          meths.delete(mname)
        end
      end
      meths.each {|m| send(m) }
      if @total == 0
        total = 0
      else
        total = (@total - @undocumented).to_f / @total.to_f * 100
      end
      log.puts("% 3.2f%% documented" % total)
    end

print_undocumented_objects() click to toggle source

Prints list of undocumented objects

    # File lib/yard/cli/stats.rb, line 71
    def print_undocumented_objects
      return if !@undoc_list || @undoc_list.empty?
      log.puts
      log.puts "Undocumented Objects:"

      objects = @undoc_list.sort_by {|o| o.file }
      max = objects.sort_by {|o| o.path.length }.last.path.length
      if @compact
        objects.each do |object|
          log.puts("%-#{max}s     (%s)" % [object.path,
            [object.file, object.line].compact.join(":")])
        end
      else
        last_file = nil
        objects.each do |object|
          if object.file != last_file
            log.puts
            log.puts "(in file: #{object.file})"
          end
          log.puts object.path
          last_file = object.file
        end
      end
    end

run(*args) click to toggle source

Runs the commandline utility, parsing arguments and generating output if set.

@param [Array<String>] args the list of arguments @return [void]

    # File lib/yard/cli/stats.rb, line 33
    def run(*args)
      parse_arguments(*args)

      if use_cache
        Registry.load!
      elsif parse
        YARD.parse(files, excluded)
        Registry.save(use_cache) if save_yardoc
      end

      print_statistics
      print_undocumented_objects
    end

stats_for_classes() click to toggle source

Statistics for classes

    # File lib/yard/cli/stats.rb, line 116
    def stats_for_classes
      output "Classes", *type_statistics(:class)
    end

stats_for_constants() click to toggle source

Statistics for constants

    # File lib/yard/cli/stats.rb, line 121
    def stats_for_constants
      output "Constants", *type_statistics(:constant)
    end

stats_for_files() click to toggle source

Statistics for files

    # File lib/yard/cli/stats.rb, line 104
    def stats_for_files
      files = []
      all_objects.each {|o| files |= [o.file] }
      output "Files", files.size
    end

stats_for_methods() click to toggle source

Statistics for methods

    # File lib/yard/cli/stats.rb, line 126
    def stats_for_methods
      objs = all_objects.select {|m| m.type == :method }
      objs.reject! {|m| m.is_alias? || !m.is_explicit? }
      undoc = objs.select {|m| m.docstring.blank? && !m.overridden_method }
      @undoc_list |= undoc if @undoc_list
      output "Methods", objs.size, undoc.size
    end

stats_for_modules() click to toggle source

Statistics for modules

    # File lib/yard/cli/stats.rb, line 111
    def stats_for_modules
      output "Modules", *type_statistics(:module)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.