class RDoc::RDoc

def parse_file(filename)

def parse_file(filename)
  encoding = @options.encoding
  filename = filename.encode encoding
  @stats.add_file filename
  return if RDoc::Parser.binary? filename
  content = RDoc::Encoding.read_file filename, encoding
  return unless content
  filename_path = Pathname(filename).expand_path
  begin
    relative_path = filename_path.relative_path_from @options.root
  rescue ArgumentError
    relative_path = filename_path
  end
  if @options.page_dir and
     relative_path.to_s.start_with? @options.page_dir.to_s then
    relative_path =
      relative_path.relative_path_from @options.page_dir
  end
  top_level = @store.add_file filename, relative_name: relative_path.to_s
  parser = RDoc::Parser.for top_level, content, @options, @stats
  return unless parser
  parser.scan
  # restart documentation for the classes & modules found
  top_level.classes_or_modules.each do |cm|
    cm.done_documenting = false
  end
  top_level
rescue Errno::EACCES => e
  $stderr.puts <<-EOF
able to read #{filename}, #{e.message}
ease check the permissions for this file.  Perhaps you do not have access to
 or perhaps the original author's permissions are to restrictive.  If the
is is not your library please report a bug to the author.
  EOF
rescue => e
  $stderr.puts <<-EOF
fore reporting this, could you check that the file you're documenting
s proper syntax:
#{Gem.ruby} -c #{filename}
oc is not a full Ruby parser and will fail when fed invalid ruby programs.
e internal error was:
(#{e.class}) #{e.message}
  EOF
  $stderr.puts e.backtrace.join("\n\t") if $DEBUG_RDOC
  raise e
end