rdoc 8.0.0 → 8.1.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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -3
  3. data/RI.md +75 -75
  4. data/exe/rdoc +2 -2
  5. data/lib/rdoc/code_object/alias.rb +71 -69
  6. data/lib/rdoc/code_object/any_method.rb +305 -303
  7. data/lib/rdoc/code_object/attr.rb +150 -148
  8. data/lib/rdoc/code_object/class_module.rb +798 -792
  9. data/lib/rdoc/code_object/constant.rb +175 -173
  10. data/lib/rdoc/code_object/context/section.rb +142 -138
  11. data/lib/rdoc/code_object/context.rb +926 -958
  12. data/lib/rdoc/code_object/extend.rb +7 -5
  13. data/lib/rdoc/code_object/include.rb +7 -5
  14. data/lib/rdoc/code_object/method_attr.rb +326 -319
  15. data/lib/rdoc/code_object/mixin.rb +97 -95
  16. data/lib/rdoc/code_object/normal_class.rb +77 -78
  17. data/lib/rdoc/code_object/normal_module.rb +61 -59
  18. data/lib/rdoc/code_object/require.rb +23 -39
  19. data/lib/rdoc/code_object/single_class.rb +21 -19
  20. data/lib/rdoc/code_object/top_level.rb +212 -219
  21. data/lib/rdoc/code_object.rb +305 -303
  22. data/lib/rdoc/comment.rb +275 -273
  23. data/lib/rdoc/cross_reference.rb +192 -190
  24. data/lib/rdoc/encoding.rb +105 -103
  25. data/lib/rdoc/erb_partial.rb +13 -11
  26. data/lib/rdoc/erbio.rb +29 -27
  27. data/lib/rdoc/generator/aliki.rb +161 -153
  28. data/lib/rdoc/generator/darkfish.rb +645 -635
  29. data/lib/rdoc/generator/json_index.rb +233 -229
  30. data/lib/rdoc/generator/markup.rb +164 -146
  31. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  32. data/lib/rdoc/generator/pot/po.rb +52 -51
  33. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  34. data/lib/rdoc/generator/pot.rb +85 -81
  35. data/lib/rdoc/generator/ri.rb +23 -19
  36. data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
  37. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
  39. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  40. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  41. data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
  42. data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  44. data/lib/rdoc/generator.rb +48 -46
  45. data/lib/rdoc/i18n/locale.rb +99 -95
  46. data/lib/rdoc/i18n/text.rb +109 -105
  47. data/lib/rdoc/i18n.rb +7 -5
  48. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  49. data/lib/rdoc/markdown.kpeg +15 -11
  50. data/lib/rdoc/markdown.rb +40 -47
  51. data/lib/rdoc/markup/block_quote.rb +12 -8
  52. data/lib/rdoc/markup/document.rb +127 -123
  53. data/lib/rdoc/markup/formatter.rb +219 -215
  54. data/lib/rdoc/markup/include.rb +33 -29
  55. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  56. data/lib/rdoc/markup/inline_parser.rb +281 -277
  57. data/lib/rdoc/markup/list.rb +80 -88
  58. data/lib/rdoc/markup/list_item.rb +73 -85
  59. data/lib/rdoc/markup/paragraph.rb +23 -19
  60. data/lib/rdoc/markup/parser.rb +501 -497
  61. data/lib/rdoc/markup/pre_process.rb +283 -279
  62. data/lib/rdoc/markup/raw.rb +2 -2
  63. data/lib/rdoc/markup/rule.rb +16 -12
  64. data/lib/rdoc/markup/to_ansi.rb +143 -139
  65. data/lib/rdoc/markup/to_bs.rb +72 -68
  66. data/lib/rdoc/markup/to_html.rb +594 -565
  67. data/lib/rdoc/markup/to_html_crossref.rb +234 -230
  68. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  69. data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
  70. data/lib/rdoc/markup/to_label.rb +63 -59
  71. data/lib/rdoc/markup/to_markdown.rb +212 -208
  72. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  73. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  74. data/lib/rdoc/markup/to_test.rb +60 -56
  75. data/lib/rdoc/markup/to_tt_only.rb +84 -80
  76. data/lib/rdoc/markup/verbatim.rb +62 -58
  77. data/lib/rdoc/markup.rb +198 -196
  78. data/lib/rdoc/options.rb +1063 -1061
  79. data/lib/rdoc/parser/c.rb +1039 -1037
  80. data/lib/rdoc/parser/changelog.rb +319 -315
  81. data/lib/rdoc/parser/markdown.rb +17 -13
  82. data/lib/rdoc/parser/rbs.rb +239 -235
  83. data/lib/rdoc/parser/rd.rb +17 -13
  84. data/lib/rdoc/parser/ruby.rb +1245 -1124
  85. data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
  86. data/lib/rdoc/parser/simple.rb +31 -27
  87. data/lib/rdoc/parser/text.rb +12 -8
  88. data/lib/rdoc/parser.rb +228 -220
  89. data/lib/rdoc/rbs_helper.rb +1 -1
  90. data/lib/rdoc/rd/inline.rb +57 -53
  91. data/lib/rdoc/rd.rb +90 -88
  92. data/lib/rdoc/rdoc.rb +500 -491
  93. data/lib/rdoc/ri/driver.rb +1140 -1135
  94. data/lib/rdoc/ri/formatter.rb +7 -3
  95. data/lib/rdoc/ri/paths.rb +140 -136
  96. data/lib/rdoc/ri/servlet.rb +354 -350
  97. data/lib/rdoc/ri/store.rb +4 -2
  98. data/lib/rdoc/ri/task.rb +55 -51
  99. data/lib/rdoc/ri.rb +14 -12
  100. data/lib/rdoc/rubygems_hook.rb +183 -181
  101. data/lib/rdoc/server.rb +349 -347
  102. data/lib/rdoc/stats/normal.rb +46 -42
  103. data/lib/rdoc/stats/quiet.rb +39 -35
  104. data/lib/rdoc/stats/verbose.rb +35 -31
  105. data/lib/rdoc/stats.rb +365 -363
  106. data/lib/rdoc/store.rb +888 -902
  107. data/lib/rdoc/task.rb +260 -256
  108. data/lib/rdoc/text.rb +135 -133
  109. data/lib/rdoc/token_stream.rb +101 -93
  110. data/lib/rdoc/tom_doc.rb +203 -201
  111. data/lib/rdoc/version.rb +1 -1
  112. metadata +4 -5
  113. data/lib/rdoc/markdown/literals.kpeg +0 -21
  114. data/lib/rdoc/markdown/literals.rb +0 -454
