StdlibDoc::GenDoc::RDocGenerator (Class)

In: StdlibDoc/GenDoc/RDocGenerator.rb
Parent: Object

This class is solely responsible for generating RDoc output. It is told where the Ruby files are and where to put the output, and also whether the output is forced. After that, it is given a "target" (see StdlibDoc::GenDoc::Target) and it must generate the documentation, checking to see whether this actually needs to be done.

Methods

generate   new  

Public Class methods

Initialize the generator. From options, we are interested in the configuration (source and target directories) and the force option.

[Source]

# File StdlibDoc/GenDoc/RDocGenerator.rb, line 20
    def initialize(options)
      @options = options
      @config = @options.config
    end

Public Instance methods

Generate RDoc’s HTML output for this target.

[Source]

# File StdlibDoc/GenDoc/RDocGenerator.rb, line 28
    def generate(target)
      name = target.target
      puts "  generating RDoc for #{name}"
      output_dir = @config.doc_base + "libdoc" + name + "rdoc"

      Dir.chdir(target.base) do
        if target.sources.empty?
          puts "  * Ignoring; no sources to generate"
          return
        end
        # Get the latest modification time of the sources.

        sources_mtime = target.sources.map { |f| File.mtime(f) }.max
        # Get the timestamp of the last generation for this target.

        rdoc_mtime = _get_timestamp(output_dir)
        # See if generation is necessary.  Let the "force" option override.

        if sources_mtime > rdoc_mtime or @options.force
          _run_rdoc(target, output_dir)
        else
          puts "  * Sources haven't changed since last rdoc generation."
        end
      end
    end

[Validate]