From e75e7fcc9f90d41ae14019c0f3b5d5048badbb5a Mon Sep 17 00:00:00 2001 From: drbrain Date: Wed, 29 Jun 2011 21:17:31 +0000 Subject: * lib/rdoc: Update to RDoc 3.8 which contains fixes for documentation in trunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/class_module.rb | 43 ++++++++++++++++++++++++++++++++++--------- lib/rdoc/known_classes.rb | 2 ++ lib/rdoc/parser/c.rb | 2 -- lib/rdoc/parser/ruby.rb | 44 ++++++++++++++++++-------------------------- lib/rdoc/ri/store.rb | 6 +----- lib/rdoc/top_level.rb | 4 ++++ 6 files changed, 59 insertions(+), 42 deletions(-) (limited to 'lib/rdoc') diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb index d7a14b73eb..e104101dcc 100644 --- a/lib/rdoc/class_module.rb +++ b/lib/rdoc/class_module.rb @@ -115,7 +115,7 @@ class RDoc::ClassModule < RDoc::Context # across multiple runs. def add_comment comment, location - return if comment.empty? + return if comment.empty? or not document_self original = comment @@ -328,7 +328,10 @@ class RDoc::ClassModule < RDoc::Context @comment = @comment_location = document end - merge_collections attributes, class_module.attributes do |add, attr| + cm = class_module + other_files = cm.in_files + + merge_collections attributes, cm.attributes, other_files do |add, attr| if add then add_attribute attr else @@ -337,7 +340,7 @@ class RDoc::ClassModule < RDoc::Context end end - merge_collections constants, class_module.constants do |add, const| + merge_collections constants, cm.constants, other_files do |add, const| if add then add_constant const else @@ -346,7 +349,7 @@ class RDoc::ClassModule < RDoc::Context end end - merge_collections includes, class_module.includes do |add, incl| + merge_collections includes, cm.includes, other_files do |add, incl| if add then add_include incl else @@ -354,7 +357,7 @@ class RDoc::ClassModule < RDoc::Context end end - merge_collections method_list, class_module.method_list do |add, meth| + merge_collections method_list, cm.method_list, other_files do |add, meth| if add then add_method meth else @@ -367,15 +370,37 @@ class RDoc::ClassModule < RDoc::Context end ## - # Merges collection +mine+ with +other+ preferring other. - - def merge_collections mine, other, &block # :nodoc: + # Merges collection +mine+ with +other+ preferring other. +other_files+ is + # used to help determine which items should be deleted. + # + # Yields whether the item should be added or removed (true or false) and the + # item to be added or removed. + # + # merge_collections things, other.things, other.in_files do |add, thing| + # if add then + # # add the thing + # else + # # remove the thing + # end + # end + + def merge_collections mine, other, other_files, &block # :nodoc: my_things = mine. group_by { |thing| thing.file } other_things = other.group_by { |thing| thing.file } + my_things.delete_if do |file, things| + next false unless other_files.include? file + + things.each do |thing| + yield false, thing + end + + true + end + other_things.each do |file, things| my_things[file].each { |thing| yield false, thing } if - my_things.include? file + my_things.include?(file) things.each do |thing| yield true, thing diff --git a/lib/rdoc/known_classes.rb b/lib/rdoc/known_classes.rb index 3feb31eae1..863be4bd5c 100644 --- a/lib/rdoc/known_classes.rb +++ b/lib/rdoc/known_classes.rb @@ -26,6 +26,7 @@ module RDoc "rb_cRange" => "Range", "rb_cRegexp" => "Regexp", "rb_cRubyVM" => "RubyVM", + "rb_cSocket" => "Socket", "rb_cString" => "String", "rb_cStruct" => "Struct", "rb_cSymbol" => "Symbol", @@ -58,6 +59,7 @@ module RDoc "rb_eZeroDivError" => "ZeroDivError", "rb_mComparable" => "Comparable", + "rb_mDL" => "DL", "rb_mEnumerable" => "Enumerable", "rb_mErrno" => "Errno", "rb_mFileTest" => "FileTest", diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index 7d05d12fb4..a0282d69f1 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -340,8 +340,6 @@ class RDoc::Parser::C < RDoc::Parser # Ignore top-object and weird struct.c dynamic stuff next if var_name == "ruby_top_self" next if var_name == "nstr" - next if var_name == "envtbl" - next if var_name == "argf" # it'd be nice to handle this one var_name = "rb_cObject" if var_name == "rb_mKernel" handle_method(type, var_name, meth_name, function, param_count, diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 50071ab736..8b7c9c3eff 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -478,7 +478,7 @@ class RDoc::Parser::Ruby < RDoc::Parser read_documentation_modifiers att, RDoc::ATTR_MODIFIERS - context.add_attribute att if att.document_self + context.add_attribute att @stats.add_attribute att else @@ -499,6 +499,8 @@ class RDoc::Parser::Ruby < RDoc::Parser tmp = RDoc::CodeObject.new read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS + # TODO In most other places we let the context keep track of document_self + # and add found items appropriately but here we do not. I'm not sure why. return unless tmp.document_self case tk.name @@ -557,7 +559,7 @@ class RDoc::Parser::Ruby < RDoc::Parser al.line = line_no read_documentation_modifiers al, RDoc::ATTR_MODIFIERS - context.add_alias al if al.document_self + context.add_alias al @stats.add_alias al al @@ -633,7 +635,7 @@ class RDoc::Parser::Ruby < RDoc::Parser cls.offset = offset cls.line = line_no - cls.add_comment comment, @top_level if cls.document_self + cls.add_comment comment, @top_level @top_level.add_to_classes_or_modules cls @stats.add_class cls @@ -657,7 +659,7 @@ class RDoc::Parser::Ruby < RDoc::Parser # notify :nodoc: all if not a constant-named class/module # (and remove any comment) - unless name =~ /\A(::)?[A-Z]/ + unless name =~ /\A(::)?[A-Z]/ then other.document_self = nil other.document_children = false other.clear_comment @@ -758,7 +760,7 @@ class RDoc::Parser::Ruby < RDoc::Parser read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS @stats.add_constant con - container.add_constant con if con.document_self + container.add_constant con true end @@ -797,7 +799,7 @@ class RDoc::Parser::Ruby < RDoc::Parser return unless meth.name - container.add_method meth if meth.document_self + container.add_method meth meth.comment = comment @@ -818,7 +820,6 @@ class RDoc::Parser::Ruby < RDoc::Parser att.line = line_no container.add_attribute att - @stats.add_attribute att end @@ -882,7 +883,6 @@ class RDoc::Parser::Ruby < RDoc::Parser tmp = RDoc::CodeObject.new read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS - return unless tmp.document_self if comment.sub!(/^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '') then rw = case $1 @@ -969,7 +969,7 @@ class RDoc::Parser::Ruby < RDoc::Parser extract_call_seq comment, meth - container.add_method meth if meth.document_self + container.add_method meth last_tk = tk @@ -1238,7 +1238,7 @@ class RDoc::Parser::Ruby < RDoc::Parser mod.record_location @top_level read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS - mod.add_comment comment, @top_level if mod.document_self + mod.add_comment comment, @top_level parse_statements(mod) @top_level.add_to_classes_or_modules mod @@ -1341,23 +1341,15 @@ class RDoc::Parser::Ruby < RDoc::Parser end when TkDEF then - if container.document_self then - parse_method container, single, tk, comment - else - nest += 1 - end + parse_method container, single, tk, comment when TkCONSTANT then - if container.document_self then - if not parse_constant container, tk, comment then - try_parse_comment = true - end + unless parse_constant container, tk, comment then + try_parse_comment = true end when TkALIAS then - if container.document_self and not current_method then - parse_alias container, single, tk, comment - end + parse_alias container, single, tk, comment unless current_method when TkYIELD then if current_method.nil? then @@ -1395,12 +1387,11 @@ class RDoc::Parser::Ruby < RDoc::Parser when /^attr_(reader|writer|accessor)$/ then parse_attr_accessor container, single, tk, comment when 'alias_method' then - parse_alias container, single, tk, comment if - container.document_self + parse_alias container, single, tk, comment when 'require', 'include' then # ignore else - if container.document_self and comment =~ /\A#\#$/ then + if comment =~ /\A#\#$/ then case comment when /^# +:?attr(_reader|_writer|_accessor)?:/ then parse_meta_attr container, single, tk, comment @@ -1523,11 +1514,12 @@ class RDoc::Parser::Ruby < RDoc::Parser end ## - # Parses statements at the toplevel in +container+ + # Parses statements in the top-level +container+ def parse_top_level_statements(container) comment = collect_first_comment look_for_directives_in(container, comment) + # HACK move if to RDoc::Context#comment= container.comment = comment if container.document_self unless comment.empty? parse_statements container, NORMAL, nil, comment end diff --git a/lib/rdoc/ri/store.rb b/lib/rdoc/ri/store.rb index e48386adcb..fe4ccc244d 100644 --- a/lib/rdoc/ri/store.rb +++ b/lib/rdoc/ri/store.rb @@ -268,11 +268,7 @@ class RDoc::RI::Store path = class_file full_name begin - disk_klass = nil - - open path, 'rb' do |io| - disk_klass = Marshal.load io.read - end + disk_klass = load_class full_name klass = disk_klass.merge klass rescue Errno::ENOENT diff --git a/lib/rdoc/top_level.rb b/lib/rdoc/top_level.rb index b9fd5c9f6f..3825a091fe 100644 --- a/lib/rdoc/top_level.rb +++ b/lib/rdoc/top_level.rb @@ -322,6 +322,7 @@ class RDoc::TopLevel < RDoc::Context # Adds +an_alias+ to +Object+ instead of +self+. def add_alias(an_alias) + object_class.record_location self return an_alias unless @document_self object_class.add_alias an_alias end @@ -330,6 +331,7 @@ class RDoc::TopLevel < RDoc::Context # Adds +constant+ to +Object+ instead of +self+. def add_constant(constant) + object_class.record_location self return constant unless @document_self object_class.add_constant constant end @@ -338,6 +340,7 @@ class RDoc::TopLevel < RDoc::Context # Adds +include+ to +Object+ instead of +self+. def add_include(include) + object_class.record_location self return include unless @document_self object_class.add_include include end @@ -346,6 +349,7 @@ class RDoc::TopLevel < RDoc::Context # Adds +method+ to +Object+ instead of +self+. def add_method(method) + object_class.record_location self return method unless @document_self object_class.add_method method end -- cgit v1.2.3