lib/yard/code_objects/base.rb in yard-0.8.4 vs lib/yard/code_objects/base.rb in yard-0.8.4.1

- old
+ new

@@ -138,10 +138,12 @@ # The non-localized documentation string associated with the object # @return [Docstring] the documentation string # @since 0.8.4 attr_reader :base_docstring + undef base_docstring + def base_docstring; @docstring end # Marks whether or not the method is conditionally defined at runtime # @return [Boolean] true if the method is conditionally defined at runtime attr_accessor :dynamic @@ -218,11 +220,11 @@ @name = name.to_sym @source_type = :ruby @visibility = :public @tags = [] @docstrings = {} - @base_docstring = Docstring.new('', self) + @docstring = Docstring.new('', self) @namespace = nil self.namespace = namespace yield(self) if block_given? end @@ -235,11 +237,11 @@ def copy_to(other) copyable_attributes.each do |ivar| ivar = "@#{ivar}" other.instance_variable_set(ivar, instance_variable_get(ivar)) end - other.docstring = @base_docstring.to_raw + other.docstring = @docstring.to_raw other end # The name of the object # @param [Boolean] prefix whether to show a prefix. Implement @@ -370,12 +372,12 @@ # @param [String, I18n::Locale] locale (I18n::Locale.default) # the locale of the documentation string. # @return [Docstring] the documentation string def docstring(locale = I18n::Locale.default) if locale.nil? - @base_docstring.resolve_reference - return @base_docstring + @docstring.resolve_reference + return @docstring end if locale.is_a?(String) locale_name = locale locale = nil @@ -393,13 +395,13 @@ # the comments attached to the code object to be parsed # into a docstring and meta tags. def docstring=(comments) @docstrings.clear if Docstring === comments - @base_docstring = comments + @docstring = comments else - @base_docstring = Docstring.new(comments, self) + @docstring = Docstring.new(comments, self) end end # Default type is the lowercase class name without the "Object" suffix. # Override this method to provide a custom object type @@ -523,11 +525,11 @@ # Add tags to the {#docstring} # @see Docstring#add_tag # @since 0.8.4 def add_tag(*tags) @docstrings.clear - @base_docstring.add_tag(*tags) + @docstring.add_tag(*tags) end # @return whether or not this object is a RootObject def root?; false end @@ -549,11 +551,11 @@ # "@" prefix) that should be copied when {#copy_to} is called # @see #copy_to # @since 0.8.0 def copyable_attributes vars = instance_variables.map {|ivar| ivar.to_s[1..-1] } - vars -= %w(base_docstring docstrings namespace name path) + vars -= %w(docstring docstrings namespace name path) vars end private @@ -567,16 +569,16 @@ indent = last ? last[/^([ \t]*)/, 1].length : 0 source.gsub(/^[ \t]{#{indent}}/, '') end def translate_docstring(locale) - @base_docstring.resolve_reference - return @base_docstring if locale.nil? + @docstring.resolve_reference + return @docstring if locale.nil? - text = I18n::Text.new(@base_docstring) + text = I18n::Text.new(@docstring) localized_text = text.translate(locale) docstring = Docstring.new(localized_text, self) - docstring.add_tag(*@base_docstring.tags) + docstring.add_tag(*@docstring.tags) docstring end end end end