@@ -1,123 +1,125 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A Mixin adds features from a module into another context. RDoc::Include and
4
- # RDoc::Extend are both mixins.
2
+ module RDoc
3
+ ##
4
+ # A Mixin adds features from a module into another context. RDoc::Include and
5
+ # RDoc::Extend are both mixins.
5
6
 
6
- class RDoc::Mixin < RDoc::CodeObject
7
+ class Mixin < CodeObject
7
8
 
8
- ##
9
- # Name of included module
9
+ ##
10
+ # Name of included module
10
11
 
11
- attr_accessor :name
12
+ attr_accessor :name
12
13
 
13
- ##
14
- # Creates a new Mixin for +name+ with +comment+
14
+ ##
15
+ # Creates a new Mixin for +name+ with +comment+
15
16
 
16
- def initialize(name, comment)
17
- super()
18
- @name = name
19
- self.comment = comment
20
- @module = nil # cache for module if found
21
- end
17
+ def initialize(name, comment)
18
+ super()
19
+ @name = name
20
+ self.comment = comment
21
+ @module = nil # cache for module if found
22
+ end
22
23
 
23
- ##
24
- # Mixins are sorted by name
24
+ ##
25
+ # Mixins are sorted by name
25
26
 
26
- def <=>(other)
27
- return unless self.class === other
27
+ def <=>(other)
28
+ return unless self.class === other
28
29
 
29
- name <=> other.name
30
- end
30
+ name <=> other.name
31
+ end
31
32
 
32
- def ==(other) # :nodoc:
33
- self.class === other and @name == other.name
34
- end
33
+ def ==(other) # :nodoc:
34
+ self.class === other and @name == other.name
35
+ end
35
36
 
36
- alias eql? == # :nodoc:
37
+ alias eql? == # :nodoc:
37
38
 
38
- ##
39
- # Full name based on #module
39
+ ##
40
+ # Full name based on #module
40
41
 
41
- def full_name
42
- m = self.module
43
- RDoc::ClassModule === m ? m.full_name : @name
44
- end
42
+ def full_name
43
+ m = self.module
44
+ ClassModule === m ? m.full_name : @name
45
+ end
45
46
 
