Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/rdoc/markup/to_html_crossref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ def link(name, text, code = true, rdoc_ref: false)

ref = @cross_reference.resolve name, text if name

# Non-text source files (C, Ruby, etc.) don't get HTML pages generated,
# so don't auto-link to them. Explicit rdoc-ref: links are still allowed.
if !rdoc_ref && RDoc::TopLevel === ref && !ref.text?
return text
end

case ref
when String then
if rdoc_ref && @warn_missing_rdoc_ref
Expand Down
19 changes: 19 additions & 0 deletions test/rdoc/markup/to_html_crossref_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,25 @@ def test_to_html_CROSSREF_email_hyperlink_all
assert_equal 'first.last@example.com', result
end

def test_convert_CROSSREF_c_file_not_autolinked
# C files are not text files, so they don't get HTML pages generated.
# Auto cross-references to them should not produce links.
c_file = @store.add_file 'array.c'
c_file.parser = RDoc::Parser::C

result = @to.convert 'array.c'
assert_equal para("array.c"), result
end

def test_convert_RDOCLINK_rdoc_ref_c_file_linked
# Explicit rdoc-ref: links to non-text files should still work.
c_file = @store.add_file 'array.c'
c_file.parser = RDoc::Parser::C

result = @to.convert 'rdoc-ref:array.c'
assert_equal para("<a href=\"array_c.html\">array.c</a>"), result
end

def test_link
assert_equal 'n', @to.link('n', 'n')

Expand Down
Loading