Skip to content

Commit f40b01d

Browse files
committed
Remove :main: and :title: directives
These directives have been deprecated since RDoc 6. The same functionality is available via --main/--title CLI options, RDoc::Task attributes, and .rdoc_options.
1 parent 3bb10a6 commit f40b01d

2 files changed

Lines changed: 14 additions & 47 deletions

File tree

lib/rdoc/markup/pre_process.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,6 @@ def handle_directive(prefix, directive, param, code_object = nil,
209209
when 'include' then
210210
filename = param.split(' ', 2).first
211211
include_file filename, prefix, encoding
212-
when 'main' then
213-
@options.main_page = param if @options.respond_to? :main_page
214-
warn <<~MSG
215-
The :main: directive is deprecated and will be removed in RDoc 7.
216-
217-
You can use these options to specify the initial page displayed instead:
218-
- `--main=#{param}` via the command line
219-
- `rdoc.main = "#{param}"` if you use `RDoc::Task`
220-
- `main_page: #{param}` in your `.rdoc_options` file
221-
MSG
222-
223-
blankline
224212
when 'nodoc' then
225213
return blankline unless code_object
226214
code_object.document_self = nil # notify nodoc
@@ -245,19 +233,6 @@ def handle_directive(prefix, directive, param, code_object = nil,
245233

246234
code_object.stop_doc
247235

248-
blankline
249-
when 'title' then
250-
@options.default_title = param if @options.respond_to? :default_title=
251-
252-
warn <<~MSG
253-
The :title: directive is deprecated and will be removed in RDoc 7.
254-
255-
You can use these options to specify the title displayed instead:
256-
- `--title=#{param}` via the command line
257-
- `rdoc.title = "#{param}"` if you use `RDoc::Task`
258-
- `title: #{param}` in your `.rdoc_options` file
259-
MSG
260-
261236
blankline
262237
when 'yield', 'yields' then
263238
return blankline unless code_object

test/rdoc/markup/pre_process_test.rb

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,20 @@ def test_include_file_in_other_directory
8484
end
8585

8686
def test_handle
87-
text = "# :main: M\n"
88-
output = nil
89-
_, err = capture_output do
90-
output = @pp.handle text
91-
end
87+
text = "# :stopdoc:\n"
88+
code_object = RDoc::CodeObject.new
89+
output = @pp.handle text, code_object
9290

93-
assert_include err, "The :main: directive is deprecated and will be removed in RDoc 7."
9491
assert_equal "#\n", output
9592
end
9693

9794
def test_handle_comment
98-
text = "# :main: M\n"
95+
text = "# :stopdoc:\n"
9996
c = comment text
97+
code_object = RDoc::CodeObject.new
10098

101-
output = nil
102-
_, err = capture_output do
103-
output = @pp.handle c
104-
end
99+
output = @pp.handle c, code_object
105100

106-
assert_include err, "The :main: directive is deprecated and will be removed in RDoc 7."
107101
assert_equal "#\n", output
108102
end
109103

@@ -253,12 +247,11 @@ def test_handle_directive_include
253247
def test_handle_directive_main
254248
@pp.options = RDoc::Options.new
255249

256-
_, err = capture_output do
257-
@pp.handle_directive '', 'main', 'M'
258-
end
250+
# :main: directive was removed; it is now treated as unhandled metadata
251+
code_object = RDoc::CodeObject.new
252+
@pp.handle_directive '', 'main', 'M', code_object
259253

260-
assert_include err, "The :main: directive is deprecated and will be removed in RDoc 7."
261-
assert_equal 'M', @pp.options.main_page
254+
assert_equal 'M', code_object.metadata['main']
262255
end
263256

264257
def test_handle_directive_notnew
@@ -396,12 +389,11 @@ def test_handle_directive_stopdoc
396389
def test_handle_directive_title
397390
@pp.options = RDoc::Options.new
398391

399-
_, err = capture_output do
400-
@pp.handle_directive '', 'title', 'T'
401-
end
392+
# :title: directive was removed; it is now treated as unhandled metadata
393+
code_object = RDoc::CodeObject.new
394+
@pp.handle_directive '', 'title', 'T', code_object
402395

403-
assert_include err, "The :title: directive is deprecated and will be removed in RDoc 7."
404-
assert_equal 'T', @pp.options.title
396+
assert_equal 'T', code_object.metadata['title']
405397
end
406398

407399
def test_handle_directive_unhandled

0 commit comments

Comments
 (0)