rdoc 3.1 → 6.3.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (247) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +220 -0
  3. data/CVE-2013-0256.rdoc +49 -0
  4. data/ExampleMarkdown.md +37 -0
  5. data/ExampleRDoc.rdoc +208 -0
  6. data/Gemfile +12 -0
  7. data/History.rdoc +1666 -0
  8. data/LEGAL.rdoc +50 -0
  9. data/LICENSE.rdoc +57 -0
  10. data/README.rdoc +129 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +84 -81
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/{bin → exe}/rdoc +11 -2
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +1 -2
  19. data/lib/rdoc/anon_class.rb +3 -2
  20. data/lib/rdoc/any_method.rb +234 -40
  21. data/lib/rdoc/attr.rb +79 -11
  22. data/lib/rdoc/class_module.rb +443 -71
  23. data/lib/rdoc/code_object.rb +216 -20
  24. data/lib/rdoc/code_objects.rb +4 -21
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +110 -9
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +392 -172
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +83 -28
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +8 -3
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +507 -84
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +27 -74
  37. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  38. data/lib/rdoc/generator/pot/po.rb +84 -0
  39. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  40. data/lib/rdoc/generator/pot.rb +98 -0
  41. data/lib/rdoc/generator/ri.rb +8 -62
  42. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  43. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  57. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  58. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  59. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  60. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
  72. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
  73. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  74. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  75. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  76. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  77. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  78. data/lib/rdoc/generator/template/json_index/.document +1 -0
  79. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  80. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  81. data/lib/rdoc/generator.rb +24 -13
  82. data/lib/rdoc/ghost_method.rb +1 -2
  83. data/lib/rdoc/i18n/locale.rb +102 -0
  84. data/lib/rdoc/i18n/text.rb +126 -0
  85. data/lib/rdoc/i18n.rb +10 -0
  86. data/lib/rdoc/include.rb +5 -95
  87. data/lib/rdoc/known_classes.rb +5 -2
  88. data/lib/rdoc/markdown/entities.rb +2132 -0
  89. data/lib/rdoc/markdown/literals.kpeg +23 -0
  90. data/lib/rdoc/markdown/literals.rb +416 -0
  91. data/lib/rdoc/markdown.kpeg +1237 -0
  92. data/lib/rdoc/markdown.rb +16684 -0
  93. data/lib/rdoc/markup/attr_changer.rb +23 -0
  94. data/lib/rdoc/markup/attr_span.rb +36 -0
  95. data/lib/rdoc/markup/attribute_manager.rb +135 -62
  96. data/lib/rdoc/markup/attributes.rb +71 -0
  97. data/lib/rdoc/markup/blank_line.rb +1 -0
  98. data/lib/rdoc/markup/block_quote.rb +15 -0
  99. data/lib/rdoc/markup/document.rb +96 -9
  100. data/lib/rdoc/markup/formatter.rb +138 -25
  101. data/lib/rdoc/markup/hard_break.rb +32 -0
  102. data/lib/rdoc/markup/heading.rb +61 -2
  103. data/lib/rdoc/markup/include.rb +43 -0
  104. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  105. data/lib/rdoc/markup/list.rb +25 -4
  106. data/lib/rdoc/markup/list_item.rb +18 -4
  107. data/lib/rdoc/markup/paragraph.rb +15 -0
  108. data/lib/rdoc/markup/parser.rb +180 -88
  109. data/lib/rdoc/markup/pre_process.rb +183 -38
  110. data/lib/rdoc/markup/raw.rb +6 -5
  111. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  112. data/lib/rdoc/markup/rule.rb +1 -0
  113. data/lib/rdoc/markup/table.rb +47 -0
  114. data/lib/rdoc/markup/to_ansi.rb +17 -7
  115. data/lib/rdoc/markup/to_bs.rb +5 -8
  116. data/lib/rdoc/markup/to_html.rb +238 -137
  117. data/lib/rdoc/markup/to_html_crossref.rb +125 -152
  118. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  119. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  120. data/lib/rdoc/markup/to_label.rb +75 -0
  121. data/lib/rdoc/markup/to_markdown.rb +192 -0
  122. data/lib/rdoc/markup/to_rdoc.rb +85 -15
  123. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  124. data/lib/rdoc/markup/to_test.rb +2 -4
  125. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  126. data/lib/rdoc/markup/verbatim.rb +39 -0
  127. data/lib/rdoc/markup.rb +388 -110
  128. data/lib/rdoc/meta_method.rb +1 -2
  129. data/lib/rdoc/method_attr.rb +87 -21
  130. data/lib/rdoc/mixin.rb +121 -0
  131. data/lib/rdoc/normal_class.rb +39 -10
  132. data/lib/rdoc/normal_module.rb +22 -7
  133. data/lib/rdoc/options.rb +613 -73
  134. data/lib/rdoc/parser/c.rb +621 -287
  135. data/lib/rdoc/parser/changelog.rb +335 -0
  136. data/lib/rdoc/parser/markdown.rb +24 -0
  137. data/lib/rdoc/parser/rd.rb +23 -0
  138. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  139. data/lib/rdoc/parser/ruby.rb +1368 -762
  140. data/lib/rdoc/parser/ruby_tools.rb +42 -35
  141. data/lib/rdoc/parser/simple.rb +23 -11
  142. data/lib/rdoc/parser/text.rb +12 -0
  143. data/lib/rdoc/parser.rb +162 -89
  144. data/lib/rdoc/rd/block_parser.rb +1056 -0
  145. data/lib/rdoc/rd/block_parser.ry +639 -0
  146. data/lib/rdoc/rd/inline.rb +72 -0
  147. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  148. data/lib/rdoc/rd/inline_parser.ry +593 -0
  149. data/lib/rdoc/rd.rb +100 -0
  150. data/lib/rdoc/rdoc.rb +208 -115
  151. data/lib/rdoc/require.rb +1 -2
  152. data/lib/rdoc/ri/driver.rb +734 -239
  153. data/lib/rdoc/ri/formatter.rb +1 -0
  154. data/lib/rdoc/ri/paths.rb +91 -48
  155. data/lib/rdoc/ri/store.rb +3 -261
  156. data/lib/rdoc/ri/task.rb +71 -0
  157. data/lib/rdoc/ri.rb +5 -2
  158. data/lib/rdoc/rubygems_hook.rb +246 -0
  159. data/lib/rdoc/servlet.rb +451 -0
  160. data/lib/rdoc/single_class.rb +14 -2
  161. data/lib/rdoc/stats/normal.rb +19 -12
  162. data/lib/rdoc/stats/quiet.rb +1 -0
  163. data/lib/rdoc/stats/verbose.rb +1 -0
  164. data/lib/rdoc/stats.rb +262 -104
  165. data/lib/rdoc/store.rb +979 -0
  166. data/lib/rdoc/task.rb +84 -44
  167. data/lib/rdoc/text.rb +117 -72
  168. data/lib/rdoc/token_stream.rb +73 -4
  169. data/lib/rdoc/tom_doc.rb +263 -0
  170. data/lib/rdoc/top_level.rb +111 -261
  171. data/lib/rdoc/version.rb +8 -0
  172. data/lib/rdoc.rb +127 -64
  173. data/man/ri.1 +247 -0
  174. data/rdoc.gemspec +249 -0
  175. metadata +171 -291
  176. data/.autotest +0 -16
  177. data/.document +0 -5
  178. data/History.txt +0 -594
  179. data/LICENSE.txt +0 -57
  180. data/Manifest.txt +0 -158
  181. data/README.txt +0 -45
  182. data/RI.txt +0 -58
  183. data/bin/ri +0 -5
  184. data/lib/rdoc/gauntlet.rb +0 -52
  185. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
  186. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  187. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
  188. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  189. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
  190. data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
  191. data/lib/rdoc/markup/formatter_test_case.rb +0 -689
  192. data/lib/rdoc/markup/inline.rb +0 -137
  193. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
  194. data/lib/rdoc/ruby_lex.rb +0 -1291
  195. data/lib/rdoc/ruby_token.rb +0 -416
  196. data/test/README +0 -1
  197. data/test/binary.dat +0 -0
  198. data/test/hidden.zip.txt +0 -1
  199. data/test/test.ja.rdoc +0 -10
  200. data/test/test.ja.txt +0 -8
  201. data/test/test.txt +0 -1
  202. data/test/test_attribute_manager.rb +0 -120
  203. data/test/test_rdoc_alias.rb +0 -13
  204. data/test/test_rdoc_any_method.rb +0 -126
  205. data/test/test_rdoc_attr.rb +0 -61
  206. data/test/test_rdoc_class_module.rb +0 -233
  207. data/test/test_rdoc_code_object.rb +0 -165
  208. data/test/test_rdoc_constant.rb +0 -15
  209. data/test/test_rdoc_context.rb +0 -370
  210. data/test/test_rdoc_encoding.rb +0 -166
  211. data/test/test_rdoc_generator_darkfish.rb +0 -119
  212. data/test/test_rdoc_generator_ri.rb +0 -76
  213. data/test/test_rdoc_include.rb +0 -96
  214. data/test/test_rdoc_markup.rb +0 -37
  215. data/test/test_rdoc_markup_attribute_manager.rb +0 -240
  216. data/test/test_rdoc_markup_document.rb +0 -51
  217. data/test/test_rdoc_markup_paragraph.rb +0 -9
  218. data/test/test_rdoc_markup_parser.rb +0 -1395
  219. data/test/test_rdoc_markup_pre_process.rb +0 -185
  220. data/test/test_rdoc_markup_raw.rb +0 -27
  221. data/test/test_rdoc_markup_to_ansi.rb +0 -328
  222. data/test/test_rdoc_markup_to_bs.rb +0 -341
  223. data/test/test_rdoc_markup_to_html.rb +0 -335
  224. data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
  225. data/test/test_rdoc_markup_to_rdoc.rb +0 -327
  226. data/test/test_rdoc_method_attr.rb +0 -122
  227. data/test/test_rdoc_normal_class.rb +0 -17
  228. data/test/test_rdoc_normal_module.rb +0 -31
  229. data/test/test_rdoc_options.rb +0 -342
  230. data/test/test_rdoc_parser.rb +0 -83
  231. data/test/test_rdoc_parser_c.rb +0 -912
  232. data/test/test_rdoc_parser_ruby.rb +0 -1754
  233. data/test/test_rdoc_parser_simple.rb +0 -99
  234. data/test/test_rdoc_rdoc.rb +0 -164
  235. data/test/test_rdoc_require.rb +0 -25
  236. data/test/test_rdoc_ri_driver.rb +0 -846
  237. data/test/test_rdoc_ri_paths.rb +0 -43
  238. data/test/test_rdoc_ri_store.rb +0 -352
  239. data/test/test_rdoc_ruby_lex.rb +0 -23
  240. data/test/test_rdoc_stats.rb +0 -38
  241. data/test/test_rdoc_task.rb +0 -92
  242. data/test/test_rdoc_text.rb +0 -251
  243. data/test/test_rdoc_top_level.rb +0 -120
  244. data/test/xref_data.rb +0 -62
  245. data/test/xref_test_case.rb +0 -61
  246. data.tar.gz.sig +0 -3
  247. metadata.gz.sig +0 -0
