aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/code_object.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 04:28:14 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 04:28:14 +0000
commit1c279a7d2753949c725754e1302f791b76358114 (patch)
tree36aa3bdde250e564445eba5f2e25fcb96bcb6cef /lib/rdoc/code_object.rb
parentc72f0daa877808e4fa5018b3191ca09d4b97c03d (diff)
downloadruby-1c279a7d2753949c725754e1302f791b76358114.tar.gz
* 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
Diffstat (limited to 'lib/rdoc/code_object.rb')
-rw-r--r--lib/rdoc/code_object.rb70
1 files changed, 55 insertions, 15 deletions
diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb
index 54826fffbd..e2d9d909da 100644
--- a/lib/rdoc/code_object.rb
+++ b/lib/rdoc/code_object.rb
@@ -1,6 +1,3 @@
-require 'rdoc'
-require 'rdoc/text'
-
##
# Base class for the RDoc code tree.
#
@@ -78,9 +75,9 @@ class RDoc::CodeObject
attr_accessor :offset
##
- # Our parent CodeObject
+ # Sets the parent CodeObject
- attr_accessor :parent
+ attr_writer :parent
##
# Did we ever receive a +:nodoc:+ directive?
@@ -88,9 +85,14 @@ class RDoc::CodeObject
attr_reader :received_nodoc
##
- # Which section are we in
+ # Set the section this CodeObject is in
- attr_accessor :section
+ attr_writer :section
+
+ ##
+ # The RDoc::Store for this object.
+
+ attr_accessor :store
##
# We are the model of the code, but we know that at some point we will be
@@ -103,11 +105,16 @@ class RDoc::CodeObject
# Creates a new CodeObject that will document itself and its children
def initialize
- @metadata = {}
- @comment = ''
- @parent = nil
- @file = nil
- @full_name = nil
+ @metadata = {}
+ @comment = ''
+ @parent = nil
+ @parent_name = nil # for loading
+ @parent_class = nil # for loading
+ @section = nil
+ @section_title = nil # for loading
+ @file = nil
+ @full_name = nil
+ @store = nil
@document_children = true
@document_self = true
@@ -124,11 +131,11 @@ class RDoc::CodeObject
@comment = case comment
when NilClass then ''
when RDoc::Markup::Document then comment
+ when RDoc::Comment then comment.normalize
else
if comment and not comment.empty? then
normalize_comment comment
else
- # TODO is this sufficient?
# HACK correct fix is to have #initialize create @comment
# with the correct encoding
if String === @comment and
@@ -216,7 +223,7 @@ class RDoc::CodeObject
##
# Force the documentation of this object unless documentation
- # has been turned off by :endoc:
+ # has been turned off by :enddoc:
#--
# HACK untested, was assigning to an ivar
@@ -262,6 +269,29 @@ class RDoc::CodeObject
end
##
+ # Our parent CodeObject. The parent may be missing for classes loaded from
+ # legacy RI data stores.
+
+ def parent
+ return @parent if @parent
+ return nil unless @parent_name
+
+ if @parent_class == RDoc::TopLevel then
+ @parent = @store.add_file @parent_name
+ else
+ @parent = @store.find_class_or_module @parent_name
+
+ return @parent if @parent
+
+ begin
+ @parent = @store.load_class @parent_name
+ rescue RDoc::Store::MissingFileError
+ nil
+ end
+ end
+ end
+
+ ##
# File name of our parent
def parent_file_name
@@ -284,8 +314,18 @@ class RDoc::CodeObject
end
##
+ # The section this CodeObject is in. Sections allow grouping of constants,
+ # attributes and methods inside a class or module.
+
+ def section
+ return @section if @section
+
+ @section = parent.add_section @section_title if parent
+ end
+
+ ##
# Enable capture of documentation unless documentation has been
- # turned off by :endoc:
+ # turned off by :enddoc:
def start_doc
return if @done_documenting