Class: VersionMenu

Inherits:
Object
  • Object
show all
Defined in:
lib/ratatui_ruby/devtools/tasks/website/version_menu.rb

Overview

Version switcher for generated documentation pages.

Multi-version docs need navigation between versions. Users viewing v0.5 docs want to switch to v0.6. Without a switcher, they’d need to navigate back to the portal.

This class injects a dropdown menu into every generated HTML page. It calculates relative paths so links work from any nesting depth.

Use it after generating all version documentation.

Instance Method Summary collapse

Constructor Details

#initialize(root:, versions:) ⇒ VersionMenu

Creates a VersionMenu.

root

Root directory of the generated site.

versions

Array of Version objects for the dropdown.



23
24
25
26
# File 'lib/ratatui_ruby/devtools/tasks/website/version_menu.rb', line 23

def initialize(root:, versions:)
  @root = root
  @versions = versions
end

Instance Method Details

#runObject

Injects the version dropdown into all HTML files.

Finds the theme toggle button and inserts the menu before it.



31
32
33
34
35
36
37
38
# File 'lib/ratatui_ruby/devtools/tasks/website/version_menu.rb', line 31

def run
  puts "Injecting version menu into generated HTML..."

  # Process all HTML files in the output directory
  Dir.glob(File.join(@root, "**/*.html")).each do |file|
    inject_menu(file)
  end
end