46
- def hash # :nodoc:
47
- [@name, self.module].hash
48
- end
47
+ def hash # :nodoc:
48
+ [@name, self.module].hash
49
+ end
49
50
 
50
- def inspect # :nodoc:
51
- "#<%s:0x%x %s.%s %s>" % [
52
- self.class,
53
- object_id,
54
- parent_name, self.class.name.downcase, @name,
55
- ]
56
- end
51
+ def inspect # :nodoc:
52
+ "#<%s:0x%x %s.%s %s>" % [
53
+ self.class,
54
+ object_id,
55
+ parent_name, self.class.name.downcase, @name,
56
+ ]
57
+ end
57
58
 
58
- ##
59
- # Attempts to locate the included module object. Returns the name if not
60
- # known.
61
- #
62
- # The scoping rules of Ruby to resolve the name of an included module are:
63
- # - first look into the children of the current context;
64
- # - if not found, look into the children of included modules,
65
- # in reverse inclusion order;
66
- # - if still not found, go up the hierarchy of names.
67
- #
68
- # This method has <code>O(n!)</code> behavior when the module calling
69
- # include is referencing nonexistent modules. Avoid calling #module until
70
- # after all the files are parsed. This behavior is due to ruby's constant
71
- # lookup behavior.
72
- #
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.
77
-
78
- def module
79
- return @module if @module
80
-
81
- # search the current context
82
- return @name unless parent
83
- full_name = parent.child_name(@name)
84
- @module = @store.modules_hash[full_name]
85
- return @module if @module
86
- return @name if @name =~ /^::/
87
-
88
- # search the includes before this one, in reverse order
89
- searched = parent.includes.take_while { |i| i != self }.reverse
90
- searched.each do |i|
91
- inc = i.module
92
- next if String === inc
93
- full_name = inc.child_name(@name)
94
- @module = @store.modules_hash[full_name]
59
+ ##
60
+ # Attempts to locate the included module object. Returns the name if not
61
+ # known.
62
+ #
63
+ # The scoping rules of Ruby to resolve the name of an included module are:
64
+ # - first look into the children of the current context;
65
+ # - if not found, look into the children of included modules,
66
+ # in reverse inclusion order;
67
+ # - if still not found, go up the hierarchy of names.
68
+ #
69
+ # This method has <code>O(n!)</code> behavior when the module calling
70
+ # include is referencing nonexistent modules. Avoid calling #module until
71
+ # after all the files are parsed. This behavior is due to ruby's constant
72
+ # lookup behavior.
73
+ #
74
+ # As of the beginning of October, 2011, no gem includes nonexistent modules.
75
+ #
76
+ # The Ruby parser passes an already-resolved full-path +name+, so most of this
77
+ # logic only runs for the C parser, which passes the unresolved local name.
78
+
79
+ def module
95
80
  return @module if @module
96
- end
97
81
 
98
- # go up the hierarchy of names
99
- up = parent.parent
100
- while up
101
- full_name = up.child_name(@name)
82
+ # search the current context
83
+ return @name unless parent
84
+ full_name = parent.child_name(@name)
102
85
  @module = @store.modules_hash[full_name]
103
86
  return @module if @module
104
- up = up.parent
87
+ return @name if @name =~ /^::/
88
+
89
+ # search the includes before this one, in reverse order
90
+ searched = parent.includes.take_while { |i| i != self }.reverse
91
+ searched.each do |i|
92
+ inc = i.module
93
+ next if String === inc
94
+ full_name = inc.child_name(@name)
95
+ @module = @store.modules_hash[full_name]
96
+ return @module if @module
97
+ end
98
+
99
+ # go up the hierarchy of names
100
+ up = parent.parent
101
+ while up
102
+ full_name = up.child_name(@name)
103
+ @module = @store.modules_hash[full_name]
104
+ return @module if @module
105
+ up = up.parent
106
+ end
107
+
108
+ @name
105
109
  end
106
110
 
107
- @name
108
- end
111
+ ##
112
+ # Sets the store for this class or module and its contained code objects.
109
113
 
110
- ##
111
- # Sets the store for this class or module and its contained code objects.
114
+ def store=(store)
115
+ super
112
116
 
113
- def store=(store)
114
- super
117
+ @file = @store.add_file @file.full_name if @file
118
+ end
115
119
 
