Skip to content

Support nesting text page URL #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2019
Merged
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
5 changes: 4 additions & 1 deletion lib/rdoc/servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ def do_GET req, res
# +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
Expand Down
12 changes: 12 additions & 0 deletions test/test_rdoc_servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ def test_documentation_page_page
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'

Expand Down