Skip to content

Share Aliki class navigation across generated pages - #1840

Open
skatkov wants to merge 11 commits into
ruby:masterfrom
skatkov:shared-class-navigation
Open

skatkov wants to merge 11 commits into
ruby:masterfrom
skatkov:shared-class-navigation

Conversation

@skatkov

@skatkov skatkov commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Aliki currently rebuilds and embeds the complete class/module navigation tree in every generated page.

My build servers can't handle google-api-gem generation, they always time out. I tried running it locally, and it was running for ~5 hours and never finished. By the time I got annoyed and stopped, the generation folder had 234GB of data.

Every HTML page was ~6 MB in size.

Solution

We can have a shared navigation section shared across all documentation pages. That would remove 97% of data from every page in case of google-api-gem.

We already have search_data.index file, which could be used to reconstruct navigation section with JavaScript.

Results

After implementing these changes, I've seen the following results for google-api-gem gem.

  • Entire gem generation completed in 5m 46s
  • Output size is 712 MiB
  • Single page size 160 KB (97.5% smaller)

For other gems, that are not that extremely big in contents, performance savings are more modest.

Version Median generation time Median full run
RDoc 8.1.0 6.49 s 7.31 s
Current branch 6.27 s 7.12 s

The current branch generated the site about 0.22 s faster (~3.4%) for rdoc's source code.

Generate one navigation data file and lazily render namespace branches.
Keep a static class index for crawlability and offline fallback, and refresh
navigation data with live-preview changes.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0ea31-9f66-7342-a269-34772e5428db
Co-authored-by: Stanislav Katkov <krooni@skatkov.com>
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: 362a3ef

@skatkov
skatkov marked this pull request as ready for review September 29, 2026 11:09
Copilot AI balanced review requested due to automatic review settings September 29, 2026 11:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

</summary>

<%= generate_class_index_content(@classes, rel_prefix) %>
<ul id="class-navigation" class="link-list nav-list"></ul>

@skatkov skatkov Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darkfish generator had a id='navigation' element, so I decided not to risk any possible collisions and call this class-navigation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be any risk of collisions here as darkfish & aliki templates should never be rendered together. I'd prefer using clear naming unless we found in some cases there's a collision, but that'd be a separate bug to fix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, let's use namespace-navigation for this id instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍🏻

@st0012 st0012 added the bug label Sep 29, 2026
Copilot AI review requested due to automatic review settings September 29, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread test/rdoc/rdoc_server_test.rb Outdated
assert_equal 'text/html', content_type
end

def test_search_data_refreshes_after_file_changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this test needed for the changes made here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to ensure that the search index is getting properly refreshed locally if the server is running (e.g. so navigation will be updated as well). I have removed it.

return
end

class RDocGeneratorAlikiNavigationTest < Test::Unit::TestCase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel these tests are providing much value as they target very specific implementation behaviour.
I know we don't have browser e2e tests as a better alternative now, but I'd rather not adding these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I removed it

</span>
</summary>

<%= generate_class_index_content(@classes, rel_prefix) %>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this method still be needed?

@skatkov skatkov Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is still used in the Darkfish generator.

The Darkfish generator has same problem as well as Aliki. But because Darkfish is already deprecated, I assume there is no need to do similar changes to Darkfish.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants