Repository navigation
Conversation
Documentation previewCommit: |
f72aa6c to
ed35b99
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Pages sidebar caching change.
No open issues 🎉
What changed in this PR
This follow-up to #1840 reduces repeated rendering in Aliki by reusing the Pages sidebar across static class pages with the same relative link prefix.
Changes:
- Cache rendered Pages sidebars during class generation and clear the cache afterward.
- Preserve uncached rendering outside that pass, including live preview.
- Add assertions verifying sidebar links for top-level and nested classes.
| File | Description |
|---|---|
test/rdoc/generator/aliki_test.rb |
Checks relative README links at two class nesting depths. |
lib/rdoc/generator/template/aliki/class.rhtml |
Uses the cached sidebar when available, otherwise renders it normally. |
lib/rdoc/generator/aliki.rb |
Adds a prefix-keyed cache scoped to class generation, with guaranteed cleanup. |
Review effort: Balanced
Currently two of my PRs are affected by this issue, see #1894 and #1895. The TruffleRuby job on macOS can fail if the preview server’s health check runs before the server starts listening. TruffleRuby 40.0.0 can return an unconnected socket instead of raising `ECONNREFUSED`, causing `Net::HTTP` to raise `EINVAL` when it sets `TCP_NODELAY`. See [TruffleRuby #4510](truffleruby/truffleruby#4510).
| def generate_class_files | ||
| @pages_sidebar_by_prefix = Hash.new { |cache, prefix| cache[prefix] = render('_sidebar_pages.rhtml') } | ||
| super | ||
| ensure |
There was a problem hiding this comment.
I have added a test that uses it.
In short: if rendering raises and the caller reuses the generator, a subsequent generate_class call can serve stale sidebar HTML.
There was a problem hiding this comment.
🟡 Changes recommended
The added assertions verify links and cache cleanup, but not sidebar reuse across class pages sharing a prefix. Removing the cache would still pass them, leaving the intended reuse behavior unprotected against regressions.
1 open issue
Review effort: Balanced
|
|
||
| #: () -> void | ||
| def generate_class_files | ||
| @pages_sidebar_by_prefix = Hash.new { |cache, prefix| cache[prefix] = render('_sidebar_pages.rhtml') } |

It’s a follow-up to #1840
Aliki renders the same Pages sidebar for every class page. During static class generation, reuse the rendered sidebar for pages that share the same relative link prefix. The cache is cleared after the class-rendering pass, and text pages and live preview keep their existing behavior.
Bigger the gem (in terms of class count) - the better the improvement.
The benchmark used Ruby 3.4.5 and compared the patch against RDoc master at 41e425b.