116
- @file = @store.add_file @file.full_name if @file
117
- end
120
+ def to_s # :nodoc:
121
+ "#{self.class.name.downcase} #@name in: #{parent}"
122
+ end
118
123
 
119
- def to_s # :nodoc:
120
- "#{self.class.name.downcase} #@name in: #{parent}"
121
124
  end
122
-
123
125
  end
@@ -1,92 +1,91 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A normal class, neither singleton nor anonymous
4
-
5
- class RDoc::NormalClass < RDoc::ClassModule
6
-
2
+ module RDoc
7
3
  ##
8
- # The ancestors of this class including modules. Unlike Module#ancestors,
9
- # this class is not included in the result. The result will contain both
10
- # RDoc::ClassModules and Strings.
11
-
12
- def ancestors
13
- if String === superclass then
14
- super << superclass
15
- elsif superclass then
16
- ancestors = super
17
- ancestors << superclass
18
- ancestors.concat superclass.ancestors
19
- else
20
- super
4
+ # A normal class, neither singleton nor anonymous
5
+
6
+ class NormalClass < ClassModule
7
+
8
+ ##
9
+ # The ancestors of this class including modules. Unlike Module#ancestors,
10
+ # this class is not included in the result. The result will contain both
11
+ # RDoc::ClassModules and Strings.
12
+
13
+ def ancestors
14
+ ancestors = included_ancestors
15
+ super_classes.each do |sclass|
16
+ ancestors << sclass
17
+ ancestors.concat sclass.included_ancestors unless String === sclass
18
+ end
19
+ ancestors
21
20
  end
22
- end
23
21
 
24
- def aref_prefix # :nodoc:
25
- 'class'
26
- end
22
+ def aref_prefix # :nodoc:
23
+ 'class'
24
+ end
27
25
 
28
- ##
29
- # The definition of this class, <tt>class MyClassName</tt>
26
+ ##
27
+ # The definition of this class, <tt>class MyClassName</tt>
30
28
 
31
- def definition
32
- "class #{full_name}"
33
- end
29
+ def definition
30
+ "class #{full_name}"
31
+ end
34
32
 
35
- def direct_ancestors
36
- superclass ? super + [superclass] : super
37
- end
33
+ def direct_ancestors
34
+ superclass ? super + [superclass] : super
35
+ end
38
36
 
39
- def inspect # :nodoc:
40
- superclass = @superclass ? " < #{@superclass}" : nil
41
- "<%s:0x%x class %s%s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
42
- self.class, object_id,
43
- full_name, superclass, @includes, @extends, @attributes, @method_list, @aliases
44
- ]
45
- end
37
+ def inspect # :nodoc:
38
+ superclass = @superclass ? " < #{@superclass}" : nil
39
+ "<%s:0x%x class %s%s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
40
+ self.class, object_id,
41
+ full_name, superclass, @includes, @extends, @attributes, @method_list, @aliases
42
+ ]
43
+ end
46
44
 
47
- def to_s # :nodoc:
48
- display = "#{self.class.name} #{self.full_name}"
49
- if superclass
50
- display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
45
+ def to_s # :nodoc:
46
+ display = "#{self.class.name} #{self.full_name}"
47
+ if superclass
48
+ display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
49
+ end
50
+ display += ' -> ' + is_alias_for.to_s if is_alias_for
51
+ display
51
52
  end
52
- display += ' -> ' + is_alias_for.to_s if is_alias_for
53
- display
54
- end
55
53
 