data/lib/rdoc/context.rb CHANGED
@@ -1,4 +1,5 @@
1
- require 'rdoc/code_object'
1
+ # frozen_string_literal: true
2
+ require 'cgi'
2
3
 
3
4
  ##
4
5
  # A Context is something that can hold modules, classes, methods, attributes,
@@ -14,6 +15,12 @@ class RDoc::Context < RDoc::CodeObject
14
15
 
15
16
  TYPES = %w[class instance]
16
17
 
18
+ ##
19
+ # If a context has these titles it will be sorted in this order.
20
+
21
+ TOMDOC_TITLES = [nil, 'Public', 'Internal', 'Deprecated'] # :nodoc:
22
+ TOMDOC_TITLES_SORT = TOMDOC_TITLES.sort_by { |title| title.to_s } # :nodoc:
23
+
17
24
  ##
18
25
  # Class/module aliases
19
26
 
@@ -24,15 +31,20 @@ class RDoc::Context < RDoc::CodeObject
24
31
 
25
32
  attr_reader :attributes
26
33
 
34
+ ##
35
+ # Block params to be used in the next MethodAttr parsed under this context
36
+
37
+ attr_accessor :block_params
38
+
27
39
  ##
28
40
  # Constants defined
29
41
 
30
42
  attr_reader :constants
