Sha256: f47fa70e4a076dace5aa493292c870454a37af823dba1847da67aea2389e4f93

Contents?: true

Size: 1.57 KB

Versions: 10

Compression:

Stored size: 1.57 KB

Contents

require 'rdoc/generator'
require 'rdoc/ri'

##
# Generates ri data files

class RDoc::Generator::RI

  RDoc::RDoc.add_generator self

  ##
  # Description of this generator

  DESCRIPTION = 'creates ri data files'

  ##
  # Set up a new ri generator

  def initialize options #:not-new:
    @options     = options
    @store       = RDoc::RI::Store.new '.'
    @old_siginfo = nil
    @current     = nil

    @store.dry_run = @options.dry_run
  end

  ##
  # Build the initial indices and output objects based on an array of TopLevel
  # objects containing the extracted information.

  def generate top_levels
    install_siginfo_handler

    @store.load_cache

    RDoc::TopLevel.all_classes_and_modules.each do |klass|
      @current = "#{klass.class}: #{klass.full_name}"

      @store.save_class klass

      klass.each_method do |method|
        @current = "#{method.class}: #{method.full_name}"
        @store.save_method klass, method
      end

      klass.each_attribute do |attribute|
        @store.save_method klass, attribute
      end
    end

    @current = 'saving cache'

    @store.save_cache

  ensure
    @current = nil

    remove_siginfo_handler
  end

  ##
  # Installs a siginfo handler that prints the current filename.

  def install_siginfo_handler
    return unless Signal.list.key? 'INFO'

    @old_siginfo = trap 'INFO' do
      puts @current if @current
    end
  end

  ##
  # Removes a siginfo handler and replaces the previous

  def remove_siginfo_handler
    return unless Signal.list.key? 'INFO'

    handler = @old_siginfo || 'DEFAULT'

    trap 'INFO', handler
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rdoc-3.6.1 lib/rdoc/generator/ri.rb
rdoc-3.6 lib/rdoc/generator/ri.rb
rdoc-3.5.3 lib/rdoc/generator/ri.rb
rdoc-3.5.2 lib/rdoc/generator/ri.rb
rdoc-3.5.1 lib/rdoc/generator/ri.rb
rdoc-3.5 lib/rdoc/generator/ri.rb
rdoc-3.4 lib/rdoc/generator/ri.rb
rdoc-3.3 lib/rdoc/generator/ri.rb
rdoc-3.2 lib/rdoc/generator/ri.rb
rdoc-3.1 lib/rdoc/generator/ri.rb