You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace WEBrick servlet with minimal TCPServer-based implementation
Drop the webrick dependency by rewriting RDoc::Server to use Ruby's
built-in TCPServer. The new implementation handles HTTP directly with
thread-per-connection, simplifies the start/shutdown lifecycle, and
keeps all existing functionality (live reload, file watching, caching).
8.**Stop server**: Kill the HTTP server process when done
334
362
335
-
**Tip:**Keep HTTP server running during iteration. Just regenerate with `bundle exec rake rerdoc` between changes.
363
+
**Note:**The server watches source files, not template files. If you modify `.rhtml` templates or CSS in the template directory, restart the server to pick up those changes.
336
364
337
365
## Notes for AI Agents
338
366
@@ -386,23 +414,27 @@ Restart Claude Code after running these commands.
386
414
387
415
### Testing Generated Documentation
388
416
389
-
To test the generated documentation:
417
+
The easiest way to test documentation is with the live-reloading server:
390
418
391
419
```bash
392
-
# Generate documentation
393
-
bundle exec rake rerdoc
420
+
bundle exec rdoc --server
421
+
# Or: bundle exec rake rdoc:server
422
+
```
423
+
424
+
This starts a server at `http://localhost:4000` that auto-refreshes on file changes.
425
+
426
+
Alternatively, for testing static output:
394
427
395
-
# Start a simple HTTP server in the _site directory (use an available port)
428
+
```bash
429
+
bundle exec rake rerdoc
396
430
cd _site && python3 -m http.server 8000
397
431
```
398
432
399
-
If port 8000 is already in use, try another port (e.g., `python3 -m http.server 9000`).
400
-
401
433
Then ask the AI assistant to inspect the documentation. It will use the appropriate Playwright tools (`browser_navigate`, `browser_snapshot`, `browser_take_screenshot`, etc.) based on your request.
402
434
403
435
**Example requests:**
404
436
405
-
- "Navigate to `http://localhost:8000` and take a screenshot"
437
+
- "Navigate to `http://localhost:4000` and take a screenshot"
406
438
- "Take a screenshot of the RDoc module page"
407
439
- "Check if code blocks are rendering properly on the Markup page"
408
440
- "Compare the index page before and after my CSS changes"
Copy file name to clipboardExpand all lines: README.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,6 +180,41 @@ There are also a few community-maintained themes for RDoc:
180
180
181
181
Please follow the theme's README for usage instructions.
182
182
183
+
## Live Preview Server
184
+
185
+
RDoc includes a built-in server for previewing documentation while you edit source files. It parses your code once on startup, then watches for changes and auto-refreshes the browser.
186
+
187
+
```shell
188
+
rdoc --server
189
+
```
190
+
191
+
This starts a server at `http://localhost:4000`. You can specify a different port:
192
+
193
+
```shell
194
+
rdoc --server=8080
195
+
```
196
+
197
+
Or use the Rake task:
198
+
199
+
```shell
200
+
rake rdoc:server
201
+
```
202
+
203
+
### How It Works
204
+
205
+
- Parses all source files on startup and serves pages from memory using the Aliki theme
206
+
- A background thread polls file mtimes every second
207
+
- When a file changes, only that file is re-parsed — the browser refreshes automatically
208
+
- New files are detected and added; deleted files are removed
209
+
210
+
**No external dependencies.** The server uses Ruby's built-in `TCPServer` (`socket` stdlib) — no WEBrick or other gems required.
211
+
212
+
### Limitations
213
+
214
+
-**Reopened classes and file deletion.** If a class is defined across multiple files (e.g. `Foo` in both `a.rb` and `b.rb`), deleting one file removes the entire class from the store, including parts from the other file. Saving the remaining file triggers a re-parse that restores it.
215
+
-**Full cache invalidation.** Any file change clears all cached pages. This is simple and correct — rendering is fast (~ms per page), parsing is the expensive part and is done incrementally.
216
+
-**No HTTPS or HTTP/2.** The server is intended for local development preview only.
217
+
183
218
## Bugs
184
219
185
220
See [CONTRIBUTING.md](CONTRIBUTING.md) for information on filing a bug report. It's OK to file a bug report for anything you're having a problem with. If you can't figure out how to make RDoc produce the output you like that is probably a documentation bug.
0 commit comments