31
43
 
32
44
  ##
33
- # Current section of documentation
45
+ # Sets the current documentation section of documentation
34
46
 
35
- attr_accessor :current_section
47
+ attr_writer :current_section
36
48
 
37
49
  ##
38
50
  # Files this context is found in
@@ -44,6 +56,11 @@ class RDoc::Context < RDoc::CodeObject
44
56
 
45
57
  attr_reader :includes
46
58
 
59
+ ##
60
+ # Modules this context is extended with
61
+
62
+ attr_reader :extends
63
+
47
64
  ##
48
65
  # Methods defined in this context
49
66
 
@@ -60,9 +77,9 @@ class RDoc::Context < RDoc::CodeObject
60
77
  attr_reader :requires
61
78
 
62
79
  ##
63
- # Sections in this context
80
+ # Use this section for the next method, attribute or constant added.
64
81
 
65
- attr_reader :sections
82
+ attr_accessor :temporary_section
66
83
 
67
84
  ##
68
85
  # Hash <tt>old_name => [aliases]</tt>, for aliases
@@ -72,7 +89,7 @@ class RDoc::Context < RDoc::CodeObject
72
89
  attr_accessor :unmatched_alias_lists
73
90
 
74
91
  ##
75
- # Aliases that could not eventually be resolved.
92
+ # Aliases that could not be resolved.
76
93
 
77
94
  attr_reader :external_aliases
78
95
 
@@ -81,6 +98,11 @@ class RDoc::Context < RDoc::CodeObject
81
98
 
82
99
  attr_accessor :visibility
83
100
 
101
+ ##
102
+ # Current visibility of this line
103
+
104
+ attr_writer :current_line_visibility
105
+
84
106
  ##
85
107
  # Hash of registered methods. Attributes are also registered here,
86
108
  # twice if they are RW.
@@ -88,96 +110,14 @@ class RDoc::Context < RDoc::CodeObject
88
110
  attr_reader :methods_hash
89
111
 
90
112
  ##
91
- # Hash of registered constants.
113
+ # Params to be used in the next MethodAttr parsed under this context
92
114
 
93
- attr_reader :constants_hash
115
+ attr_accessor :params
94
116
 
95
117
  ##
