Permalink
Browse files

Lots of fixes, including to the C parser.

  • Loading branch information...
1 parent 21aed02 commit abf8958ef21eb204db3792dd58943ccff1471122 designingpatts committed Sep 23, 2008
Showing with 42 additions and 12 deletions.
  1. +2 −0 History.txt
  2. +1 −1 lib/rdoc/parser/c.rb
  3. +3 −4 lib/rdoc/ri/display.rb
  4. +4 −2 lib/rdoc/ri/driver.rb
  5. +28 −1 test/test_rdoc_parser_c.rb
  6. +4 −4 test/test_rdoc_ri_default_display.rb
View
@@ -26,6 +26,8 @@ to polish RDoc for Ruby 1.9.1.
ri documentation, allowing ri to lookup inherited methods (i.e., File#read).
* Stop ri from crashing when it looks for a completely bogus method (i.e.,
File#reada). Now, ri exits with a helpful error message.
+ * Fixed missing display of constant values in ri.
+ * Fixed display of constants in ri's html output.
=== 2.2.0 / 2008-09-19
This version includes some significant enhancements to ri. See RI.txt for
@@ -269,7 +269,7 @@ def find_attr_comment(attr_name)
def find_body(class_name, meth_name, meth_obj, body, quiet = false)
case body
- when %r"((?>/\*.*?\*/\s*)*)(?:static|SWIGINTERN\s+)?(?:intern\s+)?VALUE\s+#{meth_name}
+ when %r"((?>/\*.*?\*/\s*)*)(?:(?:static|SWIGINTERN)\s+)?(?:intern\s+)?VALUE\s+#{meth_name}
\s*(\([^)]*\))([^;]|$)"xm
comment, params = $1, $2
body_text = $&
@@ -86,21 +86,19 @@ def display_class_info(klass)
constants = klass.constants.sort_by { |constant| constant.name }
constants.each do |constant|
+ @formatter.wrap "#{constant.name} = #{constant.value}"
if constant.comment then
- @formatter.wrap "#{constant.name}:"
-
@formatter.indent do
@formatter.display_flow constant.comment
end
else
- @formatter.wrap constant.name
+ @formatter.break_to_newline
end
end
end
unless klass.attributes.empty? then
@formatter.blankline
-
@formatter.display_heading 'Attributes:', 2, ''
attributes = klass.attributes.sort_by { |attribute| attribute.name }
@@ -113,6 +111,7 @@ def display_class_info(klass)
end
else
@formatter.wrap "#{attribute.name} (#{attribute.rw})"
+ @formatter.break_to_newline
end
end
end
@@ -524,8 +524,10 @@ def create_cache_for(klassname, path)
def lookup_ancestor(klass, orig_klass)
# This is a bit hacky, but ri will go into an infinite
# loop otherwise, since Object has an Object ancestor
- # for some reason.
- if ((klass == "Kernel") && (orig_klass == "Object"))
+ # for some reason. Depending on the documentation state, I've seen
+ # Kernel as an ancestor of Object and not as an ancestor of Object.
+ if ((orig_klass == "Object") &&
+ ((klass == "Kernel") || (klass == "Object")))
return nil
end
@@ -244,9 +244,36 @@ def test_find_class_comment_define_class_Init_Foo
assert_equal " \n a comment for class Foo on Init\n \n", klass.comment
end
+ def test_define_method
+ content = <<-EOF
+/*Method Comment! */
+static VALUE
+rb_io_s_read(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
+{
+}
+
+void
+Init_IO(void) {
+ /*
+ * a comment for class Foo on rb_define_class
+ */
+ VALUE rb_cIO = rb_define_class("IO", rb_cObject);
+ rb_define_singleton_method(rb_cIO, "read", rb_io_s_read, -1);
+}
+ EOF
+
+ klass = util_get_class content, 'rb_cIO'
+ read_method = klass.method_list.first
+ assert_equal "read", read_method.name
+ assert_equal " Method Comment! \n", read_method.comment
+ end
+
def util_get_class(content, name)
parser = util_parser content
- parser.do_classes
+ parser.scan
parser.classes[name]
end
@@ -42,9 +42,9 @@ def test_display_class_info
],
'comment' => [RDoc::Markup::Flow::P.new('SomeClass comment')],
'constants' => [
- { 'name' => 'CONSTANT', 'value' => '"value"',
+ { 'name' => 'CONSTANT', 'value' => '"value1"',
'comment' => [RDoc::Markup::Flow::P.new('CONSTANT value')] },
- { 'name' => 'CONSTANT_NOCOMMENT', 'value' => '"value"',
+ { 'name' => 'CONSTANT_NOCOMMENT', 'value' => '"value2"',
'comment' => nil },
],
'display_name' => 'Class',
@@ -70,10 +70,10 @@ def test_display_class_info
Constants:
----------
- CONSTANT:
+ CONSTANT = "value1"
CONSTANT value
- CONSTANT_NOCOMMENT
+ CONSTANT_NOCOMMENT = "value2"
Attributes:

0 comments on commit abf8958

Please sign in to comment.