Class: Website

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

Overview

Multi-version documentation website builder.

Projects need documentation for multiple versions. Users on v0.5 read v0.5 docs. Users on trunk preview upcoming changes. Building this manually is tedious and error-prone.

This class orchestrates the entire build: discovers versions, generates docs for each, creates the landing page, and injects version menus.

Use it to build a complete documentation portal.

Instance Method Summary collapse

Constructor Details

#initialize(at: "www", project_name:, globs:, assets: [], branding: {}) ⇒ Website

Creates a Website builder.

at

Output directory (default: www).

project_name

Project name for page titles.

globs

File patterns to document.

assets

Optional directories to copy into each version’s output.

branding

Optional hash of branding overrides for the index template.



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

def initialize(at: "www", project_name:, globs:, assets: [], branding: {})
  @destination = at
  @project_name = project_name
  @globs = globs
  @assets = assets
  @branding = branding
end

Instance Method Details

#buildObject

Builds the complete documentation website.

Cleans the output directory, generates docs for all versions, creates the landing page, and injects version menus.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ratatui_ruby/devtools/tasks/website/website.rb', line 44

def build
  clean

  versions.each do |version|
    VersionedDocumentation.new(version).publish_to(
      join(version.slug),
      project_name: @project_name,
      globs: @globs,
      assets: @assets
    )
  end

  IndexPage.new(versions, branding: @branding).publish_to(join("index.html"), project_name: @project_name)

  VersionMenu.new(root: @destination, versions:).run

  puts "Website built in #{@destination}/"
end

#versionsObject

Discovered versions for this build.

Cached after first call. Includes Edge plus latest patch per minor.



66
67
68
# File 'lib/ratatui_ruby/devtools/tasks/website/website.rb', line 66

def versions
  @versions ||= Version.all
end