96
- # A per-comment section of documentation like:
97
- #
98
- # # :section: The title
99
- # # The body
100
-
101
- class Section
102
-
103
- ##
104
- # Section comment
105
-
106
- attr_reader :comment
107
-
108
- ##
109
- # Context this Section lives in
110
-
111
- attr_reader :parent
112
-
113
- ##
114
- # Section sequence number (for linking)
115
-
116
- attr_reader :sequence
117
-
118
- ##
119
- # Section title
120
-
121
- attr_reader :title
122
-
123
- @@sequence = "SEC00000"
124
-
125
- ##
126
- # Creates a new section with +title+ and +comment+
127
-
128
- def initialize(parent, title, comment)
129
- @parent = parent
130
- @title = title
131
-
132
- @@sequence.succ!
133
- @sequence = @@sequence.dup
134
-
135
- set_comment comment
136
- end
137
-
138
- ##
139
- # Sections are equal when they have the same #sequence
140
-
141
- def ==(other)
142
- self.class === other and @sequence == other.sequence
143
- end
144
-
145
- def inspect # :nodoc:
146
- "#<%s:0x%x %s %p>" % [
147
- self.class, object_id,
148
- @sequence, title
149
- ]
150
- end
151
-
152
- ##
153
- # Set the comment for this section from the original comment block. If
154
- # the first line contains :section:, strip it and use the rest.
155
- # Otherwise remove lines up to the line containing :section:, and look
156
- # for those lines again at the end and remove them. This lets us write
157
- #
158
- # # :section: The title
159
- # # The body
160
-
161
- def set_comment(comment)
162
- return unless comment
163
-
164
- if comment =~ /^#[ \t]*:section:.*\n/ then
165
- start = $`
166
- rest = $'
167
-
168
- if start.empty?
169
- @comment = rest
170
- else
171
- @comment = rest.sub(/#{start.chomp}\Z/, '')
172
- end
173
- else
174
- @comment = comment
175
- end
176
-
177
- @comment = nil if @comment.empty?
178
- end
118
+ # Hash of registered constants.
179
119
 
180
- end
120
+ attr_reader :constants_hash
181
121
 
182
122
  ##
183
123
  # Creates an unnamed empty context with public current visibility
@@ -188,12 +128,12 @@ class RDoc::Context < RDoc::CodeObject
188
128
  @in_files = []
189
129
 
190
130
  @name ||= "unknown"
191
- @comment ||= ""
192
131
  @parent = nil
193
132
  @visibility = :public
194
133
 
195
134
  @current_section = Section.new self, nil, nil
196
- @sections = [@current_section]
135
+ @sections = { nil => @current_section }
136
+ @temporary_section = nil
197
137
 
198
138
  @classes = {}
199
139
  @modules = {}
@@ -210,24 +150,50 @@ class RDoc::Context < RDoc::CodeObject
210
150
  @aliases = []
211
151
  @requires = []
212
152
  @includes = []
153
+ @extends = []
213
154
  @constants = []
214
155
  @external_aliases = []
156
+ @current_line_visibility = nil
215
157
 
216
158
  # This Hash maps a method name to a list of unmatched aliases (aliases of
217
159
  # a method not yet encountered).
218
160
  @unmatched_alias_lists = {}
219
161
 
220
- @methods_hash = {}
162
+ @methods_hash = {}
221
163
  @constants_hash = {}
164
+
165
+ @params = nil
166
+
167
+ @store ||= nil
222
168
  end
223
169
 
224
170
  ##
225
171
  # Contexts are sorted by full_name
226
172
 
227
173
  def <=>(other)
174
+ return nil unless RDoc::CodeObject === other
175
+
228
176
  full_name <=> other.full_name
229
177
  end
230
178
 
179
+ ##
180
+ # Adds an item of type +klass+ with the given +name+ and +comment+ to the
181
+ # context.
182
+ #
183
+ # Currently only RDoc::Extend and RDoc::Include are supported.
184
+
185
+ def add klass, name, comment
186
+ if RDoc::Extend == klass then
187
+ ext = RDoc::Extend.new name, comment
188
+ add_extend ext
189
+ elsif RDoc::Include == klass then
190
+ incl = RDoc::Include.new name, comment
191
+ add_include incl
192
+ else
193
+ raise NotImplementedError, "adding a #{klass} is not implemented"
194
+ end
195
+ end
196
+
231
197
  ##
232
198
  # Adds +an_alias+ that is automatically resolved
233
199
 
@@ -265,22 +231,32 @@ class RDoc::Context < RDoc::CodeObject
265
231
  # TODO find a policy for 'attr_reader :foo' + 'def foo=()'
266
232
  register = false
267
233
 
268
- if attribute.rw.index('R') then
234
+ key = nil
235
+
236
+ if attribute.rw.index 'R' then
269
237
  key = attribute.pretty_name
270
238
  known = @methods_hash[key]
239
+
271
240
  if known then
272
241
  known.comment = attribute.comment if known.comment.empty?
242
+ elsif registered = @methods_hash[attribute.pretty_name + '='] and
243
+ RDoc::Attr === registered then
244
+ registered.rw = 'RW'
273
245
  else
274
246
  @methods_hash[key] = attribute
275
247
  register = true
276
248
  end
277
249
  end
278
250
 
279
- if attribute.rw.index('W')
280
- key = attribute.pretty_name << '='
251
+ if attribute.rw.index 'W' then
252
+ key = attribute.pretty_name + '='
281
253
  known = @methods_hash[key]
254
+
282
255
  if known then
283
256
  known.comment = attribute.comment if known.comment.empty?
257
+ elsif registered = @methods_hash[attribute.pretty_name] and
258
+ RDoc::Attr === registered then
259
+ registered.rw = 'RW'
284
260
  else
285
261
  @methods_hash[key] = attribute
286
262
  register = true
@@ -292,6 +268,8 @@ class RDoc::Context < RDoc::CodeObject
292
268
  add_to @attributes, attribute
293
269
  resolve_aliases attribute
294
270
  end
271
+
272
+ attribute
295
273
  end
296
274
 
297
275
  ##
@@ -329,12 +307,12 @@ class RDoc::Context < RDoc::CodeObject
329
307
  if full_name =~ /^(.+)::(\w+)$/ then
330
308
  name = $2
331
309
  ename = $1
332
- enclosing = RDoc::TopLevel.classes_hash[ename] ||
333
- RDoc::TopLevel.modules_hash[ename]
310
+ enclosing = @store.classes_hash[ename] || @store.modules_hash[ename]
334
311
  # HACK: crashes in actionpack/lib/action_view/helpers/form_helper.rb (metaprogramming)
335
312
  unless enclosing then
336
313
  # try the given name at top level (will work for the above example)
337
- enclosing = RDoc::TopLevel.classes_hash[given_name] || RDoc::TopLevel.modules_hash[given_name]
314
+ enclosing = @store.classes_hash[given_name] ||
315
+ @store.modules_hash[given_name]
338
316
  return enclosing if enclosing
339
317
  # not found: create the parent(s)
340
318
  names = ename.split('::')
@@ -351,6 +329,13 @@ class RDoc::Context < RDoc::CodeObject
351
329
  end
352
330
  end
353
331
 
332
+ # fix up superclass
333
+ if full_name == 'BasicObject' then
334
+ superclass = nil
335
+ elsif full_name == 'Object' then
336
+ superclass = '::BasicObject'
337
+ end
338
+
354
339
  # find the superclass full name
355
340
  if superclass then
356
341
  if superclass =~ /^:+/ then
@@ -367,7 +352,7 @@ class RDoc::Context < RDoc::CodeObject
367
352
  end
368
353
 
369
354
  # did we believe it was a module?
370
- mod = RDoc::TopLevel.modules_hash.delete superclass
355
+ mod = @store.modules_hash.delete superclass
371
356
 
372
357
  upgrade_to_class mod, RDoc::NormalClass, mod.parent if mod
373
358
 
@@ -375,11 +360,12 @@ class RDoc::Context < RDoc::CodeObject
375
360
  superclass = nil if superclass == full_name
376
361
  end
377
362
 
378
- klass = RDoc::TopLevel.classes_hash[full_name]
363
+ klass = @store.classes_hash[full_name]
379
364
 
380
365
  if klass then
381
366
  # if TopLevel, it may not be registered in the classes:
382
367
  enclosing.classes_hash[name] = klass
368
+
383
369
  # update the superclass if needed
384
370
  if superclass then
385
371
  existing = klass.superclass
@@ -391,7 +377,7 @@ class RDoc::Context < RDoc::CodeObject
391
377
  end
392
378
  else
393
379
  # this is a new class
394
- mod = RDoc::TopLevel.modules_hash.delete full_name
380
+ mod = @store.modules_hash.delete full_name
395
381
 
396
382
  if mod then
397
383
  klass = upgrade_to_class mod, RDoc::NormalClass, enclosing
@@ -401,10 +387,12 @@ class RDoc::Context < RDoc::CodeObject
401
387
  klass = class_type.new name, superclass
402
388
 
403
389
  enclosing.add_class_or_module(klass, enclosing.classes_hash,
404
- RDoc::TopLevel.classes_hash)
390
+ @store.classes_hash)
405
391
  end
406
392
  end
407
393
 
394
+ klass.parent = self
395
+
408
396
  klass
409
397
  end
410
398
 
@@ -416,15 +404,21 @@ class RDoc::Context < RDoc::CodeObject
416
404
  # to +self+, and its #section to #current_section. Returns +mod+.
417
405
 
418
406
  def add_class_or_module mod, self_hash, all_hash
419
- mod.section = @current_section # TODO declaring context? something is
420
- # wrong here...
407
+ mod.section = current_section # TODO declaring context? something is
408
+ # wrong here...
421
409
  mod.parent = self
410
+ mod.full_name = nil
411
+ mod.store = @store
422
412
 
423
413
  unless @done_documenting then
424
414
  self_hash[mod.name] = mod
425
415
  # this must be done AFTER adding mod to its parent, so that the full
426
416
  # name is correct:
427
417
  all_hash[mod.full_name] = mod
418
+ if @store.unmatched_constant_alias[mod.full_name] then
419
+ to, file = @store.unmatched_constant_alias[mod.full_name]
420
+ add_module_alias mod, mod.name, to, file
421
+ end
428
422
  end
429
423
 
430
424
  mod
@@ -434,50 +428,77 @@ class RDoc::Context < RDoc::CodeObject
434
428
  # Adds +constant+ if not already there. If it is, updates the comment,
435
429
  # value and/or is_alias_for of the known constant if they were empty/nil.
436
430
 
437
- def add_constant(constant)
431
+ def add_constant constant
438
432
  return constant unless @document_self
439
433
 
440
434
  # HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)
441
435
  # (this is a #ifdef: should be handled by the C parser)
442
436
  known = @constants_hash[constant.name]
443
- if known
444
- #$stderr.puts "\nconstant #{constant.name} already registered"
437
+
438
+ if known then
445
439
  known.comment = constant.comment if known.comment.empty?
446
- known.value = constant.value if known.value.nil? or known.value.strip.empty?
440
+
441
+ known.value = constant.value if
442
+ known.value.nil? or known.value.strip.empty?
443
+
447
444
  known.is_alias_for ||= constant.is_alias_for
448
445
  else
449
446
  @constants_hash[constant.name] = constant
450
447
  add_to @constants, constant
451
448
  end
449
+
450
+ constant
452
451
  end
453
452
 
454
453
  ##
455
454
  # Adds included module +include+ which should be an RDoc::Include
456
455
 
457
- def add_include(include)
456
+ def add_include include
458
457
  add_to @includes, include
458
+
459
+ include
460
+ end
461
+
462
+ ##
463
+ # Adds extension module +ext+ which should be an RDoc::Extend
464
+
465
+ def add_extend ext
466
+ add_to @extends, ext
467
+
468
+ ext
459
469
  end
460
470
 
461
471
  ##
462
472
  # Adds +method+ if not already there. If it is (as method or attribute),
463
473
  # updates the comment if it was empty.
464
474
 
465
- def add_method(method)
475
+ def add_method method
466
476
  return method unless @document_self
467
477
 
468
478
  # HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code)
469
479
  key = method.pretty_name
470
480
  known = @methods_hash[key]
471
- if known
472
- # TODO issue stderr messages if --verbose
473
- #$stderr.puts "\n#{display(method)} already registered as #{display(known)}"
474
- known.comment = method.comment if known.comment.empty?
481
+
482
+ if known then
483
+ if @store then # otherwise we are loading
484
+ known.comment = method.comment if known.comment.empty?
485
+ previously = ", previously in #{known.file}" unless
486
+ method.file == known.file
487
+ @store.rdoc.options.warn \
488
+ "Duplicate method #{known.full_name} in #{method.file}#{previously}"
489
+ end
475
490
  else
476
491
  @methods_hash[key] = method
477
- method.visibility = @visibility
492
+ if @current_line_visibility
493
+ method.visibility, @current_line_visibility = @current_line_visibility, nil
494
+ else
495
+ method.visibility = @visibility
496
+ end
478
497
  add_to @method_list, method
479
498
  resolve_aliases method
480
499
  end
500
+
501
+ method
481
502
  end
482
503
 
483
504
  ##
@@ -489,41 +510,58 @@ class RDoc::Context < RDoc::CodeObject
489
510
  return mod if mod
490
511
 
491
512
  full_name = child_name name
492
- mod = RDoc::TopLevel.modules_hash[full_name] || class_type.new(name)
513
+ mod = @store.modules_hash[full_name] || class_type.new(name)
493
514
 
494
- add_class_or_module(mod, @modules, RDoc::TopLevel.modules_hash)
515
+ add_class_or_module mod, @modules, @store.modules_hash
495
516
  end
496
517
 
497
518
  ##
498
- # Adds an alias from +from+ (a class or module) to +name+.
519
+ # Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
499
520
 
500
- def add_module_alias from, name
521
+ def add_module_by_normal_module(mod)
522
+ add_class_or_module mod, @modules, @store.modules_hash
523
+ end
524
+
525
+ ##
526
+ # Adds an alias from +from+ (a class or module) to +name+ which was defined
527
+ # in +file+.
528
+
529
+ def add_module_alias from, from_name, to, file
501
530
  return from if @done_documenting
502
531
 
503
- to_name = child_name(name)
532
+ to_full_name = child_name to.name
504
533
 
505
534
  # if we already know this name, don't register an alias:
506
535
  # see the metaprogramming in lib/active_support/basic_object.rb,
507
- # where we already know BasicObject as a class when we find
536
+ # where we already know BasicObject is a class when we find
508
537
  # BasicObject = BlankSlate
509
- return from if RDoc::TopLevel.find_class_or_module(to_name)
538
+ return from if @store.find_class_or_module to_full_name
539
+
540
+ unless from
541
+ @store.unmatched_constant_alias[child_name(from_name)] = [to, file]
542
+ return to
543
+ end
510
544
 
511
- if from.module? then
512
- RDoc::TopLevel.modules_hash[to_name] = from
513
- @modules[name] = from
545
+ new_to = from.dup
546
+ new_to.name = to.name
547
+ new_to.full_name = nil
548
+
549
+ if new_to.module? then
550
+ @store.modules_hash[to_full_name] = new_to
551
+ @modules[to.name] = new_to
514
552
  else
515
- RDoc::TopLevel.classes_hash[to_name] = from
516
- @classes[name] = from
553
+ @store.classes_hash[to_full_name] = new_to
554
+ @classes[to.name] = new_to
517
555
  end
518
556
 
519
- # HACK: register a constant for this alias:
520
- # constant value and comment will be updated after,
521
- # when the Ruby parser adds the constant
522
- const = RDoc::Constant.new(name, nil, '')
557
+ # Registers a constant for this alias. The constant value and comment
558
+ # will be updated later, when the Ruby parser adds the constant
559
+ const = RDoc::Constant.new to.name, nil, new_to.comment
560
+ const.record_location file
523
561
  const.is_alias_for = from
524
562
  add_constant const
525
563
 
526
- from
564
+ new_to
527
565
  end
528
566
 
529
567
  ##
@@ -539,20 +577,43 @@ class RDoc::Context < RDoc::CodeObject
539
577
  end
540
578
  end
541
579
 
580
+ ##
581
+ # Returns a section with +title+, creating it if it doesn't already exist.
582
+ # +comment+ will be appended to the section's comment.
583
+ #
584
+ # A section with a +title+ of +nil+ will return the default section.
585
+ #
586
+ # See also RDoc::Context::Section
587
+
588
+ def add_section title, comment = nil
589
+ if section = @sections[title] then
590
+ section.add_comment comment if comment
591
+ else
592
+ section = Section.new self, title, comment
593
+ @sections[title] = section
594
+ end
595
+
596
+ section
597
+ end
598
+
542
599
  ##
543
600
  # Adds +thing+ to the collection +array+
544
601
 
545
- def add_to(array, thing)
602
+ def add_to array, thing
546
603
  array << thing if @document_self
547
- thing.parent = self
548
- thing.section = @current_section
604
+
605
+ thing.parent = self
606
+ thing.store = @store if @store
607
+ thing.section = current_section
549
608
  end
550
609
 
551
610
  ##
552
611
  # Is there any content?
553
- # This means any of: comment, aliases, methods, attributes,
554
- # external aliases, require, constant.
555
- # Includes are also checked unless <tt>includes == false</tt>.
612
+ #
613
+ # This means any of: comment, aliases, methods, attributes, external
614
+ # aliases, require, constant.
615
+ #
616
+ # Includes and extends are also checked unless <tt>includes == false</tt>.
556
617
 
557
618
  def any_content(includes = true)
558
619
  @any_content ||= !(
@@ -564,7 +625,7 @@ class RDoc::Context < RDoc::CodeObject
564
625
  @requires.empty? &&
565
626
  @constants.empty?
566
627
  )
567
- @any_content || (includes && !@includes.empty?)
628
+ @any_content || (includes && !(@includes + @extends).empty? )
568
629
  end
569
630
 
570
631
  ##
@@ -615,6 +676,20 @@ class RDoc::Context < RDoc::CodeObject
615
676
  @classes
616
677
  end
617
678
 
679
+ ##
680
+ # The current documentation section that new items will be added to. If
681
+ # temporary_section is available it will be used.
682
+
683
+ def current_section
684
+ if section = @temporary_section then
685
+ @temporary_section = nil
686
+ else
687
+ section = @current_section
688
+ end
689
+
690
+ section
691
+ end
692
+
618
693
  ##
619
694
  # Is part of this thing was defined in +file+?
620
695
 
@@ -630,6 +705,16 @@ class RDoc::Context < RDoc::CodeObject
630
705
  end
631
706
  end
632
707
 
708
+ ##
709
+ # Iterator for ancestors for duck-typing. Does nothing. See
710
+ # RDoc::ClassModule#each_ancestor.
711
+ #
712
+ # This method exists to make it easy to work with Context subclasses that
713
+ # aren't part of RDoc.
714
+
715
+ def each_ancestor # :nodoc:
716
+ end
717
+
633
718
  ##
634
719
  # Iterator for attributes
635
720
 
@@ -658,11 +743,44 @@ class RDoc::Context < RDoc::CodeObject
658
743
  @includes.each do |i| yield i end
659
744
  end
660
745
 
746
+ ##
747
+ # Iterator for extension modules
748
+
749
+ def each_extend # :yields: extend
750
+ @extends.each do |e| yield e end
751
+ end
752
+
661
753
  ##
662
754
  # Iterator for methods
663
755
 
664
756
  def each_method # :yields: method
665
- @method_list.sort.each {|m| yield m}
757
+ return enum_for __method__ unless block_given?
758
+
759
+ @method_list.sort.each { |m| yield m }
760
+ end
761
+
762
+ ##
763
+ # Iterator for each section's contents sorted by title. The +section+, the
764
+ # section's +constants+ and the sections +attributes+ are yielded. The
765
+ # +constants+ and +attributes+ collections are sorted.
766
+ #
767
+ # To retrieve methods in a section use #methods_by_type with the optional
768
+ # +section+ parameter.
769
+ #
770
+ # NOTE: Do not edit collections yielded by this method
771
+
772
+ def each_section # :yields: section, constants, attributes
773
+ return enum_for __method__ unless block_given?
774
+
775
+ constants = @constants.group_by do |constant| constant.section end
776
+ attributes = @attributes.group_by do |attribute| attribute.section end
777
+
778
+ constants.default = []
779
+ attributes.default = []
780
+
781
+ sort_sections.each do |section|
782
+ yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
783
+ end
666
784
  end
667
785
 
668
786
  ##
@@ -698,7 +816,9 @@ class RDoc::Context < RDoc::CodeObject
698
816
  # Finds a constant with +name+ in this context
699
817
 
700
818
  def find_constant_named(name)
701
- @constants.find {|m| m.name == name}
819
+ @constants.find do |m|
820
+ m.name == name || m.full_name == name
821
+ end
702
822
  end
703
823
 
704
824
  ##
@@ -732,8 +852,8 @@ class RDoc::Context < RDoc::CodeObject
732
852
  ##
733
853
  # Finds a file with +name+ in this context
734
854
 
735
- def find_file_named(name)
736
- top_level.class.find_file_named(name)
855
+ def find_file_named name
856
+ @store.find_file_named name
737
857
  end
738
858
 
739
859
  ##
@@ -760,7 +880,13 @@ class RDoc::Context < RDoc::CodeObject
760
880
  # Finds a method named +name+ with singleton value +singleton+.
761
881
 
762
882
  def find_method(name, singleton)
763
- @method_list.find { |m| m.name == name && m.singleton == singleton }
883
+ @method_list.find { |m|
884
+ if m.singleton
885
+ m.name == name && m.singleton == singleton
886
+ else
887
+ m.name == name && !m.singleton && !singleton
888
+ end
889
+ }
764
890
  end
765
891
 
766
892
  ##
@@ -803,21 +929,21 @@ class RDoc::Context < RDoc::CodeObject
803
929
  # look for a class or module 'symbol'
804
930
  case symbol
805
931
  when /^::/ then
806
- result = RDoc::TopLevel.find_class_or_module(symbol)
932
+ result = @store.find_class_or_module symbol
807
933
  when /^(\w+):+(.+)$/
808
934
  suffix = $2
809
935
  top = $1
810
936
  searched = self
811
- loop do
937
+ while searched do
812
938
  mod = searched.find_module_named(top)
813
939
  break unless mod
814
- result = RDoc::TopLevel.find_class_or_module(mod.full_name + '::' + suffix)
940
+ result = @store.find_class_or_module "#{mod.full_name}::#{suffix}"
815
941
  break if result || searched.is_a?(RDoc::TopLevel)
816
942
  searched = searched.parent
817
943
  end
818
944
  else
819
945
  searched = self
820
- loop do
946
+ while searched do
821
947
  result = searched.find_module_named(symbol)
822
948
  break if result || searched.is_a?(RDoc::TopLevel)
823
949
  searched = searched.parent
@@ -867,15 +993,28 @@ class RDoc::Context < RDoc::CodeObject
867
993
  ##
868
994
  # Instance methods
869
995
 
996
+ def instance_methods
997
+ @instance_methods ||= method_list.reject { |a| a.singleton }
998
+ end
999
+
1000
+ ##
1001
+ # Instance methods
1002
+ #--
1003
+ # TODO remove this later
1004
+
870
1005
  def instance_method_list
871
- @instance_method_list ||= method_list.reject { |a| a.singleton }
1006
+ warn '#instance_method_list is obsoleted, please use #instance_methods'
1007
+ @instance_methods ||= method_list.reject { |a| a.singleton }
872
1008
  end
873
1009
 
874
1010
  ##
875
- # Breaks method_list into a nested hash by type (class or instance) and
876
- # visibility (public, protected, private)
1011
+ # Breaks method_list into a nested hash by type (<tt>'class'</tt> or
1012
+ # <tt>'instance'</tt>) and visibility (+:public+, +:protected+, +:private+).
1013
+ #
1014
+ # If +section+ is provided only methods in that RDoc::Context::Section will
1015
+ # be returned.
877
1016
 
878
- def methods_by_type
1017
+ def methods_by_type section = nil
879
1018
  methods = {}
880
1019
 
881
1020
  TYPES.each do |type|
@@ -888,6 +1027,7 @@ class RDoc::Context < RDoc::CodeObject
888
1027
  end
889
1028
 
890
1029
  each_method do |method|
1030
+ next if section and not method.section == section
891
1031
  methods[method.type][method.visibility] << method
892
1032
  end
893
1033
 
@@ -897,10 +1037,14 @@ class RDoc::Context < RDoc::CodeObject
897
1037
  ##
898
1038
  # Yields AnyMethod and Attr entries matching the list of names in +methods+.
899
1039
 
900
- def methods_matching(methods, singleton = false)
1040
+ def methods_matching(methods, singleton = false, &block)
901
1041
  (@method_list + @attributes).each do |m|
902
1042
  yield m if methods.include?(m.name) and m.singleton == singleton
903
1043
  end
1044
+
1045
+ each_ancestor do |parent|
1046
+ parent.methods_matching(methods, singleton, &block)
1047
+ end
904
1048
  end
905
1049
 
906
1050
  ##
@@ -962,25 +1106,33 @@ class RDoc::Context < RDoc::CodeObject
962
1106
  #--
963
1107
  # TODO mark the visibility of attributes in the template (if not public?)
964
1108
 
965
- def remove_invisible(min_visibility)
966
- return if min_visibility == :private
1109
+ def remove_invisible min_visibility
1110
+ return if [:private, :nodoc].include? min_visibility
967
1111
  remove_invisible_in @method_list, min_visibility
968
1112
  remove_invisible_in @attributes, min_visibility
1113
+ remove_invisible_in @constants, min_visibility
969
1114
  end
970
1115
 
971
- def remove_invisible_in(array, min_visibility) # :nodoc:
972
- if min_visibility == :public
973
- array.reject! { |e| e.visibility != :public }
1116
+ ##
1117
+ # Only called when min_visibility == :public or :private
1118
+
1119
+ def remove_invisible_in array, min_visibility # :nodoc:
1120
+ if min_visibility == :public then
1121
+ array.reject! { |e|
1122
+ e.visibility != :public and not e.force_documentation
1123
+ }
974
1124
  else
975
- array.reject! { |e| e.visibility == :private }
1125
+ array.reject! { |e|
1126
+ e.visibility == :private and not e.force_documentation
1127
+ }
976
1128
  end
977
1129
  end
978
1130
 
979
1131
  ##
980
- # Tries to resolve unmatched aliases when a method
981
- # or attribute has just been added.
1132
+ # Tries to resolve unmatched aliases when a method or attribute has just
1133
+ # been added.
982
1134
 
983
- def resolve_aliases(added)
1135
+ def resolve_aliases added
984
1136
  # resolve any pending unmatched aliases
985
1137
  key = added.pretty_name
986
1138
  unmatched_alias_list = @unmatched_alias_lists[key]
@@ -993,11 +1145,46 @@ class RDoc::Context < RDoc::CodeObject
993
1145
  end
994
1146
 
995
1147
  ##
996
- # Creates a new section with +title+ and +comment+
1148
+ # Returns RDoc::Context::Section objects referenced in this context for use
1149
+ # in a table of contents.
1150
+
1151
+ def section_contents
1152
+ used_sections = {}
1153
+
1154
+ each_method do |method|
1155
+ next unless method.display?
1156
+
1157
+ used_sections[method.section] = true
1158
+ end
1159
+
1160
+ # order found sections
1161
+ sections = sort_sections.select do |section|
1162
+ used_sections[section]
1163
+ end
1164
+
1165
+ # only the default section is used
1166
+ return [] if
1167
+ sections.length == 1 and not sections.first.title
1168
+
1169
+ sections
1170
+ end
1171
+
1172
+ ##
1173
+ # Sections in this context
1174
+
1175
+ def sections
1176
+ @sections.values
1177
+ end
997
1178
 
998
- def set_current_section(title, comment)
999
- @current_section = Section.new self, title, comment
1000
- @sections << @current_section
1179
+ def sections_hash # :nodoc:
1180
+ @sections
1181
+ end
1182
+
1183
+ ##
1184
+ # Sets the current section to a section with +title+. See also #add_section
1185
+
1186
+ def set_current_section title, comment
1187
+ @current_section = add_section title, comment
1001
1188
  end
1002
1189
 
1003
1190
  ##
@@ -1010,6 +1197,37 @@ class RDoc::Context < RDoc::CodeObject
1010
1197
  end
1011
1198
  end
1012
1199
 
1200
+ ##
1201
+ # Given an array +names+ of constants, set the visibility of each constant to
1202
+ # +visibility+
1203
+
1204
+ def set_constant_visibility_for(names, visibility)
1205
+ names.each do |name|
1206
+ constant = @constants_hash[name] or next
1207
+ constant.visibility = visibility
1208
+ end
1209
+ end
1210
+
1211
+ ##
1212
+ # Sorts sections alphabetically (default) or in TomDoc fashion (none,
1213
+ # Public, Internal, Deprecated)
1214
+
1215
+ def sort_sections
1216
+ titles = @sections.map { |title, _| title }
1217
+
1218
+ if titles.length > 1 and
1219
+ TOMDOC_TITLES_SORT ==
1220
+ (titles | TOMDOC_TITLES).sort_by { |title| title.to_s } then
1221
+ @sections.values_at(*TOMDOC_TITLES).compact
1222
+ else
1223
+ @sections.sort_by { |title, _|
1224
+ title.to_s
1225
+ }.map { |_, section|
1226
+ section
1227
+ }
1228
+ end
1229
+ end
1230
+
1013
1231
  def to_s # :nodoc:
1014
1232
  "#{self.class.name} #{self.full_name}"
1015
1233
  end
@@ -1034,13 +1252,15 @@ class RDoc::Context < RDoc::CodeObject
1034
1252
  enclosing.modules_hash.delete mod.name
1035
1253
 
1036
1254
  klass = RDoc::ClassModule.from_module class_type, mod
1255
+ klass.store = @store
1037
1256
 
1038
1257
  # if it was there, then we keep it even if done_documenting
1039
- RDoc::TopLevel.classes_hash[mod.full_name] = klass
1040
- enclosing.classes_hash[mod.name] = klass
1258
+ @store.classes_hash[mod.full_name] = klass
1259
+ enclosing.classes_hash[mod.name] = klass
1041
1260
 
1042
1261
  klass
1043
1262
  end
1044
1263
 
1045
- end
1264
+ autoload :Section, 'rdoc/context/section'
1046
1265
 
1266
+ end