Sha256: e6d3017232629fc44c31acedd1b5a6c437d663adc902cad53d150fb531474ec5

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

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

##
# Generates ri data files

class RDoc::Generator::RI

  RDoc::RDoc.add_generator self

  def self.for options
    new options
  end

  ##
  # Set up a new ri generator

  def initialize options #:not-new:
    @options     = options
    @store       = RDoc::RI::Store.new '.'
    @old_siginfo = nil
    @current     = nil
  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

    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

12 entries across 12 versions & 1 rubygems

Version Path
rdoc-2.5.11 lib/rdoc/generator/ri.rb
rdoc-2.5.10 lib/rdoc/generator/ri.rb
rdoc-2.5.9 lib/rdoc/generator/ri.rb
rdoc-2.5.8 lib/rdoc/generator/ri.rb
rdoc-2.5.7 lib/rdoc/generator/ri.rb
rdoc-2.5.6 lib/rdoc/generator/ri.rb
rdoc-2.5.5 lib/rdoc/generator/ri.rb
rdoc-2.5.4 lib/rdoc/generator/ri.rb
rdoc-2.5.3 lib/rdoc/generator/ri.rb
rdoc-2.5.2 lib/rdoc/generator/ri.rb
rdoc-2.5.1 lib/rdoc/generator/ri.rb
rdoc-2.5 lib/rdoc/generator/ri.rb