GRAYBYTE WORDPRESS FILE MANAGER8387

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/alt/ruby19/lib64/ruby/1.9.1/rdoc/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/alt/ruby19/lib64/ruby/1.9.1/rdoc//stats.rb
require 'rdoc'

##
# RDoc statistics collector which prints a summary and report of a project's
# documentation totals.

class RDoc::Stats

  ##
  # Output level for the coverage report

  attr_reader :coverage_level

  ##
  # Count of files parsed during parsing

  attr_reader :files_so_far

  ##
  # Total number of files found

  attr_reader :num_files

  ##
  # Creates a new Stats that will have +num_files+.  +verbosity+ defaults to 1
  # which will create an RDoc::Stats::Normal outputter.

  def initialize num_files, verbosity = 1
    @files_so_far = 0
    @num_files = num_files

    @coverage_level = 0
    @doc_items = nil
    @fully_documented = false
    @num_params = 0
    @percent_doc = nil
    @start = Time.now
    @undoc_params = 0

    @display = case verbosity
               when 0 then Quiet.new   num_files
               when 1 then Normal.new  num_files
               else        Verbose.new num_files
               end
  end

  ##
  # Records the parsing of an alias +as+.

  def add_alias as
    @display.print_alias as
  end

  ##
  # Records the parsing of an attribute +attribute+

  def add_attribute attribute
    @display.print_attribute attribute
  end

  ##
  # Records the parsing of a class +klass+

  def add_class klass
    @display.print_class klass
  end

  ##
  # Records the parsing of +constant+

  def add_constant constant
    @display.print_constant constant
  end

  ##
  # Records the parsing of +file+

  def add_file(file)
    @files_so_far += 1
    @display.print_file @files_so_far, file
  end

  ##
  # Records the parsing of +method+

  def add_method(method)
    @display.print_method method
  end

  ##
  # Records the parsing of a module +mod+

  def add_module(mod)
    @display.print_module mod
  end

  ##
  # Call this to mark the beginning of parsing for display purposes

  def begin_adding
    @display.begin_adding
  end

  ##
  # Calculates documentation totals and percentages for classes, modules,
  # constants, attributes and methods.

  def calculate
    return if @doc_items

    ucm = RDoc::TopLevel.unique_classes_and_modules
    constants = []
    ucm.each { |cm| constants.concat cm.constants }

    methods = []
    ucm.each { |cm| methods.concat cm.method_list }

    attributes = []
    ucm.each { |cm| attributes.concat cm.attributes }

    @num_attributes, @undoc_attributes = doc_stats attributes
    @num_classes,    @undoc_classes    = doc_stats RDoc::TopLevel.unique_classes
    @num_constants,  @undoc_constants  = doc_stats constants
    @num_methods,    @undoc_methods    = doc_stats methods
    @num_modules,    @undoc_modules    = doc_stats RDoc::TopLevel.unique_modules

    @num_items =
      @num_attributes +
      @num_classes +
      @num_constants +
      @num_methods +
      @num_modules +
      @num_params

    @undoc_items =
      @undoc_attributes +
      @undoc_classes +
      @undoc_constants +
      @undoc_methods +
      @undoc_modules +
      @undoc_params

    @doc_items = @num_items - @undoc_items
  end

  ##
  # Sets coverage report level.  Accepted values are:
  #
  # false or nil:: No report
  # 0:: Classes, modules, constants, attributes, methods
  # 1:: Level 0 + method parameters

  def coverage_level= level
    level = -1 unless level

    @coverage_level = level
  end

  ##
  # Returns the length and number of undocumented items in +collection+.

  def doc_stats collection
    [collection.length, collection.count { |item| not item.documented? }]
  end

  ##
  # Call this to mark the end of parsing for display purposes

  def done_adding
    @display.done_adding
  end

  ##
  # The documentation status of this project.  +true+ when 100%, +false+ when
  # less than 100% and +nil+ when unknown.
  #
  # Set by calling #calculate

  def fully_documented?
    @fully_documented
  end

  ##
  # A report that says you did a great job!

  def great_job
    report = []
    report << '100% documentation!'
    report << nil
    report << 'Great Job!'

    report.join "\n"
  end

  ##
  # Calculates the percentage of items documented.

  def percent_doc
    return @percent_doc if @percent_doc

    @fully_documented = (@num_items - @doc_items) == 0

    @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?
    @percent_doc ||= 0

    @percent_doc
  end

  ##
  # Returns a report on which items are not documented

  def report
    if @coverage_level > 0 then
      require 'rdoc/markup/to_tt_only'
      require 'rdoc/generator/markup'
      require 'rdoc/text'
      extend RDoc::Text
    end

    report = []

    if @coverage_level.zero? then
      calculate

      return great_job if @num_items == @doc_items
    end

    ucm = RDoc::TopLevel.unique_classes_and_modules

    ucm.sort.each do |cm|
      report << report_class_module(cm) {
        [
          report_constants(cm),
          report_attributes(cm),
          report_methods(cm),
        ].compact
      }
    end

    if @coverage_level > 0 then
      calculate

      return great_job if @num_items == @doc_items
    end

    report.unshift nil
    report.unshift 'The following items are not documented:'

    report.join "\n"
  end

  ##
  # Returns a report on undocumented attributes in ClassModule +cm+

  def report_attributes cm
    return if cm.attributes.empty?

    report = []

    cm.each_attribute do |attr|
      next if attr.documented?
      report << "  #{attr.definition} :#{attr.name} " \
        "# in file #{attr.file.full_name}"
    end

    report
  end

  ##
  # Returns a report on undocumented items in ClassModule +cm+

  def report_class_module cm
    return if cm.fully_documented? and @coverage_level.zero?

    report = []

    if cm.in_files.empty? then
      report << "# #{cm.definition} is referenced but empty."
      report << '#'
      report << '# It probably came from another project.  ' \
        "I'm sorry I'm holding it against you."
      report << nil

      return report
    elsif cm.documented? then
      documented = true
      report << "#{cm.definition} # is documented"
    else
      report << '# in files:'

      cm.in_files.each do |file|
        report << "#   #{file.full_name}"
      end

      report << nil

      report << "#{cm.definition}"
    end

    body = yield.flatten # HACK remove #flatten

    return if body.empty? and documented

    report << nil << body unless body.empty?

    report << 'end'
    report << nil

    report
  end

  ##
  # Returns a report on undocumented constants in ClassModule +cm+

  def report_constants cm
    return if cm.constants.empty?

    report = []

    cm.each_constant do |constant|
      # TODO constant aliases are listed in the summary but not reported
      # figure out what to do here
      next if constant.documented? || constant.is_alias_for
      report << "  # in file #{constant.file.full_name}"
      report << "  #{constant.name} = nil"
    end

    report
  end

  ##
  # Returns a report on undocumented methods in ClassModule +cm+

  def report_methods cm
    return if cm.method_list.empty?

    report = []

    cm.each_method do |method|
      next if method.documented? and @coverage_level.zero?

      if @coverage_level > 0 then
        params, undoc = undoc_params method

        @num_params += params

        unless undoc.empty? then
          @undoc_params += undoc.length

          undoc = undoc.map do |param| "+#{param}+" end
          param_report = "  # #{undoc.join ', '} is not documented"
        end
      end

      next if method.documented? and not param_report
      report << "  # in file #{method.file.full_name}"
      report << param_report if param_report
      report << "  def #{method.name}#{method.params}; end"
      report << nil
    end

    report
  end

  ##
  # Returns a summary of the collected statistics.

  def summary
    calculate

    num_width = [@num_files, @num_items].max.to_s.length
    undoc_width = [
      @undoc_attributes,
      @undoc_classes,
      @undoc_constants,
      @undoc_items,
      @undoc_methods,
      @undoc_modules,
      @undoc_params,
    ].max.to_s.length

    report = []
    report << 'Files:      %*d' % [num_width, @num_files]

    report << nil

    report << 'Classes:    %*d (%*d undocumented)' % [
      num_width, @num_classes, undoc_width, @undoc_classes]
    report << 'Modules:    %*d (%*d undocumented)' % [
      num_width, @num_modules, undoc_width, @undoc_modules]
    report << 'Constants:  %*d (%*d undocumented)' % [
      num_width, @num_constants, undoc_width, @undoc_constants]
    report << 'Attributes: %*d (%*d undocumented)' % [
      num_width, @num_attributes, undoc_width, @undoc_attributes]
    report << 'Methods:    %*d (%*d undocumented)' % [
      num_width, @num_methods, undoc_width, @undoc_methods]
    report << 'Parameters: %*d (%*d undocumented)' % [
      num_width, @num_params, undoc_width, @undoc_params] if
        @coverage_level > 0

    report << nil

    report << 'Total:      %*d (%*d undocumented)' % [
      num_width, @num_items, undoc_width, @undoc_items]

    report << '%6.2f%% documented' % percent_doc
    report << nil
    report << 'Elapsed: %0.1fs' % (Time.now - @start)

    report.join "\n"
  end

  ##
  # Determines which parameters in +method+ were not documented.  Returns a
  # total parameter count and an Array of undocumented methods.

  def undoc_params method
    @formatter ||= RDoc::Markup::ToTtOnly.new

    params = method.param_list

    return 0, [] if params.empty?

    document = parse method.comment

    tts = document.accept @formatter

    undoc = params - tts

    [params.length, undoc]
  end

  autoload :Quiet,   'rdoc/stats/quiet'
  autoload :Normal,  'rdoc/stats/normal'
  autoload :Verbose, 'rdoc/stats/verbose'

