rdoc 6.3.4.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +195 -0
- data/History.rdoc +65 -63
- data/LEGAL.rdoc +7 -1
- data/LICENSE.rdoc +6 -0
- data/README.md +236 -0
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/doc/markup_reference/markdown.md +659 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -18
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +50 -24
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +16 -14
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +225 -58
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +44 -10
- data/lib/rdoc/code_object/context/section.rb +182 -0
- data/lib/rdoc/{context.rb → code_object/context.rb} +78 -106
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -1
- data/lib/rdoc/{include.rb → code_object/include.rb} +0 -1
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +46 -48
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +6 -4
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +2 -3
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +1 -2
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +5 -1
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +60 -63
- data/lib/rdoc/code_object.rb +11 -39
- data/lib/rdoc/code_objects.rb +1 -2
- data/lib/rdoc/comment.rb +202 -99
- data/lib/rdoc/cross_reference.rb +75 -62
- data/lib/rdoc/encoding.rb +8 -24
- data/lib/rdoc/erb_partial.rb +1 -2
- data/lib/rdoc/erbio.rb +3 -8
- data/lib/rdoc/generator/aliki.rb +200 -0
- data/lib/rdoc/generator/darkfish.rb +156 -122
- data/lib/rdoc/generator/json_index.rb +8 -24
- data/lib/rdoc/generator/markup.rb +70 -34
- data/lib/rdoc/generator/pot/message_extractor.rb +7 -7
- data/lib/rdoc/generator/pot/po.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +8 -8
- data/lib/rdoc/generator/pot.rb +1 -5
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
- data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
- data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -14
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +25 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +28 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +138 -90
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +420 -358
- 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/index.rhtml +14 -12
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +59 -3
- data/lib/rdoc/generator/template/darkfish/js/search.js +15 -5
- data/lib/rdoc/generator/template/darkfish/page.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +12 -9
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +24 -21
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +35 -21
- data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
- data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
- data/lib/rdoc/generator.rb +6 -5
- data/lib/rdoc/i18n/text.rb +3 -3
- data/lib/rdoc/i18n.rb +1 -1
- data/lib/rdoc/known_classes.rb +5 -4
- data/lib/rdoc/markdown/entities.rb +0 -1
- data/lib/rdoc/markdown/literals.kpeg +0 -2
- data/lib/rdoc/markdown/literals.rb +0 -1
- data/lib/rdoc/markdown.kpeg +140 -62
- data/lib/rdoc/markdown.rb +1015 -873
- data/lib/rdoc/markup/blank_line.rb +25 -24
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +10 -11
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +134 -115
- data/lib/rdoc/markup/hard_break.rb +30 -28
- data/lib/rdoc/markup/heading.rb +163 -72
- data/lib/rdoc/markup/include.rb +3 -4
- data/lib/rdoc/markup/indented_paragraph.rb +4 -5
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/list.rb +6 -7
- data/lib/rdoc/markup/list_item.rb +6 -7
- data/lib/rdoc/markup/paragraph.rb +2 -3
- data/lib/rdoc/markup/parser.rb +29 -19
- data/lib/rdoc/markup/pre_process.rb +39 -18
- data/lib/rdoc/markup/raw.rb +52 -56
- data/lib/rdoc/markup/rule.rb +2 -3
- data/lib/rdoc/markup/table.rb +49 -32
- data/lib/rdoc/markup/to_ansi.rb +58 -8
- data/lib/rdoc/markup/to_bs.rb +47 -38
- data/lib/rdoc/markup/to_html.rb +343 -105
- data/lib/rdoc/markup/to_html_crossref.rb +143 -58
- data/lib/rdoc/markup/to_html_snippet.rb +78 -76
- data/lib/rdoc/markup/to_joined_paragraph.rb +3 -9
- data/lib/rdoc/markup/to_label.rb +34 -25
- data/lib/rdoc/markup/to_markdown.rb +74 -51
- data/lib/rdoc/markup/to_rdoc.rb +141 -82
- data/lib/rdoc/markup/to_table_of_contents.rb +4 -5
- data/lib/rdoc/markup/to_test.rb +10 -3
- data/lib/rdoc/markup/to_tt_only.rb +17 -31
- data/lib/rdoc/markup/verbatim.rb +5 -6
- data/lib/rdoc/markup.rb +59 -707
- data/lib/rdoc/options.rb +228 -101
- data/lib/rdoc/parser/c.rb +186 -184
- data/lib/rdoc/parser/changelog.rb +57 -13
- data/lib/rdoc/parser/markdown.rb +0 -2
- data/lib/rdoc/parser/rbs.rb +275 -0
- data/lib/rdoc/parser/rd.rb +0 -1
- data/lib/rdoc/parser/ruby.rb +963 -2024
- data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/lib/rdoc/parser/simple.rb +6 -23
- data/lib/rdoc/parser/text.rb +0 -1
- data/lib/rdoc/parser.rb +35 -14
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/block_parser.rb +659 -11
- data/lib/rdoc/rd/block_parser.ry +13 -9
- data/lib/rdoc/rd/inline.rb +4 -5
- data/lib/rdoc/rd/inline_parser.rb +646 -2
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +234 -90
- data/lib/rdoc/ri/driver.rb +172 -172
- data/lib/rdoc/ri/paths.rb +3 -3
- data/lib/rdoc/{servlet.rb → ri/servlet.rb} +28 -27
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ri/task.rb +3 -3
- data/lib/rdoc/ri.rb +5 -5
- data/lib/rdoc/rubygems_hook.rb +106 -25
- data/lib/rdoc/server.rb +460 -0
- data/lib/rdoc/stats/normal.rb +1 -1
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +3 -5
- data/lib/rdoc/stats.rb +158 -136
- data/lib/rdoc/store.rb +267 -48
- data/lib/rdoc/task.rb +54 -28
- data/lib/rdoc/text.rb +60 -120
- data/lib/rdoc/token_stream.rb +30 -45
- data/lib/rdoc/tom_doc.rb +9 -15
- data/lib/rdoc/version.rb +3 -1
- data/lib/rdoc.rb +90 -52
- data/lib/rubygems_plugin.rb +14 -0
- data/man/ri.1 +2 -0
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +25 -200
- metadata +120 -53
- data/CONTRIBUTING.rdoc +0 -220
- data/ExampleMarkdown.md +0 -37
- data/ExampleRDoc.rdoc +0 -208
- data/Gemfile +0 -12
- data/README.rdoc +0 -129
- data/RI.rdoc +0 -57
- data/Rakefile +0 -101
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/rdoc/anon_class.rb +0 -11
- data/lib/rdoc/context/section.rb +0 -232
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
- data/lib/rdoc/generator/template/json_index/.document +0 -1
- data/lib/rdoc/ghost_method.rb +0 -7
- data/lib/rdoc/markup/attr_changer.rb +0 -23
- data/lib/rdoc/markup/attr_span.rb +0 -36
- data/lib/rdoc/markup/attribute_manager.rb +0 -409
- data/lib/rdoc/markup/attributes.rb +0 -71
- data/lib/rdoc/markup/regexp_handling.rb +0 -41
- data/lib/rdoc/meta_method.rb +0 -7
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -590
- data/lib/rdoc/parser/ruby_tools.rb +0 -167
|
@@ -21,11 +21,6 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
21
21
|
|
|
22
22
|
attr_accessor :singleton
|
|
23
23
|
|
|
24
|
-
##
|
|
25
|
-
# Source file token stream
|
|
26
|
-
|
|
27
|
-
attr_reader :text
|
|
28
|
-
|
|
29
24
|
##
|
|
30
25
|
# Array of other names for this method/attribute
|
|
31
26
|
|
|
@@ -59,46 +54,45 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
59
54
|
attr_accessor :call_seq
|
|
60
55
|
|
|
61
56
|
##
|
|
62
|
-
#
|
|
57
|
+
# RBS type signature lines from inline annotations or loaded .rbs files.
|
|
58
|
+
# Each entry is one overload or type expression.
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
attr_accessor :type_signature_lines
|
|
65
61
|
|
|
66
62
|
##
|
|
67
|
-
#
|
|
68
|
-
|
|
69
|
-
attr_reader :param_seq
|
|
63
|
+
# The call_seq or the param_seq with method name, if there is no call_seq.
|
|
70
64
|
|
|
65
|
+
attr_reader :arglists
|
|
71
66
|
|
|
72
67
|
##
|
|
73
|
-
# Creates a new MethodAttr
|
|
68
|
+
# Creates a new MethodAttr with method or attribute
|
|
74
69
|
# name +name+.
|
|
75
70
|
#
|
|
76
71
|
# Usually this is called by super from a subclass.
|
|
77
72
|
|
|
78
|
-
def initialize
|
|
73
|
+
def initialize(name, singleton: false)
|
|
79
74
|
super()
|
|
80
75
|
|
|
81
|
-
@text = text
|
|
82
76
|
@name = name
|
|
83
77
|
|
|
84
78
|
@aliases = []
|
|
85
79
|
@is_alias_for = nil
|
|
86
80
|
@parent_name = nil
|
|
87
|
-
@singleton =
|
|
81
|
+
@singleton = singleton
|
|
88
82
|
@visibility = :public
|
|
89
83
|
@see = false
|
|
90
84
|
|
|
91
85
|
@arglists = nil
|
|
92
86
|
@block_params = nil
|
|
93
87
|
@call_seq = nil
|
|
94
|
-
@param_seq = nil
|
|
95
88
|
@params = nil
|
|
89
|
+
@type_signature_lines = nil
|
|
96
90
|
end
|
|
97
91
|
|
|
98
92
|
##
|
|
99
93
|
# Resets cached data for the object so it can be rebuilt by accessor methods
|
|
100
94
|
|
|
101
|
-
def initialize_copy
|
|
95
|
+
def initialize_copy(other) # :nodoc:
|
|
102
96
|
@full_name = nil
|
|
103
97
|
end
|
|
104
98
|
|
|
@@ -114,11 +108,11 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
114
108
|
return unless other.respond_to?(:singleton) &&
|
|
115
109
|
other.respond_to?(:name)
|
|
116
110
|
|
|
117
|
-
[
|
|
118
|
-
[other.singleton ? 0 : 1, other.name]
|
|
111
|
+
[@singleton ? 0 : 1, name_ord_range, name] <=>
|
|
112
|
+
[other.singleton ? 0 : 1, other.name_ord_range, other.name]
|
|
119
113
|
end
|
|
120
114
|
|
|
121
|
-
def ==
|
|
115
|
+
def ==(other) # :nodoc:
|
|
122
116
|
equal?(other) or self.class == other.class and full_name == other.full_name
|
|
123
117
|
end
|
|
124
118
|
|
|
@@ -157,7 +151,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
157
151
|
##
|
|
158
152
|
# Sets the store for this class or module and its contained code objects.
|
|
159
153
|
|
|
160
|
-
def store=
|
|
154
|
+
def store=(store)
|
|
161
155
|
super
|
|
162
156
|
|
|
163
157
|
@file = @store.add_file @file.full_name if @file
|
|
@@ -175,7 +169,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
175
169
|
return find_method_or_attribute name[0..-2]
|
|
176
170
|
end
|
|
177
171
|
|
|
178
|
-
def find_method_or_attribute
|
|
172
|
+
def find_method_or_attribute(name) # :nodoc:
|
|
179
173
|
return nil unless parent.respond_to? :ancestors
|
|
180
174
|
|
|
181
175
|
searched = parent.ancestors
|
|
@@ -268,8 +262,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
268
262
|
when 'const_get' then 'const'
|
|
269
263
|
when 'new' then
|
|
270
264
|
$1.split('::').last. # ClassName => class_name
|
|
271
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
272
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
265
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
|
266
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
|
273
267
|
downcase
|
|
274
268
|
else
|
|
275
269
|
$2
|
|
@@ -289,9 +283,10 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
289
283
|
# HTML id-friendly method/attribute name
|
|
290
284
|
|
|
291
285
|
def html_name
|
|
292
|
-
require 'cgi'
|
|
286
|
+
require 'cgi/escape'
|
|
287
|
+
require 'cgi/util' unless defined?(CGI::EscapeExt)
|
|
293
288
|
|
|
294
|
-
CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
|
|
289
|
+
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
|
295
290
|
end
|
|
296
291
|
|
|
297
292
|
##
|
|
@@ -320,19 +315,6 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
320
315
|
@singleton ? '::' : '#'
|
|
321
316
|
end
|
|
322
317
|
|
|
323
|
-
##
|
|
324
|
-
# Name for output to HTML. For class methods the full name with a "." is
|
|
325
|
-
# used like +SomeClass.method_name+. For instance methods the class name is
|
|
326
|
-
# used if +context+ does not match the parent.
|
|
327
|
-
#
|
|
328
|
-
# This is to help prevent people from using :: to call class methods.
|
|
329
|
-
|
|
330
|
-
def output_name context
|
|
331
|
-
return "#{name_prefix}#{@name}" if context == parent
|
|
332
|
-
|
|
333
|
-
"#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
|
|
334
|
-
end
|
|
335
|
-
|
|
336
318
|
##
|
|
337
319
|
# Method/attribute name with class/instance indicator
|
|
338
320
|
|
|
@@ -361,7 +343,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
361
343
|
@parent_name || super
|
|
362
344
|
end
|
|
363
345
|
|
|
364
|
-
def pretty_print
|
|
346
|
+
def pretty_print(q) # :nodoc:
|
|
365
347
|
alias_for =
|
|
366
348
|
if @is_alias_for.respond_to? :name then
|
|
367
349
|
"alias for #{@is_alias_for.name}"
|
|
@@ -375,13 +357,6 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
375
357
|
q.text alias_for
|
|
376
358
|
end
|
|
377
359
|
|
|
378
|
-
if text then
|
|
379
|
-
q.breakable
|
|
380
|
-
q.text "text:"
|
|
381
|
-
q.breakable
|
|
382
|
-
q.pp @text
|
|
383
|
-
end
|
|
384
|
-
|
|
385
360
|
unless comment.empty? then
|
|
386
361
|
q.breakable
|
|
387
362
|
q.text "comment:"
|
|
@@ -394,6 +369,9 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
394
369
|
##
|
|
395
370
|
# Used by RDoc::Generator::JsonIndex to create a record for the search
|
|
396
371
|
# engine.
|
|
372
|
+
#
|
|
373
|
+
# TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
|
|
374
|
+
# Use #search_snippet instead for getting documentation snippets.
|
|
397
375
|
|
|
398
376
|
def search_record
|
|
399
377
|
[
|
|
@@ -403,10 +381,19 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
403
381
|
@parent.full_name,
|
|
404
382
|
path,
|
|
405
383
|
params,
|
|
406
|
-
|
|
384
|
+
search_snippet,
|
|
407
385
|
]
|
|
408
386
|
end
|
|
409
387
|
|
|
388
|
+
##
|
|
389
|
+
# Returns an HTML snippet of the comment for search results.
|
|
390
|
+
|
|
391
|
+
def search_snippet
|
|
392
|
+
return '' if @comment.empty?
|
|
393
|
+
|
|
394
|
+
snippet(@comment)
|
|
395
|
+
end
|
|
396
|
+
|
|
410
397
|
def to_s # :nodoc:
|
|
411
398
|
if @is_alias_for
|
|
412
399
|
"#{self.class.name}: #{full_name} -> #{is_alias_for}"
|
|
@@ -415,5 +402,16 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
415
402
|
end
|
|
416
403
|
end
|
|
417
404
|
|
|
405
|
+
def name_ord_range # :nodoc:
|
|
406
|
+
case name.ord
|
|
407
|
+
when 0..64 # anything below "A"
|
|
408
|
+
1
|
|
409
|
+
when 91..96 # the symbols between "Z" and "a"
|
|
410
|
+
2
|
|
411
|
+
when 123..126 # 7-bit symbols above "z": "{", "|", "}", "~"
|
|
412
|
+
3
|
|
413
|
+
else # everythig else can be sorted as normal
|
|
414
|
+
4
|
|
415
|
+
end
|
|
416
|
+
end
|
|
418
417
|
end
|
|
419
|
-
|
|
@@ -23,13 +23,13 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
|
23
23
|
##
|
|
24
24
|
# Mixins are sorted by name
|
|
25
25
|
|
|
26
|
-
def <=>
|
|
26
|
+
def <=>(other)
|
|
27
27
|
return unless self.class === other
|
|
28
28
|
|
|
29
29
|
name <=> other.name
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def ==
|
|
32
|
+
def ==(other) # :nodoc:
|
|
33
33
|
self.class === other and @name == other.name
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -71,6 +71,9 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
|
71
71
|
# lookup behavior.
|
|
72
72
|
#
|
|
73
73
|
# As of the beginning of October, 2011, no gem includes nonexistent modules.
|
|
74
|
+
#
|
|
75
|
+
# The Ruby parser passes an already-resolved full-path +name+, so most of this
|
|
76
|
+
# logic only runs for the C parser, which passes the unresolved local name.
|
|
74
77
|
|
|
75
78
|
def module
|
|
76
79
|
return @module if @module
|
|
@@ -107,7 +110,7 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
|
107
110
|
##
|
|
108
111
|
# Sets the store for this class or module and its contained code objects.
|
|
109
112
|
|
|
110
|
-
def store=
|
|
113
|
+
def store=(store)
|
|
111
114
|
super
|
|
112
115
|
|
|
113
116
|
@file = @store.add_file @file.full_name if @file
|
|
@@ -118,4 +121,3 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
|
118
121
|
end
|
|
119
122
|
|
|
120
123
|
end
|
|
121
|
-
|
|
@@ -53,10 +53,10 @@ class RDoc::NormalClass < RDoc::ClassModule
|
|
|
53
53
|
display
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def pretty_print
|
|
56
|
+
def pretty_print(q) # :nodoc:
|
|
57
57
|
superclass = @superclass ? " < #{@superclass}" : nil
|
|
58
58
|
|
|
59
|
-
q.group 2, "[class #{full_name}#{superclass}
|
|
59
|
+
q.group 2, "[class #{full_name}#{superclass}", "]" do
|
|
60
60
|
q.breakable
|
|
61
61
|
q.text "includes:"
|
|
62
62
|
q.breakable
|
|
@@ -90,4 +90,3 @@ class RDoc::NormalClass < RDoc::ClassModule
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
end
|
|
93
|
-
|
|
@@ -29,8 +29,8 @@ class RDoc::NormalModule < RDoc::ClassModule
|
|
|
29
29
|
true
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def pretty_print
|
|
33
|
-
q.group 2, "[module #{full_name}:
|
|
32
|
+
def pretty_print(q) # :nodoc:
|
|
33
|
+
q.group 2, "[module #{full_name}:", "]" do
|
|
34
34
|
q.breakable
|
|
35
35
|
q.text "includes:"
|
|
36
36
|
q.breakable
|
|
@@ -71,4 +71,3 @@ class RDoc::NormalModule < RDoc::ClassModule
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
end
|
|
74
|
-
|
|
@@ -6,11 +6,6 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
6
6
|
|
|
7
7
|
MARSHAL_VERSION = 0 # :nodoc:
|
|
8
8
|
|
|
9
|
-
##
|
|
10
|
-
# This TopLevel's File::Stat struct
|
|
11
|
-
|
|
12
|
-
attr_accessor :file_stat
|
|
13
|
-
|
|
14
9
|
##
|
|
15
10
|
# Relative name of this file
|
|
16
11
|
|
|
@@ -21,6 +16,16 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
21
16
|
|
|
22
17
|
attr_accessor :absolute_name
|
|
23
18
|
|
|
19
|
+
##
|
|
20
|
+
# Base name of this file
|
|
21
|
+
|
|
22
|
+
attr_reader :base_name
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Base name of this file without the extension
|
|
26
|
+
|
|
27
|
+
attr_reader :page_name
|
|
28
|
+
|
|
24
29
|
##
|
|
25
30
|
# All the classes or modules that were declared in
|
|
26
31
|
# this file. These are assigned to either +#classes_hash+
|
|
@@ -28,8 +33,6 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
28
33
|
|
|
29
34
|
attr_reader :classes_or_modules
|
|
30
35
|
|
|
31
|
-
attr_accessor :diagram # :nodoc:
|
|
32
|
-
|
|
33
36
|
##
|
|
34
37
|
# The parser class that processed this file
|
|
35
38
|
|
|
@@ -40,28 +43,37 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
40
43
|
# is being generated outside the source dir +relative_name+ is relative to
|
|
41
44
|
# the source directory.
|
|
42
45
|
|
|
43
|
-
def initialize
|
|
46
|
+
def initialize(absolute_name, relative_name = absolute_name)
|
|
44
47
|
super()
|
|
45
48
|
@name = nil
|
|
46
49
|
@absolute_name = absolute_name
|
|
47
50
|
@relative_name = relative_name
|
|
48
|
-
@file_stat = File.stat(absolute_name) rescue nil # HACK for testing
|
|
49
|
-
@diagram = nil
|
|
50
51
|
@parser = nil
|
|
51
52
|
|
|
53
|
+
if relative_name
|
|
54
|
+
@base_name = File.basename(relative_name)
|
|
55
|
+
@page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '')
|
|
56
|
+
else
|
|
57
|
+
@base_name = nil
|
|
58
|
+
@page_name = nil
|
|
59
|
+
end
|
|
60
|
+
|
|
52
61
|
@classes_or_modules = []
|
|
53
62
|
end
|
|
54
63
|
|
|
64
|
+
##
|
|
65
|
+
# Sets the parser for this toplevel context, also the store.
|
|
66
|
+
|
|
55
67
|
def parser=(val)
|
|
56
68
|
@parser = val
|
|
57
|
-
@store
|
|
69
|
+
@store&.cache_text_file(relative_name)
|
|
58
70
|
@parser
|
|
59
71
|
end
|
|
60
72
|
|
|
61
73
|
##
|
|
62
74
|
# An RDoc::TopLevel is equal to another with the same relative_name
|
|
63
75
|
|
|
64
|
-
def ==
|
|
76
|
+
def ==(other)
|
|
65
77
|
self.class === other and @relative_name == other.relative_name
|
|
66
78
|
end
|
|
67
79
|
|
|
@@ -79,7 +91,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
79
91
|
##
|
|
80
92
|
# Adds +constant+ to +Object+ instead of +self+.
|
|
81
93
|
|
|
82
|
-
def add_constant
|
|
94
|
+
def add_constant(constant)
|
|
83
95
|
object_class.record_location self
|
|
84
96
|
return constant unless @document_self
|
|
85
97
|
object_class.add_constant constant
|
|
@@ -107,34 +119,19 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
107
119
|
# Adds class or module +mod+. Used in the building phase
|
|
108
120
|
# by the Ruby parser.
|
|
109
121
|
|
|
110
|
-
def add_to_classes_or_modules
|
|
122
|
+
def add_to_classes_or_modules(mod)
|
|
111
123
|
@classes_or_modules << mod
|
|
112
124
|
end
|
|
113
125
|
|
|
114
|
-
##
|
|
115
|
-
# Base name of this file
|
|
116
|
-
|
|
117
|
-
def base_name
|
|
118
|
-
File.basename @relative_name
|
|
119
|
-
end
|
|
120
|
-
|
|
121
126
|
alias name base_name
|
|
122
127
|
|
|
123
|
-
##
|
|
124
|
-
# Only a TopLevel that contains text file) will be displayed. See also
|
|
125
|
-
# RDoc::CodeObject#display?
|
|
126
|
-
|
|
127
|
-
def display?
|
|
128
|
-
text? and super
|
|
129
|
-
end
|
|
130
|
-
|
|
131
128
|
##
|
|
132
129
|
# See RDoc::TopLevel::find_class_or_module
|
|
133
130
|
#--
|
|
134
131
|
# TODO Why do we search through all classes/modules found, not just the
|
|
135
132
|
# ones of this instance?
|
|
136
133
|
|
|
137
|
-
def find_class_or_module
|
|
134
|
+
def find_class_or_module(name)
|
|
138
135
|
@store.find_class_or_module name
|
|
139
136
|
end
|
|
140
137
|
|
|
@@ -152,6 +149,8 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
152
149
|
find_class_or_module(name)
|
|
153
150
|
end
|
|
154
151
|
|
|
152
|
+
alias get_module_named find_module_named
|
|
153
|
+
|
|
155
154
|
##
|
|
156
155
|
# Returns the relative name of this file
|
|
157
156
|
|
|
@@ -170,28 +169,19 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
170
169
|
##
|
|
171
170
|
# URL for this with a +prefix+
|
|
172
171
|
|
|
173
|
-
def http_url
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
File.join(*path.compact) + '.html'
|
|
172
|
+
def http_url
|
|
173
|
+
@relative_name.tr('.', '_') + '.html'
|
|
177
174
|
end
|
|
178
175
|
|
|
179
176
|
def inspect # :nodoc:
|
|
180
177
|
"#<%s:0x%x %p modules: %p classes: %p>" % [
|
|
181
178
|
self.class, object_id,
|
|
182
179
|
base_name,
|
|
183
|
-
@modules.map { |n,m| m },
|
|
184
|
-
@classes.map { |n,c| c }
|
|
180
|
+
@modules.map { |n, m| m },
|
|
181
|
+
@classes.map { |n, c| c }
|
|
185
182
|
]
|
|
186
183
|
end
|
|
187
184
|
|
|
188
|
-
##
|
|
189
|
-
# Time this file was last modified, if known
|
|
190
|
-
|
|
191
|
-
def last_modified
|
|
192
|
-
@file_stat ? file_stat.mtime : nil
|
|
193
|
-
end
|
|
194
|
-
|
|
195
185
|
##
|
|
196
186
|
# Dumps this TopLevel for use by ri. See also #marshal_load
|
|
197
187
|
|
|
@@ -207,13 +197,11 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
207
197
|
##
|
|
208
198
|
# Loads this TopLevel from +array+.
|
|
209
199
|
|
|
210
|
-
def marshal_load
|
|
200
|
+
def marshal_load(array) # :nodoc:
|
|
211
201
|
initialize array[1]
|
|
212
202
|
|
|
213
203
|
@parser = array[2]
|
|
214
|
-
@comment = array[3]
|
|
215
|
-
|
|
216
|
-
@file_stat = nil
|
|
204
|
+
@comment = RDoc::Comment.from_document array[3]
|
|
217
205
|
end
|
|
218
206
|
|
|
219
207
|
##
|
|
@@ -229,36 +217,37 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
229
217
|
end
|
|
230
218
|
end
|
|
231
219
|
|
|
232
|
-
##
|
|
233
|
-
# Base name of this file without the extension
|
|
234
|
-
|
|
235
|
-
def page_name
|
|
236
|
-
basename = File.basename @relative_name
|
|
237
|
-
basename =~ /\.(rb|rdoc|txt|md)$/i
|
|
238
|
-
|
|
239
|
-
$` || basename
|
|
240
|
-
end
|
|
241
|
-
|
|
242
220
|
##
|
|
243
221
|
# Path to this file for use with HTML generator output.
|
|
244
222
|
|
|
245
223
|
def path
|
|
246
|
-
|
|
224
|
+
base = if options.main_page == full_name
|
|
225
|
+
'index.html'
|
|
226
|
+
else
|
|
227
|
+
http_url
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
prefix = options.file_path_prefix
|
|
231
|
+
return base unless prefix
|
|
232
|
+
File.join(prefix, base)
|
|
247
233
|
end
|
|
248
234
|
|
|
249
|
-
def pretty_print
|
|
235
|
+
def pretty_print(q) # :nodoc:
|
|
250
236
|
q.group 2, "[#{self.class}: ", "]" do
|
|
251
237
|
q.text "base name: #{base_name.inspect}"
|
|
252
238
|
q.breakable
|
|
253
239
|
|
|
254
|
-
items = @modules.map { |n,m| m }
|
|
255
|
-
items.concat @modules.map { |n,c| c }
|
|
240
|
+
items = @modules.map { |n, m| m }
|
|
241
|
+
items.concat @modules.map { |n, c| c }
|
|
256
242
|
q.seplist items do |mod| q.pp mod end
|
|
257
243
|
end
|
|
258
244
|
end
|
|
259
245
|
|
|
260
246
|
##
|
|
261
247
|
# Search record used by RDoc::Generator::JsonIndex
|
|
248
|
+
#
|
|
249
|
+
# TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
|
|
250
|
+
# Use #search_snippet instead for getting documentation snippets.
|
|
262
251
|
|
|
263
252
|
def search_record
|
|
264
253
|
return unless @parser < RDoc::Parser::Text
|
|
@@ -270,10 +259,19 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
270
259
|
'',
|
|
271
260
|
path,
|
|
272
261
|
'',
|
|
273
|
-
|
|
262
|
+
search_snippet,
|
|
274
263
|
]
|
|
275
264
|
end
|
|
276
265
|
|
|
266
|
+
##
|
|
267
|
+
# Returns an HTML snippet of the comment for search results.
|
|
268
|
+
|
|
269
|
+
def search_snippet
|
|
270
|
+
return '' if @comment.empty?
|
|
271
|
+
|
|
272
|
+
snippet(@comment)
|
|
273
|
+
end
|
|
274
|
+
|
|
277
275
|
##
|
|
278
276
|
# Is this TopLevel from a text file instead of a source code file?
|
|
279
277
|
|
|
@@ -286,4 +284,3 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
286
284
|
end
|
|
287
285
|
|
|
288
286
|
end
|
|
289
|
-
|
data/lib/rdoc/code_object.rb
CHANGED
|
@@ -10,20 +10,18 @@
|
|
|
10
10
|
# * RDoc::Context
|
|
11
11
|
# * RDoc::TopLevel
|
|
12
12
|
# * RDoc::ClassModule
|
|
13
|
-
# * RDoc::AnonClass (never used so far)
|
|
14
13
|
# * RDoc::NormalClass
|
|
15
14
|
# * RDoc::NormalModule
|
|
16
15
|
# * RDoc::SingleClass
|
|
17
16
|
# * RDoc::MethodAttr
|
|
18
17
|
# * RDoc::Attr
|
|
19
18
|
# * RDoc::AnyMethod
|
|
20
|
-
# * RDoc::GhostMethod
|
|
21
|
-
# * RDoc::MetaMethod
|
|
22
19
|
# * RDoc::Alias
|
|
23
20
|
# * RDoc::Constant
|
|
21
|
+
# * RDoc::Require
|
|
24
22
|
# * RDoc::Mixin
|
|
25
|
-
# * RDoc::Require
|
|
26
23
|
# * RDoc::Include
|
|
24
|
+
# * RDoc::Extend
|
|
27
25
|
|
|
28
26
|
class RDoc::CodeObject
|
|
29
27
|
|
|
@@ -90,11 +88,9 @@ class RDoc::CodeObject
|
|
|
90
88
|
attr_reader :store
|
|
91
89
|
|
|
92
90
|
##
|
|
93
|
-
#
|
|
94
|
-
# worked on by viewers. By implementing the Viewable protocol, viewers can
|
|
95
|
-
# associated themselves with these objects.
|
|
91
|
+
# When mixed-in to a class, this points to the Context in which it was originally defined.
|
|
96
92
|
|
|
97
|
-
attr_accessor :
|
|
93
|
+
attr_accessor :mixin_from
|
|
98
94
|
|
|
99
95
|
##
|
|
100
96
|
# Creates a new CodeObject that will document itself and its children
|
|
@@ -111,6 +107,7 @@ class RDoc::CodeObject
|
|
|
111
107
|
@full_name = nil
|
|
112
108
|
@store = nil
|
|
113
109
|
@track_visibility = true
|
|
110
|
+
@mixin_from = nil
|
|
114
111
|
|
|
115
112
|
initialize_visibility
|
|
116
113
|
end
|
|
@@ -135,7 +132,6 @@ class RDoc::CodeObject
|
|
|
135
132
|
def comment=(comment)
|
|
136
133
|
@comment = case comment
|
|
137
134
|
when NilClass then ''
|
|
138
|
-
when RDoc::Markup::Document then comment
|
|
139
135
|
when RDoc::Comment then comment.normalize
|
|
140
136
|
else
|
|
141
137
|
if comment and not comment.empty? then
|
|
@@ -211,20 +207,6 @@ class RDoc::CodeObject
|
|
|
211
207
|
@document_children = @document_self
|
|
212
208
|
end
|
|
213
209
|
|
|
214
|
-
##
|
|
215
|
-
# Yields each parent of this CodeObject. See also
|
|
216
|
-
# RDoc::ClassModule#each_ancestor
|
|
217
|
-
|
|
218
|
-
def each_parent
|
|
219
|
-
code_object = self
|
|
220
|
-
|
|
221
|
-
while code_object = code_object.parent do
|
|
222
|
-
yield code_object
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
self
|
|
226
|
-
end
|
|
227
|
-
|
|
228
210
|
##
|
|
229
211
|
# File name where this CodeObject was found.
|
|
230
212
|
#
|
|
@@ -251,7 +233,7 @@ class RDoc::CodeObject
|
|
|
251
233
|
#
|
|
252
234
|
# Set to +nil+ to clear RDoc's cached value
|
|
253
235
|
|
|
254
|
-
def full_name=
|
|
236
|
+
def full_name=(full_name)
|
|
255
237
|
@full_name = full_name
|
|
256
238
|
end
|
|
257
239
|
|
|
@@ -292,14 +274,11 @@ class RDoc::CodeObject
|
|
|
292
274
|
# The options instance from the store this CodeObject is attached to, or a
|
|
293
275
|
# default options instance if the CodeObject is not attached.
|
|
294
276
|
#
|
|
295
|
-
#
|
|
277
|
+
# Used by: store= (visibility check), ClassModule#path, TopLevel#path,
|
|
278
|
+
# ClassModule#embed_mixins
|
|
296
279
|
|
|
297
280
|
def options
|
|
298
|
-
|
|
299
|
-
@store.rdoc.options
|
|
300
|
-
else
|
|
301
|
-
RDoc::Options.new
|
|
302
|
-
end
|
|
281
|
+
@store&.options || RDoc::Options.new
|
|
303
282
|
end
|
|
304
283
|
|
|
305
284
|
##
|
|
@@ -325,13 +304,6 @@ class RDoc::CodeObject
|
|
|
325
304
|
end
|
|
326
305
|
end
|
|
327
306
|
|
|
328
|
-
##
|
|
329
|
-
# File name of our parent
|
|
330
|
-
|
|
331
|
-
def parent_file_name
|
|
332
|
-
@parent ? @parent.base_name : '(unknown)'
|
|
333
|
-
end
|
|
334
|
-
|
|
335
307
|
##
|
|
336
308
|
# Name of our parent
|
|
337
309
|
|
|
@@ -342,7 +314,7 @@ class RDoc::CodeObject
|
|
|
342
314
|
##
|
|
343
315
|
# Records the RDoc::TopLevel (file) where this code object was defined
|
|
344
316
|
|
|
345
|
-
def record_location
|
|
317
|
+
def record_location(top_level)
|
|
346
318
|
@ignored = false
|
|
347
319
|
@suppressed = false
|
|
348
320
|
@file = top_level
|
|
@@ -384,7 +356,7 @@ class RDoc::CodeObject
|
|
|
384
356
|
##
|
|
385
357
|
# Sets the +store+ that contains this CodeObject
|
|
386
358
|
|
|
387
|
-
def store=
|
|
359
|
+
def store=(store)
|
|
388
360
|
@store = store
|
|
389
361
|
|
|
390
362
|
return unless @track_visibility
|