Method: RDoc::RDoc#document

Defined in:
lib/rdoc/rdoc.rb

#document(argv) ⇒ Object

Format up one or more files according to the given arguments. For simplicity, argv is an array of strings, equivalent to the strings that would be passed on the command line. (This isn’t a coincidence, as we do pass in ARGV when running interactively). For a list of options, see rdoc/rdoc.rb. By default, output will be stored in a directory called doc below the current directory, so make sure you’re somewhere writable before invoking.

Throws: RDocError on error



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/rdoc/rdoc.rb', line 249

def document(argv)

  TopLevel::reset

  @stats = Stats.new

  options = Options.instance
  options.parse(argv, GENERATORS)

  @last_created = nil
  unless options.all_one_file
    @last_created = setup_output_dir(options.op_dir, options.force_update)
  end
  start_time = Time.now

  file_info = parse_files(options)

  if file_info.empty?
    $stderr.puts "\nNo newer files." unless options.quiet
  else
    gen = options.generator

    $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet

    require gen.file_name

    gen_class = Generators.const_get(gen.class_name)
    gen = gen_class.for(options)

    pwd = Dir.pwd

    Dir.chdir(options.op_dir)  unless options.all_one_file

    begin
      Diagram.new(file_info, options).draw if options.diagram
      gen.generate(file_info)
      update_output_dir(".", start_time)
    ensure
      Dir.chdir(pwd)
    end
  end

  unless options.quiet
    puts
    @stats.print
  end
end