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.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +129 -0
- data/RI.rdoc +57 -0
- data/Rakefile +84 -81
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +11 -2
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +1 -2
- data/lib/rdoc/anon_class.rb +3 -2
- data/lib/rdoc/any_method.rb +234 -40
- data/lib/rdoc/attr.rb +79 -11
- data/lib/rdoc/class_module.rb +443 -71
- data/lib/rdoc/code_object.rb +216 -20
- data/lib/rdoc/code_objects.rb +4 -21
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +110 -9
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +392 -172
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +83 -28
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +507 -84
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +27 -74
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +8 -62
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +24 -13
- data/lib/rdoc/ghost_method.rb +1 -2
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +5 -95
- data/lib/rdoc/known_classes.rb +5 -2
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +416 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16684 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +135 -62
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +96 -9
- data/lib/rdoc/markup/formatter.rb +138 -25
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +61 -2
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +25 -4
- data/lib/rdoc/markup/list_item.rb +18 -4
- data/lib/rdoc/markup/paragraph.rb +15 -0
- data/lib/rdoc/markup/parser.rb +180 -88
- data/lib/rdoc/markup/pre_process.rb +183 -38
- data/lib/rdoc/markup/raw.rb +6 -5
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +17 -7
- data/lib/rdoc/markup/to_bs.rb +5 -8
- data/lib/rdoc/markup/to_html.rb +238 -137
- data/lib/rdoc/markup/to_html_crossref.rb +125 -152
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +85 -15
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +2 -4
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +39 -0
- data/lib/rdoc/markup.rb +388 -110
- data/lib/rdoc/meta_method.rb +1 -2
- data/lib/rdoc/method_attr.rb +87 -21
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +39 -10
- data/lib/rdoc/normal_module.rb +22 -7
- data/lib/rdoc/options.rb +613 -73
- data/lib/rdoc/parser/c.rb +621 -287
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +1368 -762
- data/lib/rdoc/parser/ruby_tools.rb +42 -35
- data/lib/rdoc/parser/simple.rb +23 -11
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +162 -89
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +208 -115
- data/lib/rdoc/require.rb +1 -2
- data/lib/rdoc/ri/driver.rb +734 -239
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +91 -48
- data/lib/rdoc/ri/store.rb +3 -261
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +5 -2
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +14 -2
- data/lib/rdoc/stats/normal.rb +19 -12
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +262 -104
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +84 -44
- data/lib/rdoc/text.rb +117 -72
- data/lib/rdoc/token_stream.rb +73 -4
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +111 -261
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +127 -64
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +171 -291
- data/.autotest +0 -16
- data/.document +0 -5
- data/History.txt +0 -594
- data/LICENSE.txt +0 -57
- data/Manifest.txt +0 -158
- data/README.txt +0 -45
- data/RI.txt +0 -58
- data/bin/ri +0 -5
- data/lib/rdoc/gauntlet.rb +0 -52
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
- data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
- data/lib/rdoc/markup/formatter_test_case.rb +0 -689
- data/lib/rdoc/markup/inline.rb +0 -137
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
- data/lib/rdoc/ruby_lex.rb +0 -1291
- data/lib/rdoc/ruby_token.rb +0 -416
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_attribute_manager.rb +0 -120
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -126
- data/test/test_rdoc_attr.rb +0 -61
- data/test/test_rdoc_class_module.rb +0 -233
- data/test/test_rdoc_code_object.rb +0 -165
- data/test/test_rdoc_constant.rb +0 -15
- data/test/test_rdoc_context.rb +0 -370
- data/test/test_rdoc_encoding.rb +0 -166
- data/test/test_rdoc_generator_darkfish.rb +0 -119
- data/test/test_rdoc_generator_ri.rb +0 -76
- data/test/test_rdoc_include.rb +0 -96
- data/test/test_rdoc_markup.rb +0 -37
- data/test/test_rdoc_markup_attribute_manager.rb +0 -240
- data/test/test_rdoc_markup_document.rb +0 -51
- data/test/test_rdoc_markup_paragraph.rb +0 -9
- data/test/test_rdoc_markup_parser.rb +0 -1395
- data/test/test_rdoc_markup_pre_process.rb +0 -185
- data/test/test_rdoc_markup_raw.rb +0 -27
- data/test/test_rdoc_markup_to_ansi.rb +0 -328
- data/test/test_rdoc_markup_to_bs.rb +0 -341
- data/test/test_rdoc_markup_to_html.rb +0 -335
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
- data/test/test_rdoc_markup_to_rdoc.rb +0 -327
- data/test/test_rdoc_method_attr.rb +0 -122
- data/test/test_rdoc_normal_class.rb +0 -17
- data/test/test_rdoc_normal_module.rb +0 -31
- data/test/test_rdoc_options.rb +0 -342
- data/test/test_rdoc_parser.rb +0 -83
- data/test/test_rdoc_parser_c.rb +0 -912
- data/test/test_rdoc_parser_ruby.rb +0 -1754
- data/test/test_rdoc_parser_simple.rb +0 -99
- data/test/test_rdoc_rdoc.rb +0 -164
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -846
- data/test/test_rdoc_ri_paths.rb +0 -43
- data/test/test_rdoc_ri_store.rb +0 -352
- data/test/test_rdoc_ruby_lex.rb +0 -23
- data/test/test_rdoc_stats.rb +0 -38
- data/test/test_rdoc_task.rb +0 -92
- data/test/test_rdoc_text.rb +0 -251
- data/test/test_rdoc_top_level.rb +0 -120
- data/test/xref_data.rb +0 -62
- data/test/xref_test_case.rb +0 -61
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
data/lib/rdoc/class_module.rb
CHANGED
@@ -1,18 +1,39 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
3
2
|
##
|
4
3
|
# ClassModule is the base class for objects representing either a class or a
|
5
4
|
# module.
|
6
5
|
|
7
6
|
class RDoc::ClassModule < RDoc::Context
|
8
7
|
|
9
|
-
|
8
|
+
##
|
9
|
+
# 1::
|
10
|
+
# RDoc 3.7
|
11
|
+
# * Added visibility, singleton and file to attributes
|
12
|
+
# * Added file to constants
|
13
|
+
# * Added file to includes
|
14
|
+
# * Added file to methods
|
15
|
+
# 2::
|
16
|
+
# RDoc 3.13
|
17
|
+
# * Added extends
|
18
|
+
# 3::
|
19
|
+
# RDoc 4.0
|
20
|
+
# * Added sections
|
21
|
+
# * Added in_files
|
22
|
+
# * Added parent name
|
23
|
+
# * Complete Constant dump
|
24
|
+
|
25
|
+
MARSHAL_VERSION = 3 # :nodoc:
|
10
26
|
|
11
27
|
##
|
12
28
|
# Constants that are aliases for this class or module
|
13
29
|
|
14
30
|
attr_accessor :constant_aliases
|
15
31
|
|
32
|
+
##
|
33
|
+
# Comment and the location it came from. Use #add_comment to add comments
|
34
|
+
|
35
|
+
attr_accessor :comment_location
|
36
|
+
|
16
37
|
attr_accessor :diagram # :nodoc:
|
17
38
|
|
18
39
|
##
|
@@ -23,10 +44,16 @@ class RDoc::ClassModule < RDoc::Context
|
|
23
44
|
##
|
24
45
|
# Return a RDoc::ClassModule of class +class_type+ that is a copy
|
25
46
|
# of module +module+. Used to promote modules to classes.
|
47
|
+
#--
|
48
|
+
# TODO move to RDoc::NormalClass (I think)
|
49
|
+
|
50
|
+
def self.from_module class_type, mod
|
51
|
+
klass = class_type.new mod.name
|
52
|
+
|
53
|
+
mod.comment_location.each do |comment, location|
|
54
|
+
klass.add_comment comment, location
|
55
|
+
end
|
26
56
|
|
27
|
-
def self.from_module(class_type, mod)
|
28
|
-
klass = class_type.new(mod.name)
|
29
|
-
klass.comment = mod.comment
|
30
57
|
klass.parent = mod.parent
|
31
58
|
klass.section = mod.section
|
32
59
|
klass.viewer = mod.viewer
|
@@ -37,6 +64,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
37
64
|
klass.external_aliases.concat mod.external_aliases
|
38
65
|
klass.constants.concat mod.constants
|
39
66
|
klass.includes.concat mod.includes
|
67
|
+
klass.extends.concat mod.extends
|
40
68
|
|
41
69
|
klass.methods_hash.update mod.methods_hash
|
42
70
|
klass.constants_hash.update mod.constants_hash
|
@@ -65,6 +93,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
65
93
|
klass.external_aliases +
|
66
94
|
klass.constants +
|
67
95
|
klass.includes +
|
96
|
+
klass.extends +
|
68
97
|
klass.classes +
|
69
98
|
klass.modules).each do |obj|
|
70
99
|
obj.parent = klass
|
@@ -85,9 +114,48 @@ class RDoc::ClassModule < RDoc::Context
|
|
85
114
|
@is_alias_for = nil
|
86
115
|
@name = name
|
87
116
|
@superclass = superclass
|
117
|
+
@comment_location = [] # [[comment, location]]
|
118
|
+
|
88
119
|
super()
|
89
120
|
end
|
90
121
|
|
122
|
+
##
|
123
|
+
# Adds +comment+ to this ClassModule's list of comments at +location+. This
|
124
|
+
# method is preferred over #comment= since it allows ri data to be updated
|
125
|
+
# across multiple runs.
|
126
|
+
|
127
|
+
def add_comment comment, location
|
128
|
+
return unless document_self
|
129
|
+
|
130
|
+
original = comment
|
131
|
+
|
132
|
+
comment = case comment
|
133
|
+
when RDoc::Comment then
|
134
|
+
comment.normalize
|
135
|
+
else
|
136
|
+
normalize_comment comment
|
137
|
+
end
|
138
|
+
|
139
|
+
if location.parser == RDoc::Parser::C
|
140
|
+
@comment_location.delete_if { |(_, l)| l == location }
|
141
|
+
end
|
142
|
+
|
143
|
+
@comment_location << [comment, location]
|
144
|
+
|
145
|
+
self.comment = original
|
146
|
+
end
|
147
|
+
|
148
|
+
def add_things my_things, other_things # :nodoc:
|
149
|
+
other_things.each do |group, things|
|
150
|
+
my_things[group].each { |thing| yield false, thing } if
|
151
|
+
my_things.include? group
|
152
|
+
|
153
|
+
things.each do |thing|
|
154
|
+
yield true, thing
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
91
159
|
##
|
92
160
|
# Ancestors list for this ClassModule: the list of included modules
|
93
161
|
# (classes will add their superclass if any).
|
@@ -104,31 +172,53 @@ class RDoc::ClassModule < RDoc::Context
|
|
104
172
|
includes.map { |i| i.module }.reverse
|
105
173
|
end
|
106
174
|
|
175
|
+
def aref_prefix # :nodoc:
|
176
|
+
raise NotImplementedError, "missing aref_prefix for #{self.class}"
|
177
|
+
end
|
178
|
+
|
107
179
|
##
|
108
|
-
#
|
180
|
+
# HTML fragment reference for this module or class. See
|
181
|
+
# RDoc::NormalClass#aref and RDoc::NormalModule#aref
|
182
|
+
|
183
|
+
def aref
|
184
|
+
"#{aref_prefix}-#{full_name}"
|
185
|
+
end
|
186
|
+
|
187
|
+
##
|
188
|
+
# Ancestors of this class or module only
|
189
|
+
|
190
|
+
alias direct_ancestors ancestors
|
191
|
+
|
192
|
+
##
|
193
|
+
# Clears the comment. Used by the Ruby parser.
|
109
194
|
|
110
195
|
def clear_comment
|
111
196
|
@comment = ''
|
112
197
|
end
|
113
198
|
|
114
199
|
##
|
200
|
+
# This method is deprecated, use #add_comment instead.
|
201
|
+
#
|
115
202
|
# Appends +comment+ to the current comment, but separated by a rule. Works
|
116
203
|
# more like <tt>+=</tt>.
|
117
204
|
|
118
|
-
def comment= comment
|
119
|
-
|
205
|
+
def comment= comment # :nodoc:
|
206
|
+
comment = case comment
|
207
|
+
when RDoc::Comment then
|
208
|
+
comment.normalize
|
209
|
+
else
|
210
|
+
normalize_comment comment
|
211
|
+
end
|
120
212
|
|
121
|
-
comment =
|
122
|
-
comment = "#{@comment}\n---\n#{comment}" unless
|
123
|
-
@comment.empty?
|
213
|
+
comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty?
|
124
214
|
|
125
|
-
super
|
215
|
+
super comment
|
126
216
|
end
|
127
217
|
|
128
218
|
##
|
129
219
|
# Prepares this ClassModule for use by a generator.
|
130
220
|
#
|
131
|
-
# See RDoc::
|
221
|
+
# See RDoc::Store#complete
|
132
222
|
|
133
223
|
def complete min_visibility
|
134
224
|
update_aliases
|
@@ -137,12 +227,42 @@ class RDoc::ClassModule < RDoc::Context
|
|
137
227
|
remove_invisible min_visibility
|
138
228
|
end
|
139
229
|
|
230
|
+
##
|
231
|
+
# Does this ClassModule or any of its methods have document_self set?
|
232
|
+
|
233
|
+
def document_self_or_methods
|
234
|
+
document_self || method_list.any?{ |m| m.document_self }
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# Does this class or module have a comment with content or is
|
239
|
+
# #received_nodoc true?
|
240
|
+
|
241
|
+
def documented?
|
242
|
+
return true if @received_nodoc
|
243
|
+
return false if @comment_location.empty?
|
244
|
+
@comment_location.any? { |comment, _| not comment.empty? }
|
245
|
+
end
|
246
|
+
|
247
|
+
##
|
248
|
+
# Iterates the ancestors of this class or module for which an
|
249
|
+
# RDoc::ClassModule exists.
|
250
|
+
|
251
|
+
def each_ancestor # :yields: module
|
252
|
+
return enum_for __method__ unless block_given?
|
253
|
+
|
254
|
+
ancestors.each do |mod|
|
255
|
+
next if String === mod
|
256
|
+
next if self == mod
|
257
|
+
yield mod
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
140
261
|
##
|
141
262
|
# Looks for a symbol in the #ancestors. See Context#find_local_symbol.
|
142
263
|
|
143
264
|
def find_ancestor_local_symbol symbol
|
144
|
-
|
145
|
-
next if m.is_a?(String)
|
265
|
+
each_ancestor do |m|
|
146
266
|
res = m.find_local_symbol(symbol)
|
147
267
|
return res if res
|
148
268
|
end
|
@@ -151,7 +271,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
151
271
|
end
|
152
272
|
|
153
273
|
##
|
154
|
-
# Finds a class or module with +name+ in this namespace or its
|
274
|
+
# Finds a class or module with +name+ in this namespace or its descendants
|
155
275
|
|
156
276
|
def find_class_named name
|
157
277
|
return self if full_name == name
|
@@ -167,24 +287,30 @@ class RDoc::ClassModule < RDoc::Context
|
|
167
287
|
# Return the fully qualified name of this class or module
|
168
288
|
|
169
289
|
def full_name
|
170
|
-
@full_name ||= if RDoc::ClassModule ===
|
171
|
-
"#{
|
290
|
+
@full_name ||= if RDoc::ClassModule === parent then
|
291
|
+
"#{parent.full_name}::#{@name}"
|
172
292
|
else
|
173
293
|
@name
|
174
294
|
end
|
175
295
|
end
|
176
296
|
|
297
|
+
##
|
298
|
+
# TODO: filter included items by #display?
|
299
|
+
|
177
300
|
def marshal_dump # :nodoc:
|
178
|
-
# TODO must store the singleton attribute
|
179
301
|
attrs = attributes.sort.map do |attr|
|
180
|
-
|
181
|
-
|
302
|
+
next unless attr.display?
|
303
|
+
[ attr.name, attr.rw,
|
304
|
+
attr.visibility, attr.singleton, attr.file_name,
|
305
|
+
]
|
306
|
+
end.compact
|
182
307
|
|
183
308
|
method_types = methods_by_type.map do |type, visibilities|
|
184
309
|
visibilities = visibilities.map do |visibility, methods|
|
185
310
|
method_names = methods.map do |method|
|
186
|
-
method.
|
187
|
-
|
311
|
+
next unless method.display?
|
312
|
+
[method.name, method.file_name]
|
313
|
+
end.compact
|
188
314
|
|
189
315
|
[visibility, method_names.uniq]
|
190
316
|
end
|
@@ -196,89 +322,245 @@ class RDoc::ClassModule < RDoc::Context
|
|
196
322
|
@name,
|
197
323
|
full_name,
|
198
324
|
@superclass,
|
199
|
-
parse(@
|
325
|
+
parse(@comment_location),
|
200
326
|
attrs,
|
201
|
-
constants.
|
202
|
-
[const.name, parse(const.comment)]
|
203
|
-
end,
|
327
|
+
constants.select { |constant| constant.display? },
|
204
328
|
includes.map do |incl|
|
205
|
-
|
206
|
-
|
329
|
+
next unless incl.display?
|
330
|
+
[incl.name, parse(incl.comment), incl.file_name]
|
331
|
+
end.compact,
|
207
332
|
method_types,
|
333
|
+
extends.map do |ext|
|
334
|
+
next unless ext.display?
|
335
|
+
[ext.name, parse(ext.comment), ext.file_name]
|
336
|
+
end.compact,
|
337
|
+
@sections.values,
|
338
|
+
@in_files.map do |tl|
|
339
|
+
tl.relative_name
|
340
|
+
end,
|
341
|
+
parent.full_name,
|
342
|
+
parent.class,
|
208
343
|
]
|
209
344
|
end
|
210
345
|
|
211
346
|
def marshal_load array # :nodoc:
|
212
|
-
|
347
|
+
initialize_visibility
|
213
348
|
initialize_methods_etc
|
214
|
-
@
|
215
|
-
@
|
216
|
-
@
|
217
|
-
@parent
|
218
|
-
@
|
349
|
+
@current_section = nil
|
350
|
+
@document_self = true
|
351
|
+
@done_documenting = false
|
352
|
+
@parent = nil
|
353
|
+
@temporary_section = nil
|
354
|
+
@visibility = nil
|
355
|
+
@classes = {}
|
356
|
+
@modules = {}
|
219
357
|
|
220
358
|
@name = array[1]
|
221
359
|
@full_name = array[2]
|
222
360
|
@superclass = array[3]
|
223
361
|
@comment = array[4]
|
224
362
|
|
225
|
-
|
226
|
-
|
363
|
+
@comment_location = if RDoc::Markup::Document === @comment.parts.first then
|
364
|
+
@comment
|
365
|
+
else
|
366
|
+
RDoc::Markup::Document.new @comment
|
367
|
+
end
|
368
|
+
|
369
|
+
array[5].each do |name, rw, visibility, singleton, file|
|
370
|
+
singleton ||= false
|
371
|
+
visibility ||= :public
|
372
|
+
|
373
|
+
attr = RDoc::Attr.new nil, name, rw, nil, singleton
|
374
|
+
|
375
|
+
add_attribute attr
|
376
|
+
attr.visibility = visibility
|
377
|
+
attr.record_location RDoc::TopLevel.new file
|
227
378
|
end
|
228
379
|
|
229
|
-
array[6].each do |
|
230
|
-
|
380
|
+
array[6].each do |constant, comment, file|
|
381
|
+
case constant
|
382
|
+
when RDoc::Constant then
|
383
|
+
add_constant constant
|
384
|
+
else
|
385
|
+
constant = add_constant RDoc::Constant.new(constant, nil, comment)
|
386
|
+
constant.record_location RDoc::TopLevel.new file
|
387
|
+
end
|
231
388
|
end
|
232
389
|
|
233
|
-
array[7].each do |name, comment|
|
234
|
-
add_include RDoc::Include.new(name, comment)
|
390
|
+
array[7].each do |name, comment, file|
|
391
|
+
incl = add_include RDoc::Include.new(name, comment)
|
392
|
+
incl.record_location RDoc::TopLevel.new file
|
235
393
|
end
|
236
394
|
|
237
395
|
array[8].each do |type, visibilities|
|
238
396
|
visibilities.each do |visibility, methods|
|
239
397
|
@visibility = visibility
|
240
398
|
|
241
|
-
methods.each do |name|
|
399
|
+
methods.each do |name, file|
|
242
400
|
method = RDoc::AnyMethod.new nil, name
|
243
401
|
method.singleton = true if type == 'class'
|
402
|
+
method.record_location RDoc::TopLevel.new file
|
244
403
|
add_method method
|
245
404
|
end
|
246
405
|
end
|
247
406
|
end
|
407
|
+
|
408
|
+
array[9].each do |name, comment, file|
|
409
|
+
ext = add_extend RDoc::Extend.new(name, comment)
|
410
|
+
ext.record_location RDoc::TopLevel.new file
|
411
|
+
end if array[9] # Support Marshal version 1
|
412
|
+
|
413
|
+
sections = (array[10] || []).map do |section|
|
414
|
+
[section.title, section]
|
415
|
+
end
|
416
|
+
|
417
|
+
@sections = Hash[*sections.flatten]
|
418
|
+
@current_section = add_section nil
|
419
|
+
|
420
|
+
@in_files = []
|
421
|
+
|
422
|
+
(array[11] || []).each do |filename|
|
423
|
+
record_location RDoc::TopLevel.new filename
|
424
|
+
end
|
425
|
+
|
426
|
+
@parent_name = array[12]
|
427
|
+
@parent_class = array[13]
|
248
428
|
end
|
249
429
|
|
250
430
|
##
|
251
|
-
# Merges +class_module+ into this ClassModule
|
431
|
+
# Merges +class_module+ into this ClassModule.
|
432
|
+
#
|
433
|
+
# The data in +class_module+ is preferred over the receiver.
|
252
434
|
|
253
435
|
def merge class_module
|
254
|
-
|
436
|
+
@parent = class_module.parent
|
437
|
+
@parent_name = class_module.parent_name
|
438
|
+
|
439
|
+
other_document = parse class_module.comment_location
|
255
440
|
|
256
|
-
if
|
257
|
-
document = parse @
|
441
|
+
if other_document then
|
442
|
+
document = parse @comment_location
|
258
443
|
|
259
|
-
|
444
|
+
document = document.merge other_document
|
260
445
|
|
261
|
-
@comment =
|
446
|
+
@comment = @comment_location = document
|
262
447
|
end
|
263
448
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
449
|
+
cm = class_module
|
450
|
+
other_files = cm.in_files
|
451
|
+
|
452
|
+
merge_collections attributes, cm.attributes, other_files do |add, attr|
|
453
|
+
if add then
|
268
454
|
add_attribute attr
|
455
|
+
else
|
456
|
+
@attributes.delete attr
|
457
|
+
@methods_hash.delete attr.pretty_name
|
269
458
|
end
|
270
459
|
end
|
271
460
|
|
272
|
-
|
273
|
-
|
461
|
+
merge_collections constants, cm.constants, other_files do |add, const|
|
462
|
+
if add then
|
463
|
+
add_constant const
|
464
|
+
else
|
465
|
+
@constants.delete const
|
466
|
+
@constants_hash.delete const.name
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
merge_collections includes, cm.includes, other_files do |add, incl|
|
471
|
+
if add then
|
472
|
+
add_include incl
|
473
|
+
else
|
474
|
+
@includes.delete incl
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
@includes.uniq! # clean up
|
479
|
+
|
480
|
+
merge_collections extends, cm.extends, other_files do |add, ext|
|
481
|
+
if add then
|
482
|
+
add_extend ext
|
483
|
+
else
|
484
|
+
@extends.delete ext
|
485
|
+
end
|
274
486
|
end
|
275
487
|
|
276
|
-
|
277
|
-
|
488
|
+
@extends.uniq! # clean up
|
489
|
+
|
490
|
+
merge_collections method_list, cm.method_list, other_files do |add, meth|
|
491
|
+
if add then
|
492
|
+
add_method meth
|
493
|
+
else
|
494
|
+
@method_list.delete meth
|
495
|
+
@methods_hash.delete meth.pretty_name
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
merge_sections cm
|
500
|
+
|
501
|
+
self
|
502
|
+
end
|
503
|
+
|
504
|
+
##
|
505
|
+
# Merges collection +mine+ with +other+ preferring other. +other_files+ is
|
506
|
+
# used to help determine which items should be deleted.
|
507
|
+
#
|
508
|
+
# Yields whether the item should be added or removed (true or false) and the
|
509
|
+
# item to be added or removed.
|
510
|
+
#
|
511
|
+
# merge_collections things, other.things, other.in_files do |add, thing|
|
512
|
+
# if add then
|
513
|
+
# # add the thing
|
514
|
+
# else
|
515
|
+
# # remove the thing
|
516
|
+
# end
|
517
|
+
# end
|
518
|
+
|
519
|
+
def merge_collections mine, other, other_files, &block # :nodoc:
|
520
|
+
my_things = mine. group_by { |thing| thing.file }
|
521
|
+
other_things = other.group_by { |thing| thing.file }
|
522
|
+
|
523
|
+
remove_things my_things, other_files, &block
|
524
|
+
add_things my_things, other_things, &block
|
525
|
+
end
|
526
|
+
|
527
|
+
##
|
528
|
+
# Merges the comments in this ClassModule with the comments in the other
|
529
|
+
# ClassModule +cm+.
|
530
|
+
|
531
|
+
def merge_sections cm # :nodoc:
|
532
|
+
my_sections = sections.group_by { |section| section.title }
|
533
|
+
other_sections = cm.sections.group_by { |section| section.title }
|
534
|
+
|
535
|
+
other_files = cm.in_files
|
536
|
+
|
537
|
+
remove_things my_sections, other_files do |_, section|
|
538
|
+
@sections.delete section.title
|
278
539
|
end
|
279
540
|
|
280
|
-
|
281
|
-
|
541
|
+
other_sections.each do |group, sections|
|
542
|
+
if my_sections.include? group
|
543
|
+
my_sections[group].each do |my_section|
|
544
|
+
other_section = cm.sections_hash[group]
|
545
|
+
|
546
|
+
my_comments = my_section.comments
|
547
|
+
other_comments = other_section.comments
|
548
|
+
|
549
|
+
other_files = other_section.in_files
|
550
|
+
|
551
|
+
merge_collections my_comments, other_comments, other_files do |add, comment|
|
552
|
+
if add then
|
553
|
+
my_section.add_comment comment
|
554
|
+
else
|
555
|
+
my_section.remove_comment comment
|
556
|
+
end
|
557
|
+
end
|
558
|
+
end
|
559
|
+
else
|
560
|
+
sections.each do |section|
|
561
|
+
add_section group, section.comments
|
562
|
+
end
|
563
|
+
end
|
282
564
|
end
|
283
565
|
end
|
284
566
|
|
@@ -299,16 +581,43 @@ class RDoc::ClassModule < RDoc::Context
|
|
299
581
|
end
|
300
582
|
|
301
583
|
##
|
302
|
-
#
|
584
|
+
# Parses +comment_location+ into an RDoc::Markup::Document composed of
|
585
|
+
# multiple RDoc::Markup::Documents with their file set.
|
586
|
+
|
587
|
+
def parse comment_location
|
588
|
+
case comment_location
|
589
|
+
when String then
|
590
|
+
super
|
591
|
+
when Array then
|
592
|
+
docs = comment_location.map do |comment, location|
|
593
|
+
doc = super comment
|
594
|
+
doc.file = location
|
595
|
+
doc
|
596
|
+
end
|
597
|
+
|
598
|
+
RDoc::Markup::Document.new(*docs)
|
599
|
+
when RDoc::Comment then
|
600
|
+
doc = super comment_location.text, comment_location.format
|
601
|
+
doc.file = comment_location.location
|
602
|
+
doc
|
603
|
+
when RDoc::Markup::Document then
|
604
|
+
return comment_location
|
605
|
+
else
|
606
|
+
raise ArgumentError, "unknown comment class #{comment_location.class}"
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
##
|
611
|
+
# Path to this class or module for use with HTML generator output.
|
303
612
|
|
304
613
|
def path
|
305
|
-
http_url
|
614
|
+
http_url @store.rdoc.generator.class_dir
|
306
615
|
end
|
307
616
|
|
308
617
|
##
|
309
618
|
# Name to use to generate the url:
|
310
619
|
# modules and classes that are aliases for another
|
311
|
-
# module or
|
620
|
+
# module or class return the name of the latter.
|
312
621
|
|
313
622
|
def name_for_path
|
314
623
|
is_alias_for ? is_alias_for.full_name : full_name
|
@@ -336,21 +645,61 @@ class RDoc::ClassModule < RDoc::Context
|
|
336
645
|
|
337
646
|
modules_hash.each_key do |name|
|
338
647
|
full_name = prefix + name
|
339
|
-
modules_hash.delete name unless
|
648
|
+
modules_hash.delete name unless @store.modules_hash[full_name]
|
340
649
|
end
|
341
650
|
|
342
651
|
classes_hash.each_key do |name|
|
343
652
|
full_name = prefix + name
|
344
|
-
classes_hash.delete name unless
|
653
|
+
classes_hash.delete name unless @store.classes_hash[full_name]
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
def remove_things my_things, other_files # :nodoc:
|
658
|
+
my_things.delete_if do |file, things|
|
659
|
+
next false unless other_files.include? file
|
660
|
+
|
661
|
+
things.each do |thing|
|
662
|
+
yield false, thing
|
663
|
+
end
|
664
|
+
|
665
|
+
true
|
345
666
|
end
|
346
667
|
end
|
347
668
|
|
669
|
+
##
|
670
|
+
# Search record used by RDoc::Generator::JsonIndex
|
671
|
+
|
672
|
+
def search_record
|
673
|
+
[
|
674
|
+
name,
|
675
|
+
full_name,
|
676
|
+
full_name,
|
677
|
+
'',
|
678
|
+
path,
|
679
|
+
'',
|
680
|
+
snippet(@comment_location),
|
681
|
+
]
|
682
|
+
end
|
683
|
+
|
684
|
+
##
|
685
|
+
# Sets the store for this class or module and its contained code objects.
|
686
|
+
|
687
|
+
def store= store
|
688
|
+
super
|
689
|
+
|
690
|
+
@attributes .each do |attr| attr.store = store end
|
691
|
+
@constants .each do |const| const.store = store end
|
692
|
+
@includes .each do |incl| incl.store = store end
|
693
|
+
@extends .each do |ext| ext.store = store end
|
694
|
+
@method_list.each do |meth| meth.store = store end
|
695
|
+
end
|
696
|
+
|
348
697
|
##
|
349
698
|
# Get the superclass of this class. Attempts to retrieve the superclass
|
350
699
|
# object, returns the name if it is not known.
|
351
700
|
|
352
701
|
def superclass
|
353
|
-
|
702
|
+
@store.find_class_named(@superclass) || @superclass
|
354
703
|
end
|
355
704
|
|
356
705
|
##
|
@@ -381,7 +730,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
381
730
|
# aliases through a constant.
|
382
731
|
#
|
383
732
|
# The aliased module/class is replaced in the children and in
|
384
|
-
# RDoc::
|
733
|
+
# RDoc::Store#modules_hash or RDoc::Store#classes_hash
|
385
734
|
# by a copy that has <tt>RDoc::ClassModule#is_alias_for</tt> set to
|
386
735
|
# the aliased module/class, and this copy is added to <tt>#aliases</tt>
|
387
736
|
# of the aliased module/class.
|
@@ -396,16 +745,21 @@ class RDoc::ClassModule < RDoc::Context
|
|
396
745
|
next unless cm = const.is_alias_for
|
397
746
|
cm_alias = cm.dup
|
398
747
|
cm_alias.name = const.name
|
399
|
-
|
400
|
-
|
748
|
+
|
749
|
+
# Don't move top-level aliases under Object, they look ugly there
|
750
|
+
unless RDoc::TopLevel === cm_alias.parent then
|
751
|
+
cm_alias.parent = self
|
752
|
+
cm_alias.full_name = nil # force update for new parent
|
753
|
+
end
|
754
|
+
|
401
755
|
cm_alias.aliases.clear
|
402
756
|
cm_alias.is_alias_for = cm
|
403
757
|
|
404
758
|
if cm.module? then
|
405
|
-
|
759
|
+
@store.modules_hash[cm_alias.full_name] = cm_alias
|
406
760
|
modules_hash[const.name] = cm_alias
|
407
761
|
else
|
408
|
-
|
762
|
+
@store.classes_hash[cm_alias.full_name] = cm_alias
|
409
763
|
classes_hash[const.name] = cm_alias
|
410
764
|
end
|
411
765
|
|
@@ -422,8 +776,26 @@ class RDoc::ClassModule < RDoc::Context
|
|
422
776
|
def update_includes
|
423
777
|
includes.reject! do |include|
|
424
778
|
mod = include.module
|
425
|
-
!(String === mod) &&
|
779
|
+
!(String === mod) && @store.modules_hash[mod.full_name].nil?
|
780
|
+
end
|
781
|
+
|
782
|
+
includes.uniq!
|
783
|
+
end
|
784
|
+
|
785
|
+
##
|
786
|
+
# Deletes from #extends those whose module has been removed from the
|
787
|
+
# documentation.
|
788
|
+
#--
|
789
|
+
# FIXME: like update_includes, extends are not reliably removed
|
790
|
+
|
791
|
+
def update_extends
|
792
|
+
extends.reject! do |ext|
|
793
|
+
mod = ext.module
|
794
|
+
|
795
|
+
!(String === mod) && @store.modules_hash[mod.full_name].nil?
|
426
796
|
end
|
797
|
+
|
798
|
+
extends.uniq!
|
427
799
|
end
|
428
800
|
|
429
801
|
end
|