~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/rdoc/code_object.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'rdoc'
 
2
require 'rdoc/text'
 
3
 
 
4
##
 
5
# Base class for the RDoc code tree.
 
6
#
 
7
# We contain the common stuff for contexts (which are containers) and other
 
8
# elements (methods, attributes and so on)
 
9
#
 
10
# Here's the tree of the CodeObject subclasses:
 
11
#
 
12
# * RDoc::Context
 
13
#   * RDoc::TopLevel
 
14
#   * RDoc::ClassModule
 
15
#     * RDoc::AnonClass
 
16
#     * RDoc::NormalClass
 
17
#     * RDoc::NormalModule
 
18
#     * RDoc::SingleClass
 
19
# * RDoc::AnyMethod
 
20
#   * RDoc::GhostMethod
 
21
#   * RDoc::MetaMethod
 
22
# * RDoc::Alias
 
23
# * RDoc::Attr
 
24
# * RDoc::Constant
 
25
# * RDoc::Require
 
26
# * RDoc::Include
 
27
 
 
28
class RDoc::CodeObject
 
29
 
 
30
  include RDoc::Text
 
31
 
 
32
  ##
 
33
  # Our comment
 
34
 
 
35
  attr_reader :comment
 
36
 
 
37
  ##
 
38
  # Do we document our children?
 
39
 
 
40
  attr_reader :document_children
 
41
 
 
42
  ##
 
43
  # Do we document ourselves?
 
44
 
 
45
  attr_reader :document_self
 
46
 
 
47
  ##
 
48
  # Are we done documenting (ie, did we come across a :enddoc:)?
 
49
 
 
50
  attr_accessor :done_documenting
 
51
 
 
52
  ##
 
53
  # Force documentation of this CodeObject
 
54
 
 
55
  attr_accessor :force_documentation
 
56
 
 
57
  ##
 
58
  # Hash of arbitrary metadata for this CodeObject
 
59
 
 
60
  attr_reader :metadata
 
61
 
 
62
  ##
 
63
  # Our parent CodeObject
 
64
 
 
65
  attr_accessor :parent
 
66
 
 
67
  ##
 
68
  # Which section are we in
 
69
 
 
70
  attr_accessor :section
 
71
 
 
72
  ##
 
73
  # We are the model of the code, but we know that at some point we will be
 
74
  # worked on by viewers. By implementing the Viewable protocol, viewers can
 
75
  # associated themselves with these objects.
 
76
 
 
77
  attr_accessor :viewer
 
78
 
 
79
  ##
 
80
  # Creates a new CodeObject that will document itself and its children
 
81
 
 
82
  def initialize
 
83
    @metadata = {}
 
84
    @comment = ''
 
85
 
 
86
    @document_children   = true
 
87
    @document_self       = true
 
88
    @done_documenting    = false
 
89
    @force_documentation = false
 
90
 
 
91
    @parent = nil
 
92
  end
 
93
 
 
94
  ##
 
95
  # Replaces our comment with +comment+, unless it is empty.
 
96
 
 
97
  def comment=(comment)
 
98
    @comment = case comment
 
99
               when NilClass               then ''
 
100
               when RDoc::Markup::Document then comment
 
101
               else
 
102
                 if comment and not comment.empty? then
 
103
                   normalize_comment comment
 
104
                 else
 
105
                   @comment
 
106
                 end
 
107
               end
 
108
  end
 
109
 
 
110
  ##
 
111
  # Enables or disables documentation of this CodeObject's children.  Calls
 
112
  # remove_classes_and_modules when disabling.
 
113
 
 
114
  def document_children=(document_children)
 
115
    @document_children = document_children
 
116
    remove_classes_and_modules unless document_children
 
117
  end
 
118
 
 
119
  ##
 
120
  # Enables or disables documentation of this CodeObject.  Calls
 
121
  # remove_methods_etc when disabling.
 
122
 
 
123
  def document_self=(document_self)
 
124
    @document_self = document_self
 
125
    remove_methods_etc unless document_self
 
126
  end
 
127
 
 
128
  ##
 
129
  # Does this class have a comment with content or is document_self false.
 
130
 
 
131
  def documented?
 
132
    !(@document_self and @comment.empty?)
 
133
  end
 
134
 
 
135
  ##
 
136
  # File name of our parent
 
137
 
 
138
  def parent_file_name
 
139
    @parent ? @parent.base_name : '(unknown)'
 
140
  end
 
141
 
 
142
  ##
 
143
  # Name of our parent
 
144
 
 
145
  def parent_name
 
146
    @parent ? @parent.full_name : '(unknown)'
 
147
  end
 
148
 
 
149
  ##
 
150
  # Callback called upon disabling documentation of children.  See
 
151
  # #document_children=
 
152
 
 
153
  def remove_classes_and_modules
 
154
  end
 
155
 
 
156
  ##
 
157
  # Callback called upon disabling documentation of ourself.  See
 
158
  # #document_self=
 
159
 
 
160
  def remove_methods_etc
 
161
  end
 
162
 
 
163
  ##
 
164
  # Enable capture of documentation
 
165
 
 
166
  def start_doc
 
167
    @document_self = true
 
168
    @document_children = true
 
169
  end
 
170
 
 
171
  ##
 
172
  # Disable capture of documentation
 
173
 
 
174
  def stop_doc
 
175
    @document_self = false
 
176
    @document_children = false
 
177
  end
 
178
 
 
179
end
 
180