Sha256: 73e96e2523ef01a123fb7544bd8bcd03180d22d41f626251b8549f14e5ddf76f

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

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

##
# Generates ri data files

class RDoc::Generator::RI

  RDoc::RDoc.add_generator self

  ##
  # 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

2 entries across 2 versions & 1 rubygems

Version Path
rdoc-3.0.1 lib/rdoc/generator/ri.rb
rdoc-3.0 lib/rdoc/generator/ri.rb