[ruby/rdoc] Print warnings for rdoc-ref links that can't be resolved

(https://github.com/ruby/rdoc/pull/1241)

4a5206ae56
This commit is contained in:
Stan Lo 2024-12-17 03:34:56 +08:00 committed by git
parent 80b8feb929
commit a6fd6cb72f
4 changed files with 80 additions and 34 deletions

View file

@ -1,12 +1,13 @@
# frozen_string_literal: true
require_relative 'xref_test_case'
class TestRDocMarkupToHtmlCrossref < XrefTestCase
class RDocMarkupToHtmlCrossrefTest < XrefTestCase
def setup
super
@options.hyperlink_all = true
@options.warn_missing_rdoc_ref = true
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'index.html', @c1
end
@ -67,6 +68,16 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
assert_equal para("<a href=\"C1.html\"><code>C1</code></a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_not_found
result = nil
stdout, _ = capture_output do
result = @to.convert 'rdoc-ref:FOO'
end
assert_equal para("FOO"), result
assert_include stdout, "index.html: `rdoc-ref:FOO` can't be resolved for `FOO`"
end
def test_convert_RDOCLINK_rdoc_ref_method
result = @to.convert 'rdoc-ref:C1#m'
@ -153,6 +164,14 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
@to.gen_url('http://example', 'HTTP example')
end
def test_gen_url_rdoc_ref_not_found
stdout, _ = capture_output do
@to.gen_url 'rdoc-ref:FOO', 'FOO'
end
assert_include stdout, "index.html: `rdoc-ref:FOO` can't be resolved for `FOO`"
end
def test_handle_regexp_CROSSREF
assert_equal "<a href=\"C2/C3.html\"><code>C2::C3</code></a>", REGEXP_HANDLING('C2::C3')
end