Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix an issue in which RDoc would not correctly document a class' supe…

…rclass

if it encountered a reference to the class before encountered the class
definition itself (in different files).

Also, add the perl files to the Manifest.
  • Loading branch information...
commit f4cd41eb5a109c3f988f0676a5e2ecaa6fefbe40 1 parent 7a8a163
designingpatts authored
View
5 History.txt
@@ -19,6 +19,11 @@ to polish RDoc for Ruby 1.9.1.
* Fix the parsing of multiline constants (patch by Chris Alfeld and Joel VanderWerf)
* Make --exclude usuable. Ruby patch #11671 by Trans.
* Detect inline C functions. Ruby Bug #11993 by Florian Frank.
+ * Fix an issue in which RDoc might not document a class'
+ superclass correctly if the class was defined in multiple files and
+ depending on the order in which RDoc processed the files. This should
+ ensure that the child class -> parent class relationship is correct in
+ ri documentation, allowing ri to lookup inherited methods (i.e., File#read).
=== 2.2.0 / 2008-09-19
This version includes some significant enhancements to ri. See RI.txt for
View
2  Manifest.txt
@@ -47,6 +47,7 @@ lib/rdoc/options.rb
lib/rdoc/parser.rb
lib/rdoc/parser/c.rb
lib/rdoc/parser/f95.rb
+lib/rdoc/parser/perl.rb
lib/rdoc/parser/ruby.rb
lib/rdoc/parser/simple.rb
lib/rdoc/rdoc.rb
@@ -73,6 +74,7 @@ test/test_rdoc_markup_to_html.rb
test/test_rdoc_markup_to_html_crossref.rb
test/test_rdoc_parser.rb
test/test_rdoc_parser_c.rb
+test/test_rdoc_parser_perl.rb
test/test_rdoc_parser_ruby.rb
test/test_rdoc_ri_attribute_formatter.rb
test/test_rdoc_ri_default_display.rb
View
4 README.txt
@@ -46,6 +46,10 @@ The markup engine has lots of little bugs. In particular:
* Some output formats (ri, for example) do not correctly handle all of the
markup.
The markup engine needs a rewrite, which can be tracked here[http://rubyforge.org/tracker/index.php?func=detail&aid=21540&group_id=627&atid=2475].
+---
+RDoc has some subtle bugs processing classes that are split across multiple
+files (bugs that may or may not manifest depending on the order in which
+the files are encountered). This issue can be tracked here[http://rubyforge.org/tracker/index.php?func=detail&aid=22135&group_id=627&atid=2475].
-------
If you find a bug, please report it at the RDoc project's
tracker[http://rubyforge.org/tracker/?group_id=627] on RubyForge:
View
12 lib/rdoc/code_objects.rb
@@ -302,6 +302,7 @@ def add_class(class_type, name, superclass)
if mod then
klass.classes_hash.update(mod.classes_hash)
klass.modules_hash.update(mod.modules_hash)
+ klass.method_list.concat(mod.method_list)
end
return klass
@@ -625,9 +626,18 @@ def add_class_or_module(collection, class_type, name, superclass)
cls = all[name]
- unless cls then
+ if !cls then
cls = class_type.new name, superclass
all[name] = cls unless @done_documenting
+ else
+ # If the class has been encountered already, check that its
+ # superclass has been set (it may not have been, depending on
+ # the context in which it was encountered).
+ if class_type == NormalClass
+ if !cls.superclass then
+ cls.superclass = superclass
+ end
+ end
end
collection[name] = cls unless @done_documenting
View
41 test/test_rdoc_parser_ruby.rb
@@ -12,6 +12,10 @@ def setup
@tempfile = Tempfile.new self.class.name
@filename = @tempfile.path
+ # Some tests need two paths.
+ @tempfile2 = Tempfile.new self.class.name
+ @filename2 = @tempfile2.path
+
util_toplevel
@options = RDoc::Options.new
@options.quiet = true
@@ -20,6 +24,7 @@ def setup
def teardown
@tempfile.unlink
+ @tempfile2.unlink
end
def test_look_for_directives_in_commented
@@ -204,6 +209,34 @@ class Foo
assert_equal 'Foo::Baz', baz.full_name
end
+ def test_parse_class_definition_encountered_after_class_reference
+#
+# The code below is not strictly legal Ruby (Foo must have been defined
+# before Foo.bar is encountered), but RDoc might encounter Foo.bar before
+# Foo if they live in different files.
+#
+ code = <<-EOF
+def Foo.bar
+end
+
+class Foo < IO
+end
+EOF
+
+ util_parser code
+
+ @parser.scan()
+
+ assert(@top_level.modules.empty?)
+
+ foo = @top_level.classes.first
+ assert_equal 'Foo', foo.full_name
+ assert_equal 'IO', foo.superclass
+
+ bar = foo.method_list.first
+ assert_equal 'bar', bar.name
+ end
+
def test_parse_module_relative_to_top_level_namespace
comment = <<-EOF
#
@@ -699,9 +732,17 @@ def util_parser(content)
@stats
end
+ def util_two_parsers(first_file_content, second_file_content)
+ util_parser first_file_content
+
+ @parser2 = RDoc::Parser::Ruby.new @top_level2, @filename,
+ second_file_content, @options, @stats
+ end
+
def util_toplevel
RDoc::TopLevel.reset
@top_level = RDoc::TopLevel.new @filename
+ @top_level2 = RDoc::TopLevel.new @filename2
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.