Skip to content

Commit 61aca89

Browse files
committed
Move Servlet under RDoc::RI
This class is used as a server for the ri command, not as a rdoc server. So putting it under RDoc::RI will make its purpose clearer.
1 parent 95b6cfb commit 61aca89

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ group :development do
1111
gem 'rubocop', '>= 1.31.0'
1212
gem 'gettext'
1313
gem 'prism', '>= 0.30.0'
14+
gem 'webrick'
1415
end

lib/rdoc.rb

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ def self.home
162162
autoload :Generator, "#{__dir__}/rdoc/generator"
163163
autoload :Options, "#{__dir__}/rdoc/options"
164164
autoload :Parser, "#{__dir__}/rdoc/parser"
165-
autoload :Servlet, "#{__dir__}/rdoc/servlet"
166165
autoload :RI, "#{__dir__}/rdoc/ri"
167166
autoload :Stats, "#{__dir__}/rdoc/stats"
168167
autoload :Store, "#{__dir__}/rdoc/store"

lib/rdoc/ri.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ module RDoc::RI
1313

1414
class Error < RDoc::Error; end
1515

16-
autoload :Driver, "#{__dir__}/ri/driver"
17-
autoload :Paths, "#{__dir__}/ri/paths"
18-
autoload :Store, "#{__dir__}/ri/store"
16+
autoload :Driver, "#{__dir__}/ri/driver"
17+
autoload :Paths, "#{__dir__}/ri/paths"
18+
autoload :Store, "#{__dir__}/ri/store"
19+
autoload :Servlet, "#{__dir__}/ri/servlet"
1920

2021
end

lib/rdoc/ri/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ def start_server
15061506

15071507
extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact
15081508

1509-
server.mount '/', RDoc::Servlet, nil, extra_doc_dirs
1509+
server.mount '/', RDoc::RI::Servlet, nil, extra_doc_dirs
15101510

15111511
trap 'INT' do server.shutdown end
15121512
trap 'TERM' do server.shutdown end

lib/rdoc/servlet.rb renamed to lib/rdoc/ri/servlet.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
2-
require_relative '../rdoc'
2+
require_relative '../../rdoc'
33
require 'erb'
44
require 'time'
55
require 'json'
@@ -24,14 +24,14 @@
2424
#
2525
# server = WEBrick::HTTPServer.new Port: 8000
2626
#
27-
# server.mount '/', RDoc::Servlet
27+
# server.mount '/', RDoc::RI::Servlet
2828
#
2929
# If you want to mount the servlet some other place than the root, provide the
3030
# base path when mounting:
3131
#
32-
# server.mount '/rdoc', RDoc::Servlet, '/rdoc'
32+
# server.mount '/rdoc', RDoc::RI::Servlet, '/rdoc'
3333

34-
class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
34+
class RDoc::RI::Servlet < WEBrick::HTTPServlet::AbstractServlet
3535

3636
@server_stores = Hash.new { |hash, server| hash[server] = {} }
3737
@cache = Hash.new { |hash, store| hash[store] = {} }
@@ -146,7 +146,7 @@ def do_GET req, res
146146
# Fills in +res+ with the class, module or page for +req+ from +store+.
147147
#
148148
# +path+ is relative to the mount_path and is used to determine the class,
149-
# module or page name (/RDoc/Servlet.html becomes RDoc::Servlet).
149+
# module or page name (/RDoc/RI.html becomes RDoc::RI).
150150
# +generator+ is used to create the page.
151151

152152
def documentation_page store, generator, path, req, res

rdoc.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
208208
"lib/rdoc/ri/paths.rb",
209209
"lib/rdoc/ri/store.rb",
210210
"lib/rdoc/ri/task.rb",
211+
"lib/rdoc/ri/servlet.rb",
211212
"lib/rdoc/rubygems_hook.rb",
212-
"lib/rdoc/servlet.rb",
213213
"lib/rdoc/single_class.rb",
214214
"lib/rdoc/stats.rb",
215215
"lib/rdoc/stats/normal.rb",

test/rdoc/test_rdoc_servlet.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def @server.mount(*) end
3030

3131
@extra_dirs = [File.join(@tempdir, 'extra1'), File.join(@tempdir, 'extra2')]
3232

33-
@s = RDoc::Servlet.new @server, @stores, @cache, nil, @extra_dirs
33+
@s = RDoc::RI::Servlet.new @server, @stores, @cache, nil, @extra_dirs
3434

3535
@req = WEBrick::HTTPRequest.new :Logger => nil
3636
@res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
@@ -141,7 +141,7 @@ def @req.path() raise 'no' end
141141
end
142142

143143
def test_do_GET_mount_path
144-
@s = RDoc::Servlet.new @server, @stores, @cache, '/mount/path'
144+
@s = RDoc::RI::Servlet.new @server, @stores, @cache, '/mount/path'
145145

146146
temp_dir do
147147
FileUtils.mkdir 'css'

0 commit comments

Comments
 (0)