зеркало из https://github.com/github/ruby.git
[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:
Родитель
a86d4eef4b
Коммит
3b0f952ec8
|
@ -145,12 +145,15 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|||
# +generator+ is used to create the page.
|
||||
|
||||
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
|
||||
res.body = generator.generate_class klass
|
||||
elsif page = store.find_text_page(name.sub(/_([^_]*)$/, '.\1')) then
|
||||
res.body = generator.generate_page page
|
||||
elsif page = store.find_text_page(text_name.sub(/_([^_]*)$/, '.\1')) then
|
||||
res.body = generator.generate_page page
|
||||
else
|
||||
not_found generator, req, res
|
||||
end
|
||||
|
|
|
@ -232,6 +232,18 @@ class TestRDocServlet < RDoc::TestCase
|
|||
assert_match %r%<body [^>]+ class="file">%, @res.body
|
||||
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
|
||||
store, path = @s.documentation_source '/ruby/Object.html'
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче