SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.

RDoc bug: visiblity of attributes is always public

Posted on September 22nd, 2007 by Alex Gorbatchev. In Ruby. No comments yet...

It would appear that RDoc Ruby parser in Ruby 1.8.6 has a bug which leads to attributes always being public.

Here’s the fix in parser_rb.rb:

...

def parse_attr(context, single, tk, comment)
  args = parse_symbol_arg(1)
  if args.size > 0
    name = args[0]
    rw = "R"
    skip_tkspace(false)
    tk = get_tk
    if tk.kind_of? TkCOMMA
      rw = "RW" if get_bool
    else
      unget_tk tk
    end
    att = Attr.new(get_tkread, name, rw, comment)
    att.top_level = @top_level
    att.visibility = context.visibility  ######### NEW LINE ##########
    read_documentation_modifiers(att, ATTR_MODIFIERS)
    if att.document_self
      context.add_attribute(att)
    end
  else
    warn("'attr' ignored - looks like a variable")
  end
end

...

def parse_attr_accessor(context, single, tk, comment)
  args = parse_symbol_arg
  read = get_tkread
  rw = "?"

  # If nodoc is given, don't document any of them

  tmp = CodeObject.new
  read_documentation_modifiers(tmp, ATTR_MODIFIERS)
  return unless tmp.document_self

  case tk.name
  when "attr_reader"   then rw = "R"
  when "attr_writer"   then rw = "W"
  when "attr_accessor" then rw = "RW"
  else
    rw = @options.extra_accessor_flags[tk.name]
  end

  for name in args
    att = Attr.new(get_tkread, name, rw, comment)
    att.top_level = @top_level
    att.visibility = context.visibility   ######### NEW LINE ##########
    context.add_attribute(att)
  end
end
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet, be the first one!

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> , rel="nofollow" in use - no link dropping, no keywords or domains as names; do not spam, and do not advertise!

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr