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,286 +1,279 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A TopLevel context is a representation of the contents of a single file
2
+ module RDoc
3
+ ##
4
+ # A TopLevel context is a representation of the contents of a single file
4
5
 
5
- class RDoc::TopLevel < RDoc::Context
6
+ class TopLevel < Context
6
7
 
7
- MARSHAL_VERSION = 0 # :nodoc:
8
+ MARSHAL_VERSION = 0 # :nodoc:
8
9
 
9
- ##
10
- # Relative name of this file
10
+ ##
11
+ # Relative name of this file
11
12
 
12
- attr_accessor :relative_name
13
+ attr_accessor :relative_name
13
14
 
14
- ##
15
- # Absolute name of this file
15
+ ##
16
+ # Absolute name of this file
16
17
 
17
- attr_accessor :absolute_name
18
+ attr_accessor :absolute_name
18
19
 
19
- ##
20
- # Base name of this file
20
+ ##
21
+ # Base name of this file
21
22
 
22
- attr_reader :base_name
23
+ attr_reader :base_name
23
24
 
24
- ##
25
- # Base name of this file without the extension
25
+ ##
26
+ # Base name of this file without the extension
26
27
 
27
- attr_reader :page_name
28
+ attr_reader :page_name
28
29
 
29
- ##
30
- # All the classes or modules that were declared in
31
- # this file. These are assigned to either +#classes_hash+
32
- # or +#modules_hash+ once we know what they really are.
30
+ ##
31
+ # All the classes or modules that were declared in
32
+ # this file. These are assigned to either +#classes_hash+
33
+ # or +#modules_hash+ once we know what they really are.
33
34
 
34
- attr_reader :classes_or_modules
35
+ attr_reader :classes_or_modules
35
36
 
36
- ##
37
- # The parser class that processed this file
37
+ ##
38
+ # The parser class that processed this file
38
39
 
39
- attr_reader :parser
40
+ attr_accessor :parser
40
41
 
41
- ##
42
- # Creates a new TopLevel for the file at +absolute_name+. If documentation
43
- # is being generated outside the source dir +relative_name+ is relative to
44
- # the source directory.
45
-
46
- def initialize(absolute_name, relative_name = absolute_name)
47
- super()
48
- @name = nil
49
- @absolute_name = absolute_name
50
- @relative_name = relative_name
51
- @parser = nil
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
42
+ ##
43
+ # Creates a new TopLevel for the file at +absolute_name+. If documentation
44
+ # is being generated outside the source dir +relative_name+ is relative to
45
+ # the source directory.
46
+
47
+ def initialize(absolute_name, relative_name = absolute_name)
48
+ super()
49
+ @name = nil
50
+ @absolute_name = absolute_name
51
+ @relative_name = relative_name
52
+ @parser = nil
53
+
54
+ if relative_name
55
+ @base_name = File.basename(relative_name)
56
+ @page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '')
57
+ else
58
+ @base_name = nil
59
+ @page_name = nil
60
+ end
61
+
62
+ @classes_or_modules = []
59
63
  end
60
64
 
61
- @classes_or_modules = []
62
- end
65
+ ##
66
+ # An RDoc::TopLevel is equal to another with the same relative_name
63
67
 
64
- ##
65
- # Sets the parser for this toplevel context, also the store.
68
+ def ==(other)
69
+ self.class === other and @relative_name == other.relative_name
70
+ end
66
71
 
67
- def parser=(val)
68
- @parser = val
69
- @store&.cache_text_file(relative_name)
70
- @parser
71
- end
72
+ alias eql? ==
72
73
 
73
- ##
74
- # An RDoc::TopLevel is equal to another with the same relative_name
74
+ ##
75
+ # Adds +an_alias+ to +Object+ instead of +self+.
75
76
 
76
- def ==(other)
77
- self.class === other and @relative_name == other.relative_name
78
- end
77
+ def add_alias(an_alias)
78
+ object_class.record_location self
79
+ return an_alias unless @document_self
80
+ object_class.add_alias an_alias
81
+ end
79
82
 
80
- alias eql? ==
83
+ ##
84
+ # Adds +constant+ to +Object+ instead of +self+.
81
85
 
82
- ##
83
- # Adds +an_alias+ to +Object+ instead of +self+.
86
+ def add_constant(constant)
87
+ object_class.record_location self
88
+ return constant unless @document_self
89
+ object_class.add_constant constant
90
+ end
84
91
 
85
- def add_alias(an_alias)
86
- object_class.record_location self
87
- return an_alias unless @document_self
88
- object_class.add_alias an_alias
89
- end
92
+ ##
93
+ # Adds +include+ to +Object+ instead of +self+.
90
94
 
91
- ##
92
- # Adds +constant+ to +Object+ instead of +self+.
95
+ def add_include(include)
96
+ object_class.record_location self
97
+ return include unless @document_self
98
+ object_class.add_include include
99
+ end
93
100
 
94
- def add_constant(constant)
95
- object_class.record_location self
96
- return constant unless @document_self
97
- object_class.add_constant constant
98
- end
101
+ ##
102
+ # Adds +method+ to +Object+ instead of +self+.
99
103
 
100
- ##
101
- # Adds +include+ to +Object+ instead of +self+.
104
+ def add_method(method)
105
+ object_class.record_location self
106
+ return method unless @document_self
107
+ object_class.add_method method
108
+ end
102
109
 
103
- def add_include(include)
104
- object_class.record_location self
105
- return include unless @document_self
106
- object_class.add_include include
107
- end
110
+ ##
111
+ # Adds class or module +mod+. Used in the building phase
112
+ # by the Ruby parser.
108
113
 
109
- ##
110
- # Adds +method+ to +Object+ instead of +self+.
114
+ def add_to_classes_or_modules(mod)
115
+ @classes_or_modules << mod
116
+ end
111
117
 
112
- def add_method(method)
113
- object_class.record_location self
114
- return method unless @document_self
115
- object_class.add_method method
116
- end
118
+ alias name base_name
117
119
 
118
- ##
119
- # Adds class or module +mod+. Used in the building phase
120
- # by the Ruby parser.
120
+ ##
121
+ # See RDoc::TopLevel::find_class_or_module
122
+ #--
123
+ # TODO Why do we search through all classes/modules found, not just the
124
+ # ones of this instance?
121
125
 
122
- def add_to_classes_or_modules(mod)
123
- @classes_or_modules << mod
124
- end
126
+ def find_class_or_module(name)
127
+ @store.find_class_or_module name
128
+ end
125
129
 
126
- alias name base_name
130
+ ##
131
+ # Finds a class or module named +symbol+
127
132
 
128
- ##
129
- # See RDoc::TopLevel::find_class_or_module
130
- #--
131
- # TODO Why do we search through all classes/modules found, not just the
132
- # ones of this instance?
133
+ def find_local_symbol(symbol)
134
+ find_class_or_module(symbol) || super
135
+ end
133
136
 
134
- def find_class_or_module(name)
135
- @store.find_class_or_module name
136
- end
137
+ ##
138
+ # Finds a module or class with +name+
137
139
 
138
- ##
139
- # Finds a class or module named +symbol+
140
+ def find_module_named(name)
141
+ find_class_or_module(name)
142
+ end
140
143
 
141
- def find_local_symbol(symbol)
142
- find_class_or_module(symbol) || super
143
- end
144
+ alias get_module_named find_module_named
144
145
 
145
- ##
146
- # Finds a module or class with +name+
146
+ ##
147
+ # Returns the relative name of this file
147
148
 
148
- def find_module_named(name)
149
- find_class_or_module(name)
150
- end
149
+ def full_name
150
+ @relative_name
151
+ end
151
152
 
152
- alias get_module_named find_module_named
153
+ ##
154
+ # An RDoc::TopLevel has the same hash as another with the same
155
+ # relative_name
153
156
 
154
- ##
155
- # Returns the relative name of this file
157
+ def hash
158
+ @relative_name.hash
159
+ end
156
160
 
157
- def full_name
158
- @relative_name
159
- end
161
+ ##
162
+ # URL for this with a +prefix+
160
163
 
161
- ##
162
- # An RDoc::TopLevel has the same hash as another with the same
163
- # relative_name
164
+ def http_url
165
+ @relative_name.tr('.', '_') + '.html'
166
+ end
164
167
 
165
- def hash
166
- @relative_name.hash
167
- end
168
+ def inspect # :nodoc:
169
+ "#<%s:0x%x %p modules: %p classes: %p>" % [
170
+ self.class, object_id,
171
+ base_name,
172
+ @modules.map { |n, m| m },
173
+ @classes.map { |n, c| c }
174
+ ]
175
+ end
168
176
 
169
- ##
170
- # URL for this with a +prefix+
177
+ ##
178
+ # Dumps this TopLevel for use by ri. See also #marshal_load
171
179
 
172
- def http_url
173
- @relative_name.tr('.', '_') + '.html'
174
- end
180
+ def marshal_dump
181
+ [
182
+ MARSHAL_VERSION,
183
+ @relative_name,
184
+ @parser,
185
+ parse(@comment),
186
+ ]
187
+ end
175
188
 
176
- def inspect # :nodoc:
177
- "#<%s:0x%x %p modules: %p classes: %p>" % [
178
- self.class, object_id,
179
- base_name,
180
- @modules.map { |n, m| m },
181
- @classes.map { |n, c| c }
182
- ]
183
- end
189
+ ##
190
+ # Loads this TopLevel from +array+.
184
191
 
185
- ##
186
- # Dumps this TopLevel for use by ri. See also #marshal_load
187
-
188
- def marshal_dump
189
- [
190
- MARSHAL_VERSION,
191
- @relative_name,
192
- @parser,
193
- parse(@comment),
194
- ]
195
- end
192
+ def marshal_load(array) # :nodoc:
193
+ initialize array[1]
196
194
 
197
- ##
198
- # Loads this TopLevel from +array+.
195
+ @parser = array[2]
196
+ @comment = Comment.from_document array[3]
197
+ end
199
198
 
200
- def marshal_load(array) # :nodoc:
201
- initialize array[1]
199
+ ##
200
+ # Returns the NormalClass "Object", creating it if not found.
201
+ #
202
+ # Records +self+ as a location in "Object".
203
+
204
+ def object_class
205
+ @object_class ||= begin
206
+ oc = @store.find_class_named('Object') || add_class(NormalClass, 'Object')
207
+ oc.record_location self
208
+ oc
209
+ end
210
+ end
202
211
 
203
- @parser = array[2]
204
- @comment = RDoc::Comment.from_document array[3]
205
- end
212
+ ##
213
+ # Path to this file for use with HTML generator output.
206
214
 
207
- ##
208
- # Returns the NormalClass "Object", creating it if not found.
209
- #
210
- # Records +self+ as a location in "Object".
211
-
212
- def object_class
213
- @object_class ||= begin
214
- oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
215
- oc.record_location self
216
- oc
215
+ def path
216
+ base = if options.main_page == full_name
217
+ 'index.html'
218
+ else
219
+ http_url
220
+ end
221
+
222
+ prefix = options.file_path_prefix
223
+ return base unless prefix
224
+ File.join(prefix, base)
217
225
  end
218
- end
219
226
 
220
- ##
221
- # Path to this file for use with HTML generator output.
222
-
223
- def path
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)
233
- end
227
+ def pretty_print(q) # :nodoc:
228
+ q.group 2, "[#{self.class}: ", "]" do
229
+ q.text "base name: #{base_name.inspect}"
230
+ q.breakable
234
231
 
235
- def pretty_print(q) # :nodoc:
236
- q.group 2, "[#{self.class}: ", "]" do
237
- q.text "base name: #{base_name.inspect}"
238
- q.breakable
232
+ items = @modules.map { |n, m| m }
233
+ items.concat @modules.map { |n, c| c }
234
+ q.seplist items do |mod| q.pp mod end
235
+ end
236
+ end
239
237
 
240
- items = @modules.map { |n, m| m }
241
- items.concat @modules.map { |n, c| c }
242
- q.seplist items do |mod| q.pp mod end
238
+ ##
239
+ # Search record used by RDoc::Generator::JsonIndex
240
+ #
241
+ # TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
242
+ # Use #search_snippet instead for getting documentation snippets.
243
+
244
+ def search_record
245
+ return unless @parser < Parser::Text
246
+
247
+ [
248
+ page_name,
249
+ '',
250
+ page_name,
251
+ '',
252
+ path,
253
+ '',
254
+ search_snippet,
255
+ ]
243
256
  end
244
- end
245
257
 
246
- ##
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.
251
-
252
- def search_record
253
- return unless @parser < RDoc::Parser::Text
254
-
255
- [
256
- page_name,
257
- '',
258
- page_name,
259
- '',
260
- path,
261
- '',
262
- search_snippet,
263
- ]
264
- end
258
+ ##
259
+ # Returns an HTML snippet of the comment for search results.
265
260
 
266
- ##
267
- # Returns an HTML snippet of the comment for search results.
261
+ def search_snippet
262
+ return '' if @comment.empty?
268
263
 
269
- def search_snippet
270
- return '' if @comment.empty?
264
+ snippet(@comment)
265
+ end
271
266
 
272
- snippet(@comment)
273
- end
267
+ ##
268
+ # Is this TopLevel from a text file instead of a source code file?
274
269
 
275
- ##
276
- # Is this TopLevel from a text file instead of a source code file?
270
+ def text?
271
+ @parser and @parser.include? Parser::Text
272
+ end
277
273
 
278
- def text?
279
- @parser and @parser.include? RDoc::Parser::Text
280
- end
274
+ def to_s # :nodoc:
275
+ "file #{full_name}"
276
+ end
281
277
 
282
- def to_s # :nodoc:
283
- "file #{full_name}"
284
278
  end
285
-
286
279
  end