end


[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
March 03 2024 22:50:37
root / root
0755
generator
--
March 03 2024 22:48:11
root / linksafe
0755
markup
--
March 03 2024 22:48:11
root / linksafe
0755
parser
--
March 03 2024 22:48:11
root / linksafe
0755
ri
--
March 03 2024 22:48:11
root / linksafe
0755
stats
--
March 03 2024 22:48:11
root / linksafe
0755
alias.rb
2.12 KB
December 20 2010 03:22:49
root / linksafe
0644
anon_class.rb
0.167 KB
February 02 2011 00:32:30
root / linksafe
0644
any_method.rb
4.544 KB
June 16 2011 04:59:24
root / linksafe
0644
attr.rb
2.877 KB
June 16 2011 04:59:24
root / linksafe
0644
class_module.rb
14.487 KB
August 05 2011 21:21:55
root / linksafe
0644
code_object.rb
6.563 KB
August 05 2011 21:21:55
root / linksafe
0644
code_objects.rb
0.522 KB
April 01 2010 07:45:16
root / linksafe
0644
constant.rb
1.505 KB
December 20 2010 03:22:49
root / linksafe
0644
context.rb
28.142 KB
August 05 2011 21:21:55
root / linksafe
0644
cross_reference.rb
5.819 KB
August 05 2011 21:21:55
root / linksafe
0644
encoding.rb
2.521 KB
February 14 2012 07:55:37
root / linksafe
0644
erbio.rb
0.775 KB
May 15 2011 11:55:52
root / linksafe
0644
generator.rb
1.298 KB
February 02 2011 00:32:30
root / linksafe
0644
ghost_method.rb
0.138 KB
April 01 2010 07:45:16
root / linksafe
0644
include.rb
2.109 KB
December 20 2010 03:22:49
root / linksafe
0644
known_classes.rb
2.58 KB
June 29 2011 21:17:31
root / linksafe
0644
markup.rb
20.962 KB
August 26 2011 23:58:26
root / linksafe
0644
meta_method.rb
0.123 KB
April 01 2010 07:45:16
root / linksafe
0644
method_attr.rb
7.573 KB
May 15 2011 11:55:52
root / linksafe
0644
normal_class.rb
1.582 KB
February 02 2011 00:32:30
root / linksafe
0644
normal_module.rb
1.242 KB
February 02 2011 00:32:30
root / linksafe
0644
options.rb
18.786 KB
May 14 2011 00:39:16
root / linksafe
0644
parser.rb
5.39 KB
August 26 2011 23:58:26
root / linksafe
0644
rdoc.rb
11.971 KB
June 16 2011 04:59:24
root / linksafe
0644
require.rb
0.94 KB
December 20 2010 03:22:49
root / linksafe
0644
ri.rb
0.225 KB
April 01 2010 07:45:16
root / linksafe
0644
ruby_lex.rb
26.07 KB
August 24 2011 00:02:17
root / linksafe
0644
ruby_token.rb
10.144 KB
December 20 2010 03:22:49
root / linksafe
0644
rubygems_hook.rb
4.497 KB
June 16 2011 04:59:24
root / linksafe
0644
single_class.rb
0.351 KB
February 02 2011 00:32:30
root / linksafe
0644
stats.rb
9.52 KB
May 14 2011 00:39:16
root / linksafe
0644
task.rb
7.504 KB
May 14 2011 00:39:16
root / linksafe
0644
text.rb
7.223 KB
August 05 2011 21:21:55
root / linksafe
0644
token_stream.rb
0.991 KB
December 20 2010 03:22:49
root / linksafe
0644
top_level.rb
10.102 KB
June 29 2011 21:17:31
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF