From 2ef9c50c6e405717d06362787c4549ca4f1c6485 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 20 Dec 2010 03:22:49 +0000 Subject: Import RDoc 3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/require.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/rdoc/require.rb') diff --git a/lib/rdoc/require.rb b/lib/rdoc/require.rb index 407b55af35..65d3d464da 100644 --- a/lib/rdoc/require.rb +++ b/lib/rdoc/require.rb @@ -16,6 +16,7 @@ class RDoc::Require < RDoc::CodeObject def initialize(name, comment) super() @name = name.gsub(/'|"/, "") #' + @top_level = nil self.comment = comment end @@ -28,5 +29,25 @@ class RDoc::Require < RDoc::CodeObject ] end + def to_s # :nodoc: + "require #{name} in: #{parent}" + end + + ## + # The RDoc::TopLevel corresponding to this require, or +nil+ if not found. + + def top_level + @top_level ||= begin + tl = RDoc::TopLevel.all_files_hash[name + '.rb'] + + if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then + # second chance + tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb'] + end + + tl + end + end + end -- cgit v1.2.3