rdoc 6.12.0 → 6.14.1
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/README.rdoc +3 -1
- data/lib/rdoc/code_object/alias.rb +2 -9
- data/lib/rdoc/code_object/any_method.rb +9 -14
- data/lib/rdoc/code_object/attr.rb +6 -9
- data/lib/rdoc/code_object/class_module.rb +40 -23
- data/lib/rdoc/code_object/constant.rb +5 -5
- data/lib/rdoc/code_object/context/section.rb +8 -7
- data/lib/rdoc/code_object/context.rb +23 -65
- data/lib/rdoc/code_object/method_attr.rb +9 -28
- data/lib/rdoc/code_object/mixin.rb +3 -3
- data/lib/rdoc/code_object/normal_class.rb +1 -1
- data/lib/rdoc/code_object/normal_module.rb +1 -1
- data/lib/rdoc/code_object/require.rb +1 -1
- data/lib/rdoc/code_object/single_class.rb +1 -1
- data/lib/rdoc/code_object/top_level.rb +12 -30
- data/lib/rdoc/code_object.rb +6 -37
- data/lib/rdoc/comment.rb +7 -10
- data/lib/rdoc/cross_reference.rb +3 -3
- data/lib/rdoc/encoding.rb +4 -4
- data/lib/rdoc/erb_partial.rb +1 -1
- data/lib/rdoc/erbio.rb +2 -2
- data/lib/rdoc/generator/darkfish.rb +97 -109
- data/lib/rdoc/generator/json_index.rb +4 -20
- data/lib/rdoc/generator/markup.rb +14 -2
- data/lib/rdoc/generator/pot/message_extractor.rb +6 -6
- data/lib/rdoc/generator/pot/po.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +7 -7
- data/lib/rdoc/generator/pot.rb +1 -6
- data/lib/rdoc/generator/ri.rb +1 -1
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -30
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +15 -0
- data/lib/rdoc/markdown.kpeg +7 -5
- data/lib/rdoc/markdown.rb +34 -21
- data/lib/rdoc/markup/attribute_manager.rb +5 -5
- data/lib/rdoc/markup/attributes.rb +3 -3
- data/lib/rdoc/markup/blank_line.rb +2 -2
- data/lib/rdoc/markup/block_quote.rb +1 -1
- data/lib/rdoc/markup/document.rb +8 -8
- data/lib/rdoc/markup/formatter.rb +12 -12
- data/lib/rdoc/markup/hard_break.rb +3 -3
- data/lib/rdoc/markup/heading.rb +11 -5
- data/lib/rdoc/markup/include.rb +3 -3
- data/lib/rdoc/markup/indented_paragraph.rb +3 -3
- data/lib/rdoc/markup/list.rb +4 -4
- data/lib/rdoc/markup/list_item.rb +4 -4
- data/lib/rdoc/markup/paragraph.rb +2 -2
- data/lib/rdoc/markup/parser.rb +11 -11
- data/lib/rdoc/markup/pre_process.rb +6 -6
- data/lib/rdoc/markup/raw.rb +5 -5
- data/lib/rdoc/markup/rule.rb +2 -2
- data/lib/rdoc/markup/table.rb +4 -4
- data/lib/rdoc/markup/to_ansi.rb +3 -3
- data/lib/rdoc/markup/to_bs.rb +6 -6
- data/lib/rdoc/markup/to_html.rb +25 -16
- data/lib/rdoc/markup/to_html_crossref.rb +5 -5
- data/lib/rdoc/markup/to_html_snippet.rb +17 -17
- data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
- data/lib/rdoc/markup/to_label.rb +6 -5
- data/lib/rdoc/markup/to_markdown.rb +12 -12
- data/lib/rdoc/markup/to_rdoc.rb +29 -28
- data/lib/rdoc/markup/to_table_of_contents.rb +3 -3
- data/lib/rdoc/markup/to_test.rb +1 -1
- data/lib/rdoc/markup/to_tt_only.rb +8 -8
- data/lib/rdoc/markup/verbatim.rb +3 -3
- data/lib/rdoc/markup.rb +3 -3
- data/lib/rdoc/options.rb +31 -12
- data/lib/rdoc/parser/c.rb +20 -23
- data/lib/rdoc/parser/changelog.rb +9 -9
- data/lib/rdoc/parser/prism_ruby.rb +9 -16
- data/lib/rdoc/parser/ruby.rb +50 -53
- data/lib/rdoc/parser/simple.rb +2 -2
- data/lib/rdoc/parser.rb +8 -8
- data/lib/rdoc/rd/inline.rb +4 -4
- data/lib/rdoc/rd.rb +1 -1
- data/lib/rdoc/rdoc.rb +11 -26
- data/lib/rdoc/ri/driver.rb +60 -52
- data/lib/rdoc/ri/paths.rb +2 -2
- data/lib/rdoc/ri/task.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +14 -17
- data/lib/rdoc/servlet.rb +23 -22
- data/lib/rdoc/stats/normal.rb +1 -1
- data/lib/rdoc/stats/quiet.rb +1 -1
- data/lib/rdoc/stats/verbose.rb +3 -3
- data/lib/rdoc/stats.rb +14 -14
- data/lib/rdoc/store.rb +39 -43
- data/lib/rdoc/task.rb +2 -2
- data/lib/rdoc/text.rb +13 -13
- data/lib/rdoc/token_stream.rb +1 -1
- data/lib/rdoc/tom_doc.rb +7 -7
- data/lib/rdoc/version.rb +1 -1
- data/man/ri.1 +2 -0
- data/rdoc.gemspec +69 -0
- metadata +18 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
@@ -180,7 +180,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
180
180
|
#
|
181
181
|
# Currently only RDoc::Extend and RDoc::Include are supported.
|
182
182
|
|
183
|
-
def add
|
183
|
+
def add(klass, name, comment)
|
184
184
|
if RDoc::Extend == klass then
|
185
185
|
ext = RDoc::Extend.new name, comment
|
186
186
|
add_extend ext
|
@@ -195,7 +195,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
195
195
|
##
|
196
196
|
# Adds +an_alias+ that is automatically resolved
|
197
197
|
|
198
|
-
def add_alias
|
198
|
+
def add_alias(an_alias)
|
199
199
|
return an_alias unless @document_self
|
200
200
|
|
201
201
|
method_attr = find_method(an_alias.old_name, an_alias.singleton) ||
|
@@ -222,7 +222,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
222
222
|
# if method +foo+ exists, but <tt>attr_accessor :foo</tt> will be registered
|
223
223
|
# if method +foo+ exists, but <tt>foo=</tt> does not.
|
224
224
|
|
225
|
-
def add_attribute
|
225
|
+
def add_attribute(attribute)
|
226
226
|
return attribute unless @document_self
|
227
227
|
|
228
228
|
# mainly to check for redefinition of an attribute as a method
|
@@ -285,7 +285,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
285
285
|
# unless it later sees <tt>class Container</tt>. +add_class+ automatically
|
286
286
|
# upgrades +given_name+ to a class in this case.
|
287
287
|
|
288
|
-
def add_class
|
288
|
+
def add_class(class_type, given_name, superclass = '::Object')
|
289
289
|
# superclass +nil+ is passed by the C parser in the following cases:
|
290
290
|
# - registering Object in 1.8 (correct)
|
291
291
|
# - registering BasicObject in 1.9 (correct)
|
@@ -401,7 +401,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
401
401
|
# unless #done_documenting is +true+. Sets the #parent of +mod+
|
402
402
|
# to +self+, and its #section to #current_section. Returns +mod+.
|
403
403
|
|
404
|
-
def add_class_or_module
|
404
|
+
def add_class_or_module(mod, self_hash, all_hash)
|
405
405
|
mod.section = current_section # TODO declaring context? something is
|
406
406
|
# wrong here...
|
407
407
|
mod.parent = self
|
@@ -426,7 +426,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
426
426
|
# Adds +constant+ if not already there. If it is, updates the comment,
|
427
427
|
# value and/or is_alias_for of the known constant if they were empty/nil.
|
428
428
|
|
429
|
-
def add_constant
|
429
|
+
def add_constant(constant)
|
430
430
|
return constant unless @document_self
|
431
431
|
|
432
432
|
# HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)
|
@@ -451,7 +451,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
451
451
|
##
|
452
452
|
# Adds included module +include+ which should be an RDoc::Include
|
453
453
|
|
454
|
-
def add_include
|
454
|
+
def add_include(include)
|
455
455
|
add_to @includes, include
|
456
456
|
|
457
457
|
include
|
@@ -460,7 +460,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
460
460
|
##
|
461
461
|
# Adds extension module +ext+ which should be an RDoc::Extend
|
462
462
|
|
463
|
-
def add_extend
|
463
|
+
def add_extend(ext)
|
464
464
|
add_to @extends, ext
|
465
465
|
|
466
466
|
ext
|
@@ -470,7 +470,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
470
470
|
# Adds +method+ if not already there. If it is (as method or attribute),
|
471
471
|
# updates the comment if it was empty.
|
472
472
|
|
473
|
-
def add_method
|
473
|
+
def add_method(method)
|
474
474
|
return method unless @document_self
|
475
475
|
|
476
476
|
# HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code)
|
@@ -482,7 +482,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
482
482
|
known.comment = method.comment if known.comment.empty?
|
483
483
|
previously = ", previously in #{known.file}" unless
|
484
484
|
method.file == known.file
|
485
|
-
@store.
|
485
|
+
@store.options.warn \
|
486
486
|
"Duplicate method #{known.full_name} in #{method.file}#{previously}"
|
487
487
|
end
|
488
488
|
else
|
@@ -524,7 +524,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
524
524
|
# Adds an alias from +from+ (a class or module) to +name+ which was defined
|
525
525
|
# in +file+.
|
526
526
|
|
527
|
-
def add_module_alias
|
527
|
+
def add_module_alias(from, from_name, to, file)
|
528
528
|
return from if @done_documenting
|
529
529
|
|
530
530
|
to_full_name = child_name to.name
|
@@ -583,7 +583,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
583
583
|
#
|
584
584
|
# See also RDoc::Context::Section
|
585
585
|
|
586
|
-
def add_section
|
586
|
+
def add_section(title, comment = nil)
|
587
587
|
if section = @sections[title] then
|
588
588
|
section.add_comment comment if comment
|
589
589
|
else
|
@@ -597,7 +597,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
597
597
|
##
|
598
598
|
# Adds +thing+ to the collection +array+
|
599
599
|
|
600
|
-
def add_to
|
600
|
+
def add_to(array, thing)
|
601
601
|
array << thing if @document_self
|
602
602
|
|
603
603
|
thing.parent = self
|
@@ -629,7 +629,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
629
629
|
##
|
630
630
|
# Creates the full name for a child with +name+
|
631
631
|
|
632
|
-
def child_name
|
632
|
+
def child_name(name)
|
633
633
|
if name =~ /^:+/
|
634
634
|
$' #'
|
635
635
|
elsif RDoc::TopLevel === self then
|
@@ -688,13 +688,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
688
688
|
section
|
689
689
|
end
|
690
690
|
|
691
|
-
##
|
692
|
-
# Is part of this thing was defined in +file+?
|
693
|
-
|
694
|
-
def defined_in?(file)
|
695
|
-
@in_files.include?(file)
|
696
|
-
end
|
697
|
-
|
698
691
|
def display(method_attr) # :nodoc:
|
699
692
|
if method_attr.is_a? RDoc::Attr
|
700
693
|
"#{method_attr.definition} #{method_attr.pretty_name}"
|
@@ -713,13 +706,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
713
706
|
def each_ancestor(&_) # :nodoc:
|
714
707
|
end
|
715
708
|
|
716
|
-
##
|
717
|
-
# Iterator for attributes
|
718
|
-
|
719
|
-
def each_attribute # :yields: attribute
|
720
|
-
@attributes.each { |a| yield a }
|
721
|
-
end
|
722
|
-
|
723
709
|
##
|
724
710
|
# Iterator for classes and modules
|
725
711
|
|
@@ -727,27 +713,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
727
713
|
classes_and_modules.sort.each(&block)
|
728
714
|
end
|
729
715
|
|
730
|
-
##
|
731
|
-
# Iterator for constants
|
732
|
-
|
733
|
-
def each_constant # :yields: constant
|
734
|
-
@constants.each {|c| yield c}
|
735
|
-
end
|
736
|
-
|
737
|
-
##
|
738
|
-
# Iterator for included modules
|
739
|
-
|
740
|
-
def each_include # :yields: include
|
741
|
-
@includes.each do |i| yield i end
|
742
|
-
end
|
743
|
-
|
744
|
-
##
|
745
|
-
# Iterator for extension modules
|
746
|
-
|
747
|
-
def each_extend # :yields: extend
|
748
|
-
@extends.each do |e| yield e end
|
749
|
-
end
|
750
|
-
|
751
716
|
##
|
752
717
|
# Iterator for methods
|
753
718
|
|
@@ -847,13 +812,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
847
812
|
end
|
848
813
|
end
|
849
814
|
|
850
|
-
##
|
851
|
-
# Finds a file with +name+ in this context
|
852
|
-
|
853
|
-
def find_file_named name
|
854
|
-
@store.find_file_named name
|
855
|
-
end
|
856
|
-
|
857
815
|
##
|
858
816
|
# Finds an instance method with +name+ in this context
|
859
817
|
|
@@ -871,7 +829,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
871
829
|
find_attribute_named(symbol) or
|
872
830
|
find_external_alias_named(symbol) or
|
873
831
|
find_module_named(symbol) or
|
874
|
-
find_file_named(symbol)
|
832
|
+
@store.find_file_named(symbol)
|
875
833
|
end
|
876
834
|
|
877
835
|
##
|
@@ -973,10 +931,10 @@ class RDoc::Context < RDoc::CodeObject
|
|
973
931
|
##
|
974
932
|
# URL for this with a +prefix+
|
975
933
|
|
976
|
-
def http_url
|
934
|
+
def http_url
|
977
935
|
path = name_for_path
|
978
936
|
path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<</
|
979
|
-
path =
|
937
|
+
path = path.split('::')
|
980
938
|
|
981
939
|
File.join(*path.compact) + '.html'
|
982
940
|
end
|
@@ -1012,7 +970,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1012
970
|
# If +section+ is provided only methods in that RDoc::Context::Section will
|
1013
971
|
# be returned.
|
1014
972
|
|
1015
|
-
def methods_by_type
|
973
|
+
def methods_by_type(section = nil)
|
1016
974
|
methods = {}
|
1017
975
|
|
1018
976
|
TYPES.each do |type|
|
@@ -1104,7 +1062,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1104
1062
|
#--
|
1105
1063
|
# TODO mark the visibility of attributes in the template (if not public?)
|
1106
1064
|
|
1107
|
-
def remove_invisible
|
1065
|
+
def remove_invisible(min_visibility)
|
1108
1066
|
return if [:private, :nodoc].include? min_visibility
|
1109
1067
|
remove_invisible_in @method_list, min_visibility
|
1110
1068
|
remove_invisible_in @attributes, min_visibility
|
@@ -1114,7 +1072,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1114
1072
|
##
|
1115
1073
|
# Only called when min_visibility == :public or :private
|
1116
1074
|
|
1117
|
-
def remove_invisible_in
|
1075
|
+
def remove_invisible_in(array, min_visibility) # :nodoc:
|
1118
1076
|
if min_visibility == :public then
|
1119
1077
|
array.reject! { |e|
|
1120
1078
|
e.visibility != :public and not e.force_documentation
|
@@ -1130,7 +1088,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1130
1088
|
# Tries to resolve unmatched aliases when a method or attribute has just
|
1131
1089
|
# been added.
|
1132
1090
|
|
1133
|
-
def resolve_aliases
|
1091
|
+
def resolve_aliases(added)
|
1134
1092
|
# resolve any pending unmatched aliases
|
1135
1093
|
key = added.pretty_name
|
1136
1094
|
unmatched_alias_list = @unmatched_alias_lists[key]
|
@@ -1181,7 +1139,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1181
1139
|
##
|
1182
1140
|
# Sets the current section to a section with +title+. See also #add_section
|
1183
1141
|
|
1184
|
-
def set_current_section
|
1142
|
+
def set_current_section(title, comment)
|
1185
1143
|
@current_section = add_section title, comment
|
1186
1144
|
end
|
1187
1145
|
|
@@ -1246,7 +1204,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1246
1204
|
##
|
1247
1205
|
# Upgrades NormalModule +mod+ in +enclosing+ to a +class_type+
|
1248
1206
|
|
1249
|
-
def upgrade_to_class
|
1207
|
+
def upgrade_to_class(mod, class_type, enclosing)
|
1250
1208
|
enclosing.modules_hash.delete mod.name
|
1251
1209
|
|
1252
1210
|
klass = RDoc::ClassModule.from_module class_type, mod
|
@@ -63,19 +63,13 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
63
63
|
|
64
64
|
attr_reader :arglists
|
65
65
|
|
66
|
-
##
|
67
|
-
# Pretty parameter list for this method
|
68
|
-
|
69
|
-
attr_reader :param_seq
|
70
|
-
|
71
|
-
|
72
66
|
##
|
73
67
|
# Creates a new MethodAttr from token stream +text+ and method or attribute
|
74
68
|
# name +name+.
|
75
69
|
#
|
76
70
|
# Usually this is called by super from a subclass.
|
77
71
|
|
78
|
-
def initialize
|
72
|
+
def initialize(text, name, singleton: false)
|
79
73
|
super()
|
80
74
|
|
81
75
|
@text = text
|
@@ -84,21 +78,20 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
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
|
96
89
|
end
|
97
90
|
|
98
91
|
##
|
99
92
|
# Resets cached data for the object so it can be rebuilt by accessor methods
|
100
93
|
|
101
|
-
def initialize_copy
|
94
|
+
def initialize_copy(other) # :nodoc:
|
102
95
|
@full_name = nil
|
103
96
|
end
|
104
97
|
|
@@ -118,7 +111,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
118
111
|
[other.singleton ? 0 : 1, other.name_ord_range, other.name]
|
119
112
|
end
|
120
113
|
|
121
|
-
def ==
|
114
|
+
def ==(other) # :nodoc:
|
122
115
|
equal?(other) or self.class == other.class and full_name == other.full_name
|
123
116
|
end
|
124
117
|
|
@@ -157,7 +150,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
157
150
|
##
|
158
151
|
# Sets the store for this class or module and its contained code objects.
|
159
152
|
|
160
|
-
def store=
|
153
|
+
def store=(store)
|
161
154
|
super
|
162
155
|
|
163
156
|
@file = @store.add_file @file.full_name if @file
|
@@ -175,7 +168,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
175
168
|
return find_method_or_attribute name[0..-2]
|
176
169
|
end
|
177
170
|
|
178
|
-
def find_method_or_attribute
|
171
|
+
def find_method_or_attribute(name) # :nodoc:
|
179
172
|
return nil unless parent.respond_to? :ancestors
|
180
173
|
|
181
174
|
searched = parent.ancestors
|
@@ -289,7 +282,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
289
282
|
# HTML id-friendly method/attribute name
|
290
283
|
|
291
284
|
def html_name
|
292
|
-
require 'cgi/
|
285
|
+
require 'cgi/escape'
|
286
|
+
require 'cgi/util' unless defined?(CGI::EscapeExt)
|
293
287
|
|
294
288
|
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
295
289
|
end
|
@@ -320,19 +314,6 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
320
314
|
@singleton ? '::' : '#'
|
321
315
|
end
|
322
316
|
|
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
317
|
##
|
337
318
|
# Method/attribute name with class/instance indicator
|
338
319
|
|
@@ -361,7 +342,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
361
342
|
@parent_name || super
|
362
343
|
end
|
363
344
|
|
364
|
-
def pretty_print
|
345
|
+
def pretty_print(q) # :nodoc:
|
365
346
|
alias_for =
|
366
347
|
if @is_alias_for.respond_to? :name then
|
367
348
|
"alias for #{@is_alias_for.name}"
|
@@ -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
|
|
@@ -107,7 +107,7 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
107
107
|
##
|
108
108
|
# Sets the store for this class or module and its contained code objects.
|
109
109
|
|
110
|
-
def store=
|
110
|
+
def store=(store)
|
111
111
|
super
|
112
112
|
|
113
113
|
@file = @store.add_file @file.full_name if @file
|
@@ -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
|
|
@@ -28,8 +23,6 @@ class RDoc::TopLevel < RDoc::Context
|
|
28
23
|
|
29
24
|
attr_reader :classes_or_modules
|
30
25
|
|
31
|
-
attr_accessor :diagram # :nodoc:
|
32
|
-
|
33
26
|
##
|
34
27
|
# The parser class that processed this file
|
35
28
|
|
@@ -40,13 +33,11 @@ class RDoc::TopLevel < RDoc::Context
|
|
40
33
|
# is being generated outside the source dir +relative_name+ is relative to
|
41
34
|
# the source directory.
|
42
35
|
|
43
|
-
def initialize
|
36
|
+
def initialize(absolute_name, relative_name = absolute_name)
|
44
37
|
super()
|
45
38
|
@name = nil
|
46
39
|
@absolute_name = absolute_name
|
47
40
|
@relative_name = relative_name
|
48
|
-
@file_stat = File.stat(absolute_name) rescue nil # HACK for testing
|
49
|
-
@diagram = nil
|
50
41
|
@parser = nil
|
51
42
|
|
52
43
|
@classes_or_modules = []
|
@@ -64,7 +55,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
64
55
|
##
|
65
56
|
# An RDoc::TopLevel is equal to another with the same relative_name
|
66
57
|
|
67
|
-
def ==
|
58
|
+
def ==(other)
|
68
59
|
self.class === other and @relative_name == other.relative_name
|
69
60
|
end
|
70
61
|
|
@@ -82,7 +73,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
82
73
|
##
|
83
74
|
# Adds +constant+ to +Object+ instead of +self+.
|
84
75
|
|
85
|
-
def add_constant
|
76
|
+
def add_constant(constant)
|
86
77
|
object_class.record_location self
|
87
78
|
return constant unless @document_self
|
88
79
|
object_class.add_constant constant
|
@@ -110,7 +101,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
110
101
|
# Adds class or module +mod+. Used in the building phase
|
111
102
|
# by the Ruby parser.
|
112
103
|
|
113
|
-
def add_to_classes_or_modules
|
104
|
+
def add_to_classes_or_modules(mod)
|
114
105
|
@classes_or_modules << mod
|
115
106
|
end
|
116
107
|
|
@@ -137,7 +128,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
137
128
|
# TODO Why do we search through all classes/modules found, not just the
|
138
129
|
# ones of this instance?
|
139
130
|
|
140
|
-
def find_class_or_module
|
131
|
+
def find_class_or_module(name)
|
141
132
|
@store.find_class_or_module name
|
142
133
|
end
|
143
134
|
|
@@ -173,10 +164,8 @@ class RDoc::TopLevel < RDoc::Context
|
|
173
164
|
##
|
174
165
|
# URL for this with a +prefix+
|
175
166
|
|
176
|
-
def http_url
|
177
|
-
|
178
|
-
|
179
|
-
File.join(*path.compact) + '.html'
|
167
|
+
def http_url
|
168
|
+
@relative_name.tr('.', '_') + '.html'
|
180
169
|
end
|
181
170
|
|
182
171
|
def inspect # :nodoc:
|
@@ -188,13 +177,6 @@ class RDoc::TopLevel < RDoc::Context
|
|
188
177
|
]
|
189
178
|
end
|
190
179
|
|
191
|
-
##
|
192
|
-
# Time this file was last modified, if known
|
193
|
-
|
194
|
-
def last_modified
|
195
|
-
@file_stat ? file_stat.mtime : nil
|
196
|
-
end
|
197
|
-
|
198
180
|
##
|
199
181
|
# Dumps this TopLevel for use by ri. See also #marshal_load
|
200
182
|
|
@@ -210,13 +192,11 @@ class RDoc::TopLevel < RDoc::Context
|
|
210
192
|
##
|
211
193
|
# Loads this TopLevel from +array+.
|
212
194
|
|
213
|
-
def marshal_load
|
195
|
+
def marshal_load(array) # :nodoc:
|
214
196
|
initialize array[1]
|
215
197
|
|
216
198
|
@parser = array[2]
|
217
199
|
@comment = RDoc::Comment.from_document array[3]
|
218
|
-
|
219
|
-
@file_stat = nil
|
220
200
|
end
|
221
201
|
|
222
202
|
##
|
@@ -246,10 +226,12 @@ class RDoc::TopLevel < RDoc::Context
|
|
246
226
|
# Path to this file for use with HTML generator output.
|
247
227
|
|
248
228
|
def path
|
249
|
-
|
229
|
+
prefix = options.file_path_prefix
|
230
|
+
return http_url unless prefix
|
231
|
+
File.join(prefix, http_url)
|
250
232
|
end
|
251
233
|
|
252
|
-
def pretty_print
|
234
|
+
def pretty_print(q) # :nodoc:
|
253
235
|
q.group 2, "[#{self.class}: ", "]" do
|
254
236
|
q.text "base name: #{base_name.inspect}"
|
255
237
|
q.breakable
|
data/lib/rdoc/code_object.rb
CHANGED
@@ -21,9 +21,10 @@
|
|
21
21
|
# * RDoc::MetaMethod
|
22
22
|
# * RDoc::Alias
|
23
23
|
# * RDoc::Constant
|
24
|
+
# * RDoc::Require
|
24
25
|
# * RDoc::Mixin
|
25
|
-
# * RDoc::Require
|
26
26
|
# * RDoc::Include
|
27
|
+
# * RDoc::Extend
|
27
28
|
|
28
29
|
class RDoc::CodeObject
|
29
30
|
|
@@ -89,13 +90,6 @@ class RDoc::CodeObject
|
|
89
90
|
|
90
91
|
attr_reader :store
|
91
92
|
|
92
|
-
##
|
93
|
-
# We are the model of the code, but we know that at some point we will be
|
94
|
-
# worked on by viewers. By implementing the Viewable protocol, viewers can
|
95
|
-
# associated themselves with these objects.
|
96
|
-
|
97
|
-
attr_accessor :viewer
|
98
|
-
|
99
93
|
##
|
100
94
|
# When mixed-in to a class, this points to the Context in which it was originally defined.
|
101
95
|
|
@@ -216,20 +210,6 @@ class RDoc::CodeObject
|
|
216
210
|
@document_children = @document_self
|
217
211
|
end
|
218
212
|
|
219
|
-
##
|
220
|
-
# Yields each parent of this CodeObject. See also
|
221
|
-
# RDoc::ClassModule#each_ancestor
|
222
|
-
|
223
|
-
def each_parent
|
224
|
-
code_object = self
|
225
|
-
|
226
|
-
while code_object = code_object.parent do
|
227
|
-
yield code_object
|
228
|
-
end
|
229
|
-
|
230
|
-
self
|
231
|
-
end
|
232
|
-
|
233
213
|
##
|
234
214
|
# File name where this CodeObject was found.
|
235
215
|
#
|
@@ -256,7 +236,7 @@ class RDoc::CodeObject
|
|
256
236
|
#
|
257
237
|
# Set to +nil+ to clear RDoc's cached value
|
258
238
|
|
259
|
-
def full_name=
|
239
|
+
def full_name=(full_name)
|
260
240
|
@full_name = full_name
|
261
241
|
end
|
262
242
|
|
@@ -300,11 +280,7 @@ class RDoc::CodeObject
|
|
300
280
|
# This is used by Text#snippet
|
301
281
|
|
302
282
|
def options
|
303
|
-
|
304
|
-
@store.rdoc.options
|
305
|
-
else
|
306
|
-
RDoc::Options.new
|
307
|
-
end
|
283
|
+
@store&.options || RDoc::Options.new
|
308
284
|
end
|
309
285
|
|
310
286
|
##
|
@@ -330,13 +306,6 @@ class RDoc::CodeObject
|
|
330
306
|
end
|
331
307
|
end
|
332
308
|
|
333
|
-
##
|
334
|
-
# File name of our parent
|
335
|
-
|
336
|
-
def parent_file_name
|
337
|
-
@parent ? @parent.base_name : '(unknown)'
|
338
|
-
end
|
339
|
-
|
340
309
|
##
|
341
310
|
# Name of our parent
|
342
311
|
|
@@ -347,7 +316,7 @@ class RDoc::CodeObject
|
|
347
316
|
##
|
348
317
|
# Records the RDoc::TopLevel (file) where this code object was defined
|
349
318
|
|
350
|
-
def record_location
|
319
|
+
def record_location(top_level)
|
351
320
|
@ignored = false
|
352
321
|
@suppressed = false
|
353
322
|
@file = top_level
|
@@ -389,7 +358,7 @@ class RDoc::CodeObject
|
|
389
358
|
##
|
390
359
|
# Sets the +store+ that contains this CodeObject
|
391
360
|
|
392
|
-
def store=
|
361
|
+
def store=(store)
|
393
362
|
@store = store
|
394
363
|
|
395
364
|
return unless @track_visibility
|