Skip to content

[pull] master from ruby:master#161

Merged
pull[bot] merged 2 commits intosysfce2:masterfrom
ruby:master
Mar 14, 2026
Merged

[pull] master from ruby:master#161
pull[bot] merged 2 commits intosysfce2:masterfrom
ruby:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Mar 14, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

st0012 and others added 2 commits March 14, 2026 19:05
## Summary
- Remove `class_attributes` and `instance_attributes` methods (zero
callers)
- Remove obsolete `instance_method_list` method (deprecated wrapper)
- Remove memoization from `class_method_list` and `instance_methods` —
these are only called once per class/module during generation, so
caching adds no benefit
A better attempt of #1151

Implement `rdoc --server[=PORT]` for previewing documentation with
automatic browser refresh on source file changes. The server parses all
sources on startup, serves pages from memory via the Aliki generator,
and watches for file modifications, additions, and deletions —
re-parsing only what changed.


https://github.com/user-attachments/assets/06d5ae7b-cc54-4cc5-a8b0-1cc30177cadb


## Changes

- **New `RDoc::Server`** (`lib/rdoc/server.rb`) — minimal HTTP server
using Ruby's built-in `TCPServer` (no WEBrick or external dependencies)
  - Thread-per-connection with `Connection: close`
  - Persistent Aliki generator instance rendering pages to strings
  - In-memory page cache with full invalidation on changes
- Live reload via inline JS polling `/__status` endpoint every 1 second
  - Background file watcher polling source file mtimes every 1 second
- Incremental re-parse: only changed files are re-parsed, old data
removed first
  - Detection of new and deleted source files
- **`--server[=PORT]`** CLI option (default port 4000) and `rdoc:server`
Rake task
- **`RDoc::Store#remove_file`** — removes a file's entries from the
store hashes
- **`RDoc::Store#clear_file_contributions`** — surgically removes a
file's methods, constants, comments, includes, extends, and aliases from
its classes/modules, preserving classes that span multiple files.
Supports `keep_position:` for server re-parse to preserve comment
ordering.
- **`RDoc::RDoc#relative_path_for`** — extracted path normalization
(against `options.root` and `options.page_dir`) shared by `parse_file`
and the server
- **`Darkfish#refresh_store_data`** — extracted for reuse by the server
after re-parsing
- **`RDoc::Servlet` → `RDoc::RI::Servlet`** — moved to clarify
RI-specific usage

## Security & robustness

- Binds to `127.0.0.1` only (localhost)
- Path traversal protection in asset serving (`File.expand_path`
containment check)
- Proper HTTP error responses: 400, 404, 405, 500
- 5-second `IO.select` read timeout on client sockets
- Mutex protects all store mutations, generator refresh, and cache
invalidation atomically
- Individual `parse_file` errors rescued so one failure doesn't block
remaining files
- Watcher thread uses `@running` flag with clean shutdown via
`Thread#join`

## Known limitations

- **Full cache invalidation:** any file change clears all cached pages.
Rendering is fast (~ms per page); parsing is the expensive part and is
done incrementally.
- **Template/CSS changes:** require server restart (only source files
are watched).

---------

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
@pull pull Bot locked and limited conversation to collaborators Mar 14, 2026
@pull pull Bot added the ⤵️ pull label Mar 14, 2026
@pull pull Bot merged commit 3c6f5f6 into sysfce2:master Mar 14, 2026
7 of 8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant