[ruby/rdoc] Support nesting text page URL
RDoc::Servlet#documentation_page replaces "/" in URL with "::" for class or module but it's also used for the replaced name on text pages. This causes a bug when text pages are in nesting directory. This commit fixes #615. https://github.com/ruby/rdoc/commit/d73b915b1e
This commit is contained in:
parent
a86d4eef4b
commit
3b0f952ec8
@ -145,12 +145,15 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|||||||
# +generator+ is used to create the page.
|
# +generator+ is used to create the page.
|
||||||
|
|
||||||
def documentation_page store, generator, path, req, res
|
def documentation_page store, generator, path, req, res
|
||||||
name = path.sub(/.html$/, '').gsub '/', '::'
|
text_name = path.sub /.html$/, ''
|
||||||
|
name = text_name.gsub '/', '::'
|
||||||
|
|
||||||
if klass = store.find_class_or_module(name) then
|
if klass = store.find_class_or_module(name) then
|
||||||
res.body = generator.generate_class klass
|
res.body = generator.generate_class klass
|
||||||
elsif page = store.find_text_page(name.sub(/_([^_]*)$/, '.\1')) then
|
elsif page = store.find_text_page(name.sub(/_([^_]*)$/, '.\1')) then
|
||||||
res.body = generator.generate_page page
|
res.body = generator.generate_page page
|
||||||
|
elsif page = store.find_text_page(text_name.sub(/_([^_]*)$/, '.\1')) then
|
||||||
|
res.body = generator.generate_page page
|
||||||
else
|
else
|
||||||
not_found generator, req, res
|
not_found generator, req, res
|
||||||
end
|
end
|
||||||
|
@ -232,6 +232,18 @@ class TestRDocServlet < RDoc::TestCase
|
|||||||
assert_match %r%<body [^>]+ class="file">%, @res.body
|
assert_match %r%<body [^>]+ class="file">%, @res.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_documentation_page_page_with_nesting
|
||||||
|
store = RDoc::Store.new
|
||||||
|
|
||||||
|
generator = @s.generator_for store
|
||||||
|
|
||||||
|
readme = store.add_file 'nesting/README.rdoc', parser: RDoc::Parser::Simple
|
||||||
|
|
||||||
|
@s.documentation_page store, generator, 'nesting/README_rdoc.html', @req, @res
|
||||||
|
|
||||||
|
assert_equal 200, @res.status
|
||||||
|
end
|
||||||
|
|
||||||
def test_documentation_source
|
def test_documentation_source
|
||||||
store, path = @s.documentation_source '/ruby/Object.html'
|
store, path = @s.documentation_source '/ruby/Object.html'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user