1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc*: Updated to RDoc 4.0 (pre-release)

* bin/rdoc:  ditto
* test/rdoc:  ditto
* NEWS:  Updated with RDoc 4.0 information


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2012-11-27 04:28:14 +00:00
parent c72f0daa87
commit 1c279a7d27
233 changed files with 45019 additions and 5100 deletions

View file

@ -1,16 +1,14 @@
require 'rdoc/code_object'
##
# A constant
class RDoc::Constant < RDoc::CodeObject
##
# If this constant is an alias for a module or class,
# this is the RDoc::ClassModule it is an alias for.
# +nil+ otherwise.
MARSHAL_VERSION = 0 # :nodoc:
attr_accessor :is_alias_for
##
# Sets the module or class this is constant is an alias for.
attr_writer :is_alias_for
##
# The constant's name
@ -22,14 +20,23 @@ class RDoc::Constant < RDoc::CodeObject
attr_accessor :value
##
# The constant's visibility
attr_accessor :visibility
##
# Creates a new constant with +name+, +value+ and +comment+
def initialize(name, value, comment)
super()
@name = name
@name = name
@value = value
@is_alias_for = nil
@visibility = nil
self.comment = comment
end
@ -59,6 +66,27 @@ class RDoc::Constant < RDoc::CodeObject
super or is_alias_for && is_alias_for.documented?
end
##
# Full constant name including namespace
def full_name
@full_name ||= "#{parent_name}::#{@name}"
end
##
# The module or class this constant is an alias for
def is_alias_for
case @is_alias_for
when String then
found = @store.find_class_or_module @is_alias_for
@is_alias_for = found if found
@is_alias_for
else
@is_alias_for
end
end
def inspect # :nodoc:
"#<%s:0x%x %s::%s>" % [
self.class, object_id,
@ -67,12 +95,76 @@ class RDoc::Constant < RDoc::CodeObject
end
##
# Path to this constant
# Dumps this Constant for use by ri. See also #marshal_load
def marshal_dump
alias_name = case found = is_alias_for
when RDoc::CodeObject then found.full_name
else found
end
[ MARSHAL_VERSION,
@name,
full_name,
@visibility,
alias_name,
parse(@comment),
@file.absolute_name,
parent.name,
parent.class,
section.title,
]
end
##
# Loads this Constant from +array+. For a loaded Constant the following
# methods will return cached values:
#
# * #full_name
# * #parent_name
def marshal_load array
initialize array[1], nil, array[5]
@full_name = array[2]
@visibility = array[3]
@is_alias_for = array[4]
# 5 handled above
# 6 handled below
@parent_name = array[7]
@parent_class = array[8]
@section_title = array[9]
@file = RDoc::TopLevel.new array[6]
end
##
# Path to this constant for use with HTML generator output.
def path
"#{@parent.path}##{@name}"
end
def pretty_print q # :nodoc:
q.group 2, "[#{self.class.name} #{full_name}", "]" do
unless comment.empty? then
q.breakable
q.text "comment:"
q.breakable
q.pp @comment
end
end
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 to_s # :nodoc:
parent_name = parent ? parent.full_name : '(unknown)'
if is_alias_for