Class: RDoc::Server
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | lib/rdoc/server.rb |
Overview
A minimal HTTP server for live-reloading RDoc documentation.
Uses Ruby's built-in TCPServer (no external dependencies).
Used by rdoc --server to let developers preview documentation while editing source files. Parses sources once on startup, watches for file changes, re-parses only the changed files, and auto-refreshes the browser via a simple polling script.
Constant Summary
-
CONTENT_TYPES =
# File 'lib/rdoc/server.rb', line 43{ '.html' => 'text/html', '.css' => 'text/css', '.js' => 'application/javascript', '.json' => 'application/json', }.freeze -
STATUS_TEXTS =
# File 'lib/rdoc/server.rb', line 50{ 200 => 'OK', 400 => 'Bad Request', 404 => 'Not Found', 405 => 'Method Not Allowed', 500 => 'Internal Server Error', }.freeze
Class Method Summary
-
.live_reload_script(last_change_time)
Returns a live-reload polling script with the given
last_change_timeembedded so the browser knows the exact timestamp of the content it received. -
.new(rdoc, port) ⇒ Server
constructor
Creates a new server.
Instance Method Summary
-
#start
Starts the server.
-
#check_for_changes
private
Checks for modified, new, and deleted files.
- #create_generator private
- #current_watch_files private
- #file_changed?(file) ⇒ Boolean private
- #file_mtimes_for(files) private
-
#generate_page(name)
private
Dispatches to the appropriate generator method based on the page name.
-
#handle_client(client)
private
Reads an HTTP request from
clientand dispatches to the router. -
#inject_live_reload(html, last_change_time)
private
Injects the live-reload polling script before