56
- def pretty_print(q) # :nodoc:
57
- superclass = @superclass ? " < #{@superclass}" : nil
58
-
59
- q.group 2, "[class #{full_name}#{superclass}", "]" do
60
- q.breakable
61
- q.text "includes:"
62
- q.breakable
63
- q.seplist @includes do |inc| q.pp inc end
64
-
65
- q.breakable
66
- q.text "constants:"
67
- q.breakable
68
- q.seplist @constants do |const| q.pp const end
69
-
70
- q.breakable
71
- q.text "attributes:"
72
- q.breakable
73
- q.seplist @attributes do |attr| q.pp attr end
74
-
75
- q.breakable
76
- q.text "methods:"
77
- q.breakable
78
- q.seplist @method_list do |meth| q.pp meth end
79
-
80
- q.breakable
81
- q.text "aliases:"
82
- q.breakable
83
- q.seplist @aliases do |aliaz| q.pp aliaz end
84
-
85
- q.breakable
86
- q.text "comment:"
87
- q.breakable
88
- q.pp comment
54
+ def pretty_print(q) # :nodoc:
55
+ superclass = @superclass ? " < #{@superclass}" : nil
56
+
57
+ q.group 2, "[class #{full_name}#{superclass}", "]" do
58
+ q.breakable
59
+ q.text "includes:"
60
+ q.breakable
61
+ q.seplist @includes do |inc| q.pp inc end
62
+
63
+ q.breakable
64
+ q.text "constants:"
65
+ q.breakable
66
+ q.seplist @constants do |const| q.pp const end
67
+
68
+ q.breakable
69
+ q.text "attributes:"
70
+ q.breakable
71
+ q.seplist @attributes do |attr| q.pp attr end
72
+
73
+ q.breakable
74
+ q.text "methods:"
75
+ q.breakable
76
+ q.seplist @method_list do |meth| q.pp meth end
77
+
78
+ q.breakable
79
+ q.text "aliases:"
80
+ q.breakable
81
+ q.seplist @aliases do |aliaz| q.pp aliaz end
82
+
83
+ q.breakable
84
+ q.text "comment:"
85
+ q.breakable
86
+ q.pp comment
87
+ end
89
88
  end
90
- end
91
89
 
90
+ end
92
91
  end
@@ -1,73 +1,75 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A normal module, like NormalClass
2
+ module RDoc
3
+ ##
4
+ # A normal module, like NormalClass
4
5
 
5
- class RDoc::NormalModule < RDoc::ClassModule
6
+ class NormalModule < ClassModule
6
7
 
7
- def aref_prefix # :nodoc:
8
- 'module'
9
- end
8
+ def aref_prefix # :nodoc:
9
+ 'module'
10
+ end
10
11
 
11
- def inspect # :nodoc:
12
- "#<%s:0x%x module %s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
13
- self.class, object_id,
14
- full_name, @includes, @extends, @attributes, @method_list, @aliases
15
- ]
16
- end
12
+ def inspect # :nodoc:
13
+ "#<%s:0x%x module %s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
14
+ self.class, object_id,
15
+ full_name, @includes, @extends, @attributes, @method_list, @aliases
16
+ ]
17
+ end
17
18
 
18
- ##
19
- # The definition of this module, <tt>module MyModuleName</tt>
19
+ ##
20
+ # The definition of this module, <tt>module MyModuleName</tt>
20
21
 
21
- def definition
22
- "module #{full_name}"
23
- end
22
+ def definition
23
+ "module #{full_name}"
24
+ end
24
25
 
25
- ##
26
- # This is a module, returns true
26
+ ##
27
+ # This is a module, returns true
27
28
 
28
- def module?
29
- true
30
- end
29
+ def module?
30
+ true
31
+ end
31
32
 
32
- def pretty_print(q) # :nodoc:
33
- q.group 2, "[module #{full_name}:", "]" do
34
- q.breakable
35
- q.text "includes:"
36
- q.breakable
37
- q.seplist @includes do |inc| q.pp inc end
38
- q.breakable
39
-
40
- q.breakable
41
- q.text "constants:"
42
- q.breakable
43
- q.seplist @constants do |const| q.pp const end
44
-
45
- q.text "attributes:"
46
- q.breakable
47
- q.seplist @attributes do |attr| q.pp attr end
48
- q.breakable
49
-
50
- q.text "methods:"
51
- q.breakable
52
- q.seplist @method_list do |meth| q.pp meth end
53
- q.breakable
54
-
55
- q.text "aliases:"
56
- q.breakable
57
- q.seplist @aliases do |aliaz| q.pp aliaz end
58
- q.breakable
59
-
60
- q.text "comment:"
61
- q.breakable
62
- q.pp comment
33
+ def pretty_print(q) # :nodoc:
34
+ q.group 2, "[module #{full_name}:", "]" do
35
+ q.breakable
36
+ q.text "includes:"
37
+ q.breakable
38
+ q.seplist @includes do |inc| q.pp inc end
39
+ q.breakable
40
+
41
+ q.breakable
42
+ q.text "constants:"
43
+ q.breakable
44
+ q.seplist @constants do |const| q.pp const end
45
+
46
+ q.text "attributes:"
47
+ q.breakable
48
+ q.seplist @attributes do |attr| q.pp attr end
49
+ q.breakable
50
+
51
+ q.text "methods:"
52
+ q.breakable
53
+ q.seplist @method_list do |meth| q.pp meth end
54
+ q.breakable
55
+
56
+ q.text "aliases:"
57
+ q.breakable
58
+ q.seplist @aliases do |aliaz| q.pp aliaz end
59
+ q.breakable
60
+
61
+ q.text "comment:"
62
+ q.breakable
63
+ q.pp comment
64
+ end
63
65
  end
