[ruby/rdoc] Deprecate main
and title
directives
(https://github.com/ruby/rdoc/pull/1218) * Deprecate :main: directive * Deprecate :title: direcive * Update documentation * Remove :main: directive's usage * Update test cases * Add '.rdoc_options' to suggested alternatives https://github.com/ruby/rdoc/commit/e2d4ac9dad
This commit is contained in:
parent
866f1a1f2d
commit
2ecd2fe0ed
@ -535,17 +535,6 @@ require 'rdoc'
|
|||||||
# parameter +type+ is one of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
|
# parameter +type+ is one of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
|
||||||
# See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
|
# See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
|
||||||
#
|
#
|
||||||
# ===== Directives for HTML Output
|
|
||||||
#
|
|
||||||
# - <tt># :title: _text_</tt>:
|
|
||||||
#
|
|
||||||
# - Appears on a line by itself.
|
|
||||||
# - Specifies the title for the HTML output.
|
|
||||||
#
|
|
||||||
# - <tt># :main: _filename_</tt>:
|
|
||||||
# - Appears on a line by itself.
|
|
||||||
# - Specifies the HTML file to be displayed first.
|
|
||||||
#
|
|
||||||
# ===== Directives for Method Documentation
|
# ===== Directives for Method Documentation
|
||||||
#
|
#
|
||||||
# - <tt># :call-seq:</tt>:
|
# - <tt># :call-seq:</tt>:
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
$DEBUG_RDOC = nil
|
$DEBUG_RDOC = nil
|
||||||
|
|
||||||
# :main: README.rdoc
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# RDoc produces documentation for Ruby source files by parsing the source and
|
# RDoc produces documentation for Ruby source files by parsing the source and
|
||||||
# extracting the definition for classes, modules, methods, includes and
|
# extracting the definition for classes, modules, methods, includes and
|
||||||
|
@ -187,6 +187,14 @@ class RDoc::Markup::PreProcess
|
|||||||
include_file filename, prefix, encoding
|
include_file filename, prefix, encoding
|
||||||
when 'main' then
|
when 'main' then
|
||||||
@options.main_page = param if @options.respond_to? :main_page
|
@options.main_page = param if @options.respond_to? :main_page
|
||||||
|
warn <<~MSG
|
||||||
|
The :main: directive is deprecated and will be removed in RDoc 7.
|
||||||
|
|
||||||
|
You can use these options to specify the initial page displayed instead:
|
||||||
|
- `--main=#{param}` via the command line
|
||||||
|
- `rdoc.main = "#{param}"` if you use `RDoc::Task`
|
||||||
|
- `main_page: #{param}` in your `.rdoc_options` file
|
||||||
|
MSG
|
||||||
|
|
||||||
blankline
|
blankline
|
||||||
when 'nodoc' then
|
when 'nodoc' then
|
||||||
@ -217,6 +225,15 @@ class RDoc::Markup::PreProcess
|
|||||||
when 'title' then
|
when 'title' then
|
||||||
@options.default_title = param if @options.respond_to? :default_title=
|
@options.default_title = param if @options.respond_to? :default_title=
|
||||||
|
|
||||||
|
warn <<~MSG
|
||||||
|
The :title: directive is deprecated and will be removed in RDoc 7.
|
||||||
|
|
||||||
|
You can use these options to specify the title displayed instead:
|
||||||
|
- `--title=#{param}` via the command line
|
||||||
|
- `rdoc.title = "#{param}"` if you use `RDoc::Task`
|
||||||
|
- `title: #{param}` in your `.rdoc_options` file
|
||||||
|
MSG
|
||||||
|
|
||||||
blankline
|
blankline
|
||||||
when 'yield', 'yields' then
|
when 'yield', 'yields' then
|
||||||
return blankline unless code_object
|
return blankline unless code_object
|
||||||
|
@ -1097,15 +1097,34 @@ class RDoc::Parser::C < RDoc::Parser
|
|||||||
# */
|
# */
|
||||||
#
|
#
|
||||||
# This method modifies the +comment+
|
# This method modifies the +comment+
|
||||||
|
# Both :main: and :title: directives are deprecated and will be removed in RDoc 7.
|
||||||
|
|
||||||
def look_for_directives_in context, comment
|
def look_for_directives_in context, comment
|
||||||
@preprocess.handle comment, context do |directive, param|
|
@preprocess.handle comment, context do |directive, param|
|
||||||
case directive
|
case directive
|
||||||
when 'main' then
|
when 'main' then
|
||||||
@options.main_page = param
|
@options.main_page = param
|
||||||
|
|
||||||
|
warn <<~MSG
|
||||||
|
The :main: directive is deprecated and will be removed in RDoc 7.
|
||||||
|
|
||||||
|
You can use these options to specify the initial page displayed instead:
|
||||||
|
- `--main=#{param}` via the command line
|
||||||
|
- `rdoc.main = "#{param}"` if you use `RDoc::Task`
|
||||||
|
- `main_page: #{param}` in your `.rdoc_options` file
|
||||||
|
MSG
|
||||||
''
|
''
|
||||||
when 'title' then
|
when 'title' then
|
||||||
@options.default_title = param if @options.respond_to? :default_title=
|
@options.default_title = param if @options.respond_to? :default_title=
|
||||||
|
|
||||||
|
warn <<~MSG
|
||||||
|
The :title: directive is deprecated and will be removed in RDoc 7.
|
||||||
|
|
||||||
|
You can use these options to specify the title displayed instead:
|
||||||
|
- `--title=#{param}` via the command line
|
||||||
|
- `rdoc.title = "#{param}"` if you use `RDoc::Task`
|
||||||
|
- `title: #{param}` in your `.rdoc_options` file
|
||||||
|
MSG
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -407,6 +407,7 @@ The internal error was:
|
|||||||
|
|
||||||
return [] if file_list.empty?
|
return [] if file_list.empty?
|
||||||
|
|
||||||
|
# This workaround can be removed after the :main: directive is removed
|
||||||
original_options = @options.dup
|
original_options = @options.dup
|
||||||
@stats.begin_adding
|
@stats.begin_adding
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
class TestRDocMarkupPreProcess < RDoc::TestCase
|
class RDoc::Markup::PreProcessTest < RDoc::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@ -85,18 +85,26 @@ contents of a string.
|
|||||||
|
|
||||||
def test_handle
|
def test_handle
|
||||||
text = "# :main: M\n"
|
text = "# :main: M\n"
|
||||||
out = @pp.handle text
|
output = nil
|
||||||
|
_, err = capture_output do
|
||||||
|
output = @pp.handle text
|
||||||
|
end
|
||||||
|
|
||||||
assert_equal "#\n", out
|
assert_include err, "The :main: directive is deprecated and will be removed in RDoc 7."
|
||||||
|
assert_equal "#\n", output
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_handle_comment
|
def test_handle_comment
|
||||||
text = "# :main: M\n"
|
text = "# :main: M\n"
|
||||||
c = comment text
|
c = comment text
|
||||||
|
|
||||||
out = @pp.handle c
|
output = nil
|
||||||
|
_, err = capture_output do
|
||||||
|
output = @pp.handle c
|
||||||
|
end
|
||||||
|
|
||||||
assert_equal "#\n", out
|
assert_include err, "The :main: directive is deprecated and will be removed in RDoc 7."
|
||||||
|
assert_equal "#\n", output
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_handle_markup
|
def test_handle_markup
|
||||||
@ -245,8 +253,11 @@ contents of a string.
|
|||||||
def test_handle_directive_main
|
def test_handle_directive_main
|
||||||
@pp.options = RDoc::Options.new
|
@pp.options = RDoc::Options.new
|
||||||
|
|
||||||
@pp.handle_directive '', 'main', 'M'
|
_, err = capture_output do
|
||||||
|
@pp.handle_directive '', 'main', 'M'
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_include err, "The :main: directive is deprecated and will be removed in RDoc 7."
|
||||||
assert_equal 'M', @pp.options.main_page
|
assert_equal 'M', @pp.options.main_page
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -385,8 +396,11 @@ contents of a string.
|
|||||||
def test_handle_directive_title
|
def test_handle_directive_title
|
||||||
@pp.options = RDoc::Options.new
|
@pp.options = RDoc::Options.new
|
||||||
|
|
||||||
@pp.handle_directive '', 'title', 'T'
|
_, err = capture_output do
|
||||||
|
@pp.handle_directive '', 'title', 'T'
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_include err, "The :title: directive is deprecated and will be removed in RDoc 7."
|
||||||
assert_equal 'T', @pp.options.title
|
assert_equal 'T', @pp.options.title
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user