lib/rdoc/method_attr.rb in rdoc-3.12.2 vs lib/rdoc/method_attr.rb in rdoc-4.0.0.preview2

- old
+ new

@@ -96,13 +96,18 @@ ## # Order by #singleton then #name def <=>(other) - [@singleton ? 0 : 1, name] <=> [other.singleton ? 0 : 1, other.name] + [ @singleton ? 0 : 1, name] <=> + [other.singleton ? 0 : 1, other.name] end + def == other # :nodoc: + super or self.class == other.class and full_name == other.full_name + end + ## # A method/attribute is documented if any of the following is true: # - it was marked with :nodoc:; # - it has a comment; # - it is an alias for a documented method; @@ -131,10 +136,19 @@ def see @see = find_see if @see == false @see end + ## + # Sets the store for this class or module and its contained code objects. + + def store= store + super + + @file = @store.add_file @file.full_name if @file + end + def find_see # :nodoc: return nil if singleton || is_alias_for # look for the method other = find_method_or_attribute name @@ -147,11 +161,11 @@ def find_method_or_attribute name # :nodoc: return nil unless parent.respond_to? :ancestors searched = parent.ancestors - kernel = RDoc::TopLevel.all_modules_hash['Kernel'] + kernel = @store.modules_hash['Kernel'] searched << kernel if kernel && parent != kernel && !searched.include?(kernel) searched.each do |ancestor| @@ -169,14 +183,14 @@ ## # Abstract method. Contexts in their building phase call this # to register a new alias for this known method/attribute. # - # - creates a new AnyMethod/Attribute +newa+ named an_alias.new_name; - # - adds +self+ as +newa.is_alias_for+; - # - adds +newa+ to #aliases - # - adds +newa+ to the methods/attributes of +context+. + # - creates a new AnyMethod/Attribute named <tt>an_alias.new_name</tt>; + # - adds +self+ as an alias for the new method or attribute + # - adds the method or attribute to #aliases + # - adds the method or attribute to +context+. def add_alias(an_alias, context) raise NotImplementedError end @@ -269,10 +283,22 @@ def full_name @full_name ||= "#{parent_name}#{pretty_name}" end + def inspect # :nodoc: + alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil + visibility = self.visibility + visibility = "forced #{visibility}" if force_documentation + "#<%s:0x%x %s (%s)%s>" % [ + self.class, object_id, + full_name, + visibility, + alias_for, + ] + end + ## # '::' for a class method/attribute, '#' for an instance method. def name_prefix @singleton ? '::' : '#' @@ -304,11 +330,11 @@ def type singleton ? 'class' : 'instance' end ## - # Path to this method + # Path to this method for use with HTML generator output. def path "#{@parent.path}##{aref}" end @@ -340,21 +366,9 @@ q.text "comment:" q.breakable q.pp @comment end end - end - - def inspect # :nodoc: - alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil - visibility = self.visibility - visibility = "forced #{visibility}" if force_documentation - "#<%s:0x%x %s (%s)%s>" % [ - self.class, object_id, - full_name, - visibility, - alias_for, - ] end ## # Used by RDoc::Generator::JsonIndex to create a record for the search # engine.