64
- end
65
66
 
66
- ##
67
- # Modules don't have one, raises NoMethodError
67
+ ##
68
+ # Modules don't have one, raises NoMethodError
68
69
 
69
- def superclass
70
- raise NoMethodError, "#{full_name} is a module"
71
- end
70
+ def superclass
71
+ raise NoMethodError, "#{full_name} is a module"
72
+ end
72
73
 
74
+ end
73
75
  end
@@ -1,51 +1,35 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A file loaded by \#require
4
-
5
- class RDoc::Require < RDoc::CodeObject
6
-
7
- ##
8
- # Name of the required file
9
-
10
- attr_accessor :name
11
-
2
+ module RDoc
12
3
  ##
13
- # Creates a new Require that loads +name+ with +comment+
4
+ # A file loaded by \#require
14
5
 
15
- def initialize(name, comment)
16
- super()
17
- @name = name.gsub(/'|"/, "") #'
18
- @top_level = nil
19
- self.comment = comment
20
- end
6
+ class Require < CodeObject
21
7
 
22
- def inspect # :nodoc:
23
- "#<%s:0x%x require '%s' in %s>" % [
24
- self.class,
25
- object_id,
26
- @name,
27
- @parent ? @parent.base_name : '(unknown)'
28
- ]
29
- end
8
+ ##
9
+ # Name of the required file
30
10
 
31
- def to_s # :nodoc:
32
- "require #{name} in: #{parent}"
33
- end
11
+ attr_accessor :name
34
12
 
35
- ##
36
- # The RDoc::TopLevel corresponding to this require, or +nil+ if not found.
13
+ ##
14
+ # Creates a new Require that loads +name+ with +comment+
37
15
 
38
- def top_level
39
- @top_level ||= begin
40
- tl = RDoc::TopLevel.all_files_hash[name + '.rb']
16
+ def initialize(name, comment)
17
+ super()
18
+ @name = name.gsub(/'|"/, "")
19
+ self.comment = comment
20
+ end
41
21
 
42
- if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then
43
- # second chance
44
- tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb']
45
- end
22
+ def inspect # :nodoc:
23
+ "#<%s:0x%x require '%s' in %s>" % [
24
+ self.class,
25
+ object_id,
26
+ @name,
27
+ @parent ? @parent.base_name : '(unknown)'
28
+ ]
29
+ end
46
30
 
47
- tl
31
+ def to_s # :nodoc:
32
+ "require #{name} in: #{parent}"
48
33
  end
49
34
  end
50
-
51
35
  end
@@ -1,30 +1,32 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A singleton class
2
+ module RDoc
3
+ ##
4
+ # A singleton class
4
5
 
5
- class RDoc::SingleClass < RDoc::ClassModule
6
+ class SingleClass < ClassModule
6
7
 
7
- ##
8
- # Adds the superclass to the included modules.
8
+ ##
9
+ # Adds the superclass to the included modules.
9
10
 
10
- def ancestors
11
- superclass ? super + [superclass] : super
12
- end
11
+ def ancestors
12
+ superclass ? super + [superclass] : super
13
+ end
13
14
 
14
- def aref_prefix # :nodoc:
15
- 'sclass'
16
- end
15
+ def aref_prefix # :nodoc:
16
+ 'sclass'
17
+ end
17
18
 
18
- ##
19
- # The definition of this singleton class, <tt>class << MyClassName</tt>
19
+ ##
20
+ # The definition of this singleton class, <tt>class << MyClassName</tt>
20
21
 
21
- def definition
22
- "class << #{full_name}"
23
- end
22
+ def definition
23
+ "class << #{full_name}"
24
+ end
24
25
 
25
- def pretty_print(q) # :nodoc:
26
- q.group 2, "[class << #{full_name}", "]" do
27
- next
26
+ def pretty_print(q) # :nodoc:
27
+ q.group 2, "[class << #{full_name}", "]" do
28
+ next
29
+ end
28
30
  end
29
31
  end
30
32
  end