ratatui_ruby 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/ratatui_ruby/Cargo.lock +1 -1
- data/ext/ratatui_ruby/Cargo.toml +1 -1
- data/lib/ratatui_ruby/version.rb +1 -1
- metadata +1 -255
- data/.builds/ruby-3.2.yml +0 -54
- data/.builds/ruby-3.3.yml +0 -54
- data/.builds/ruby-3.4.yml +0 -54
- data/.builds/ruby-4.0.0.yml +0 -54
- data/.pre-commit-config.yaml +0 -16
- data/.rubocop.yml +0 -10
- data/AGENTS.md +0 -147
- data/CHANGELOG.md +0 -736
- data/README.md +0 -187
- data/README.rdoc +0 -302
- data/Rakefile +0 -11
- data/Steepfile +0 -50
- data/doc/concepts/application_architecture.md +0 -321
- data/doc/concepts/application_testing.md +0 -193
- data/doc/concepts/async.md +0 -190
- data/doc/concepts/custom_widgets.md +0 -247
- data/doc/concepts/debugging.md +0 -401
- data/doc/concepts/event_handling.md +0 -162
- data/doc/concepts/interactive_design.md +0 -146
- data/doc/contributors/auditing/parity.md +0 -239
- data/doc/contributors/design/ruby_frontend.md +0 -448
- data/doc/contributors/design/rust_backend.md +0 -434
- data/doc/contributors/design.md +0 -11
- data/doc/contributors/developing_examples.md +0 -400
- data/doc/contributors/documentation_style.md +0 -121
- data/doc/contributors/index.md +0 -21
- data/doc/contributors/releasing.md +0 -215
- data/doc/contributors/todo/align/api_completeness_audit-finished.md +0 -381
- data/doc/contributors/todo/align/api_completeness_audit-unfinished.md +0 -200
- data/doc/contributors/todo/align/term.md +0 -351
- data/doc/contributors/todo/align/terminal.md +0 -647
- data/doc/contributors/todo/future_work.md +0 -169
- data/doc/contributors/upstream_requests/paragraph_span_rects.md +0 -259
- data/doc/contributors/upstream_requests/tab_rects.md +0 -173
- data/doc/contributors/upstream_requests/title_rects.md +0 -132
- data/doc/custom.css +0 -22
- data/doc/getting_started/quickstart.md +0 -291
- data/doc/getting_started/why.md +0 -93
- data/doc/images/app_all_events.png +0 -0
- data/doc/images/app_cli_rich_moments.gif +0 -0
- data/doc/images/app_color_picker.png +0 -0
- data/doc/images/app_debugging_showcase.gif +0 -0
- data/doc/images/app_debugging_showcase.png +0 -0
- data/doc/images/app_external_editor.gif +0 -0
- data/doc/images/app_login_form.png +0 -0
- data/doc/images/app_stateful_interaction.png +0 -0
- data/doc/images/verify_quickstart_dsl.png +0 -0
- data/doc/images/verify_quickstart_layout.png +0 -0
- data/doc/images/verify_quickstart_lifecycle.png +0 -0
- data/doc/images/verify_readme_usage.png +0 -0
- data/doc/images/widget_barchart.png +0 -0
- data/doc/images/widget_block.png +0 -0
- data/doc/images/widget_box.png +0 -0
- data/doc/images/widget_calendar.png +0 -0
- data/doc/images/widget_canvas.png +0 -0
- data/doc/images/widget_cell.png +0 -0
- data/doc/images/widget_center.png +0 -0
- data/doc/images/widget_chart.png +0 -0
- data/doc/images/widget_gauge.png +0 -0
- data/doc/images/widget_layout_split.png +0 -0
- data/doc/images/widget_line_gauge.png +0 -0
- data/doc/images/widget_list.png +0 -0
- data/doc/images/widget_map.png +0 -0
- data/doc/images/widget_overlay.png +0 -0
- data/doc/images/widget_popup.png +0 -0
- data/doc/images/widget_ratatui_logo.png +0 -0
- data/doc/images/widget_ratatui_mascot.png +0 -0
- data/doc/images/widget_rect.png +0 -0
- data/doc/images/widget_render.png +0 -0
- data/doc/images/widget_rich_text.png +0 -0
- data/doc/images/widget_scroll_text.png +0 -0
- data/doc/images/widget_scrollbar.png +0 -0
- data/doc/images/widget_sparkline.png +0 -0
- data/doc/images/widget_style_colors.png +0 -0
- data/doc/images/widget_table.png +0 -0
- data/doc/images/widget_tabs.png +0 -0
- data/doc/images/widget_text_width.png +0 -0
- data/doc/index.md +0 -34
- data/doc/troubleshooting/async.md +0 -4
- data/doc/troubleshooting/terminal_limitations.md +0 -131
- data/doc/troubleshooting/tui_output.md +0 -197
- data/examples/app_all_events/README.md +0 -114
- data/examples/app_all_events/app.rb +0 -98
- data/examples/app_all_events/model/app_model.rb +0 -159
- data/examples/app_all_events/model/event_color_cycle.rb +0 -43
- data/examples/app_all_events/model/event_entry.rb +0 -94
- data/examples/app_all_events/model/msg.rb +0 -39
- data/examples/app_all_events/model/timestamp.rb +0 -56
- data/examples/app_all_events/update.rb +0 -75
- data/examples/app_all_events/view/app_view.rb +0 -80
- data/examples/app_all_events/view/controls_view.rb +0 -54
- data/examples/app_all_events/view/counts_view.rb +0 -61
- data/examples/app_all_events/view/live_view.rb +0 -72
- data/examples/app_all_events/view/log_view.rb +0 -57
- data/examples/app_all_events/view.rb +0 -9
- data/examples/app_cli_rich_moments/README.md +0 -81
- data/examples/app_cli_rich_moments/app.rb +0 -189
- data/examples/app_color_picker/README.md +0 -156
- data/examples/app_color_picker/app.rb +0 -76
- data/examples/app_color_picker/clipboard.rb +0 -86
- data/examples/app_color_picker/color.rb +0 -193
- data/examples/app_color_picker/controls.rb +0 -92
- data/examples/app_color_picker/copy_dialog.rb +0 -168
- data/examples/app_color_picker/export_pane.rb +0 -128
- data/examples/app_color_picker/harmony.rb +0 -58
- data/examples/app_color_picker/input.rb +0 -176
- data/examples/app_color_picker/main_container.rb +0 -180
- data/examples/app_color_picker/palette.rb +0 -111
- data/examples/app_debugging_showcase/README.md +0 -119
- data/examples/app_debugging_showcase/app.rb +0 -318
- data/examples/app_external_editor/README.md +0 -62
- data/examples/app_external_editor/app.rb +0 -344
- data/examples/app_login_form/README.md +0 -58
- data/examples/app_login_form/app.rb +0 -109
- data/examples/app_stateful_interaction/README.md +0 -35
- data/examples/app_stateful_interaction/app.rb +0 -328
- data/examples/timeout_demo.rb +0 -45
- data/examples/verify_quickstart_dsl/README.md +0 -55
- data/examples/verify_quickstart_dsl/app.rb +0 -49
- data/examples/verify_quickstart_layout/README.md +0 -77
- data/examples/verify_quickstart_layout/app.rb +0 -73
- data/examples/verify_quickstart_lifecycle/README.md +0 -68
- data/examples/verify_quickstart_lifecycle/app.rb +0 -62
- data/examples/verify_readme_usage/README.md +0 -49
- data/examples/verify_readme_usage/app.rb +0 -42
- data/examples/verify_website_managed/README.md +0 -48
- data/examples/verify_website_managed/app.rb +0 -36
- data/examples/verify_website_menu/README.md +0 -60
- data/examples/verify_website_menu/app.rb +0 -84
- data/examples/verify_website_spinner/README.md +0 -44
- data/examples/verify_website_spinner/app.rb +0 -34
- data/examples/widget_barchart/README.md +0 -58
- data/examples/widget_barchart/app.rb +0 -240
- data/examples/widget_block/README.md +0 -44
- data/examples/widget_block/app.rb +0 -258
- data/examples/widget_box/README.md +0 -54
- data/examples/widget_box/app.rb +0 -255
- data/examples/widget_calendar/README.md +0 -48
- data/examples/widget_calendar/app.rb +0 -115
- data/examples/widget_canvas/README.md +0 -31
- data/examples/widget_canvas/app.rb +0 -130
- data/examples/widget_cell/README.md +0 -45
- data/examples/widget_cell/app.rb +0 -112
- data/examples/widget_center/README.md +0 -33
- data/examples/widget_center/app.rb +0 -118
- data/examples/widget_chart/README.md +0 -50
- data/examples/widget_chart/app.rb +0 -220
- data/examples/widget_gauge/README.md +0 -50
- data/examples/widget_gauge/app.rb +0 -229
- data/examples/widget_layout_split/README.md +0 -53
- data/examples/widget_layout_split/app.rb +0 -260
- data/examples/widget_line_gauge/README.md +0 -50
- data/examples/widget_line_gauge/app.rb +0 -219
- data/examples/widget_list/README.md +0 -58
- data/examples/widget_list/app.rb +0 -382
- data/examples/widget_map/README.md +0 -48
- data/examples/widget_map/app.rb +0 -95
- data/examples/widget_overlay/README.md +0 -45
- data/examples/widget_overlay/app.rb +0 -250
- data/examples/widget_popup/README.md +0 -45
- data/examples/widget_popup/app.rb +0 -106
- data/examples/widget_ratatui_logo/README.md +0 -43
- data/examples/widget_ratatui_logo/app.rb +0 -104
- data/examples/widget_ratatui_mascot/README.md +0 -43
- data/examples/widget_ratatui_mascot/app.rb +0 -95
- data/examples/widget_rect/README.md +0 -53
- data/examples/widget_rect/app.rb +0 -222
- data/examples/widget_render/README.md +0 -46
- data/examples/widget_render/app.rb +0 -186
- data/examples/widget_render/app.rbs +0 -41
- data/examples/widget_rich_text/README.md +0 -44
- data/examples/widget_rich_text/app.rb +0 -193
- data/examples/widget_scroll_text/README.md +0 -46
- data/examples/widget_scroll_text/app.rb +0 -109
- data/examples/widget_scrollbar/README.md +0 -46
- data/examples/widget_scrollbar/app.rb +0 -155
- data/examples/widget_sparkline/README.md +0 -51
- data/examples/widget_sparkline/app.rb +0 -277
- data/examples/widget_style_colors/README.md +0 -43
- data/examples/widget_style_colors/app.rb +0 -83
- data/examples/widget_table/README.md +0 -57
- data/examples/widget_table/app.rb +0 -285
- data/examples/widget_tabs/README.md +0 -50
- data/examples/widget_tabs/app.rb +0 -183
- data/examples/widget_text_width/README.md +0 -44
- data/examples/widget_text_width/app.rb +0 -117
- data/migrate_to_buffer.rb +0 -145
- data/mise.toml +0 -8
- data/tasks/autodoc/examples.rb +0 -87
- data/tasks/autodoc/member.rb +0 -58
- data/tasks/autodoc/name.rb +0 -21
- data/tasks/autodoc.rake +0 -21
- data/tasks/bump/bump_workflow.rb +0 -49
- data/tasks/bump/cargo_lockfile.rb +0 -21
- data/tasks/bump/changelog.rb +0 -104
- data/tasks/bump/header.rb +0 -32
- data/tasks/bump/history.rb +0 -32
- data/tasks/bump/links.rb +0 -69
- data/tasks/bump/manifest.rb +0 -33
- data/tasks/bump/patch_release.rb +0 -19
- data/tasks/bump/release_branch.rb +0 -17
- data/tasks/bump/release_from_trunk.rb +0 -49
- data/tasks/bump/repository.rb +0 -54
- data/tasks/bump/ruby_gem.rb +0 -29
- data/tasks/bump/sem_ver.rb +0 -44
- data/tasks/bump/unreleased_section.rb +0 -73
- data/tasks/bump.rake +0 -61
- data/tasks/doc/documentation.rb +0 -59
- data/tasks/doc/link/file_url.rb +0 -30
- data/tasks/doc/link/relative_path.rb +0 -61
- data/tasks/doc/link/web_url.rb +0 -55
- data/tasks/doc/link.rb +0 -52
- data/tasks/doc/link_audit.rb +0 -116
- data/tasks/doc/problem.rb +0 -40
- data/tasks/doc/source_file.rb +0 -93
- data/tasks/doc.rake +0 -905
- data/tasks/example_viewer.html.erb +0 -172
- data/tasks/extension.rake +0 -14
- data/tasks/license/headers_md.rb +0 -223
- data/tasks/license/headers_rb.rb +0 -210
- data/tasks/license/license_utils.rb +0 -130
- data/tasks/license/snippets_md.rb +0 -315
- data/tasks/license/snippets_rdoc.rb +0 -150
- data/tasks/license.rake +0 -91
- data/tasks/lint.rake +0 -170
- data/tasks/rbs_predicates/predicate_catalog.rb +0 -52
- data/tasks/rbs_predicates/predicate_tests.rb +0 -124
- data/tasks/rbs_predicates/rbs_signature.rb +0 -63
- data/tasks/rbs_predicates.rake +0 -31
- data/tasks/rdoc_config.rb +0 -29
- data/tasks/resources/build.yml.erb +0 -60
- data/tasks/resources/index.html.erb +0 -141
- data/tasks/resources/rubies.yml +0 -7
- data/tasks/sourcehut.rake +0 -110
- data/tasks/steep.rake +0 -11
- data/tasks/terminal_preview/app_screenshot.rb +0 -45
- data/tasks/terminal_preview/crash_report.rb +0 -54
- data/tasks/terminal_preview/example_app.rb +0 -27
- data/tasks/terminal_preview/launcher_script.rb +0 -48
- data/tasks/terminal_preview/preview_collection.rb +0 -60
- data/tasks/terminal_preview/preview_timing.rb +0 -24
- data/tasks/terminal_preview/safety_confirmation.rb +0 -58
- data/tasks/terminal_preview/saved_screenshot.rb +0 -56
- data/tasks/terminal_preview/system_appearance.rb +0 -13
- data/tasks/terminal_preview/terminal_window.rb +0 -138
- data/tasks/terminal_preview/window_id.rb +0 -16
- data/tasks/terminal_preview.rake +0 -30
- data/tasks/test.rake +0 -36
- data/tasks/website/index_page.rb +0 -30
- data/tasks/website/version.rb +0 -122
- data/tasks/website/version_menu.rb +0 -68
- data/tasks/website/versioned_documentation.rb +0 -83
- data/tasks/website/website.rb +0 -53
- data/tasks/website.rake +0 -28
data/tasks/test.rake
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
require "minitest/test_task"
|
|
9
|
-
|
|
10
|
-
namespace :cargo do
|
|
11
|
-
desc "Run cargo tests"
|
|
12
|
-
task :test do
|
|
13
|
-
sh "cd ext/ratatui_ruby && cargo test"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Clear the default test task created by Minitest::TestTask if it exists
|
|
18
|
-
Rake::Task["test"].clear if Rake::Task.task_defined?("test")
|
|
19
|
-
|
|
20
|
-
desc "Run all tests (Ruby and Rust)"
|
|
21
|
-
task test: %w[compile test:ruby test:rust]
|
|
22
|
-
|
|
23
|
-
namespace :test do
|
|
24
|
-
desc "Run Rust tests"
|
|
25
|
-
task :rust do
|
|
26
|
-
Rake::Task["cargo:test"].invoke
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Create a specific Minitest task for Ruby tests
|
|
30
|
-
Minitest::TestTask.create(:ruby) do |t|
|
|
31
|
-
t.test_globs = ["test/**/*.rb", "examples/**/test_*.rb"]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Regenerate predicate tests before running Ruby tests
|
|
35
|
-
Rake::Task["test:ruby"].enhance(["rbs:tests"])
|
|
36
|
-
end
|
data/tasks/website/index_page.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
require "erb"
|
|
9
|
-
|
|
10
|
-
class IndexPage
|
|
11
|
-
def initialize(versions)
|
|
12
|
-
@versions = versions
|
|
13
|
-
|
|
14
|
-
latest_version = @versions.find { |v| v.is_a?(Tagged) }
|
|
15
|
-
latest_version.is_latest = true if latest_version
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def publish_to(path, project_name:)
|
|
19
|
-
puts "Generating index page..."
|
|
20
|
-
|
|
21
|
-
template_path = File.expand_path("../resources/index.html.erb", __dir__)
|
|
22
|
-
template = File.read(template_path)
|
|
23
|
-
|
|
24
|
-
versions = @versions
|
|
25
|
-
# project_name is used in the ERB
|
|
26
|
-
html_content = ERB.new(template).result(binding)
|
|
27
|
-
|
|
28
|
-
File.write(path, html_content)
|
|
29
|
-
end
|
|
30
|
-
end
|
data/tasks/website/version.rb
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
require "rubygems"
|
|
9
|
-
require "fileutils"
|
|
10
|
-
|
|
11
|
-
class Version
|
|
12
|
-
def self.all
|
|
13
|
-
tags = `git tag`.split.grep(/^v\d/)
|
|
14
|
-
sorted_versions = tags.map { |t| Tagged.new(t) }
|
|
15
|
-
.sort_by(&:semver)
|
|
16
|
-
.reverse
|
|
17
|
-
|
|
18
|
-
# Keep only the latest patch for each minor version
|
|
19
|
-
# e.g., if we have v0.6.0, v0.6.1, v0.6.2, only keep v0.6.2
|
|
20
|
-
latest_per_minor = sorted_versions
|
|
21
|
-
.group_by { |v| v.semver.segments[0..1] } # group by [major, minor]
|
|
22
|
-
.values
|
|
23
|
-
.map(&:first) # take the first (highest patch) from each group
|
|
24
|
-
|
|
25
|
-
[Edge.new] + latest_per_minor
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def slug
|
|
29
|
-
raise NotImplementedError
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def name
|
|
33
|
-
raise NotImplementedError
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def type
|
|
37
|
-
raise NotImplementedError
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def ref
|
|
41
|
-
raise NotImplementedError
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def checkout(globs:, &block)
|
|
45
|
-
Dir.mktmpdir do |path|
|
|
46
|
-
# Use git archive to export the version at the specified ref
|
|
47
|
-
# Pipe to tar to extract into the temporary directory
|
|
48
|
-
system("git archive #{ref} | tar -x -C #{path}")
|
|
49
|
-
|
|
50
|
-
# Remove the native extension directory as we don't need it for builds
|
|
51
|
-
# and it can cause issues if not meant to be compiled in this context
|
|
52
|
-
FileUtils.rm_rf("#{path}/ext")
|
|
53
|
-
|
|
54
|
-
yield path
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def latest?
|
|
59
|
-
false
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def edge?
|
|
63
|
-
false
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
class Edge < Version
|
|
68
|
-
def slug
|
|
69
|
-
"trunk"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def name
|
|
73
|
-
"trunk"
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def type
|
|
77
|
-
:edge
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def ref
|
|
81
|
-
"trunk"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def edge?
|
|
85
|
-
true
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
class Tagged < Version
|
|
90
|
-
attr_reader :tag
|
|
91
|
-
|
|
92
|
-
def initialize(tag)
|
|
93
|
-
@tag = tag
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def slug
|
|
97
|
-
segments = semver.segments
|
|
98
|
-
"v#{segments[0]}.#{segments[1]}"
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def name
|
|
102
|
-
@tag
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def type
|
|
106
|
-
:version
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def ref
|
|
110
|
-
@tag
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def semver
|
|
114
|
-
Gem::Version.new(@tag.sub(/^v/, ""))
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
attr_accessor :is_latest
|
|
118
|
-
|
|
119
|
-
def latest?
|
|
120
|
-
@is_latest
|
|
121
|
-
end
|
|
122
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
class VersionMenu
|
|
9
|
-
def initialize(root:, versions:)
|
|
10
|
-
@root = root
|
|
11
|
-
@versions = versions
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def run
|
|
15
|
-
puts "Injecting version menu into generated HTML..."
|
|
16
|
-
|
|
17
|
-
# Process all HTML files in the output directory
|
|
18
|
-
Dir.glob(File.join(@root, "**/*.html")).each do |file|
|
|
19
|
-
inject_menu(file)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private def inject_menu(file)
|
|
24
|
-
content = File.read(file)
|
|
25
|
-
|
|
26
|
-
# Find the injection point (before the theme toggle button)
|
|
27
|
-
pattern = /(<button[^>]*id="theme-toggle"[^>]*>)/mi
|
|
28
|
-
|
|
29
|
-
unless content.match?(pattern)
|
|
30
|
-
# warn "Could not find theme-toggle in #{file}"
|
|
31
|
-
return
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Calculate relative path to root from this file
|
|
35
|
-
file_dir = File.dirname(file)
|
|
36
|
-
relative_path_to_root = Pathname.new(@root).relative_path_from(Pathname.new(file_dir)).to_s
|
|
37
|
-
relative_path_to_root += "/" unless relative_path_to_root.end_with?("/")
|
|
38
|
-
|
|
39
|
-
# Determine current version from file path
|
|
40
|
-
relative_path_from_root = Pathname.new(file).relative_path_from(Pathname.new(@root)).to_s
|
|
41
|
-
current_version_slug = relative_path_from_root.split("/").first
|
|
42
|
-
|
|
43
|
-
# Build options
|
|
44
|
-
options = @versions.map do |version|
|
|
45
|
-
value = "#{relative_path_to_root}#{version.slug}/index.html"
|
|
46
|
-
selected = (version.slug == current_version_slug) ? "selected" : ""
|
|
47
|
-
display_name = version.name
|
|
48
|
-
display_name += " (latest)" if version.respond_to?(:latest?) && version.latest?
|
|
49
|
-
display_name += " (dev)" if version.edge?
|
|
50
|
-
|
|
51
|
-
%Q{<option value="#{value}" #{selected}>#{display_name}</option>}
|
|
52
|
-
end.join("\n")
|
|
53
|
-
|
|
54
|
-
# margin-left: auto pushes it to the right
|
|
55
|
-
# margin-right: 1rem spacing from the theme toggle
|
|
56
|
-
switcher_html = <<~HTML
|
|
57
|
-
<select class="version-menu" onchange="window.location.href=this.value" style="margin-left: auto; padding: 0.25rem; border-radius: 4px; border: 1px solid #ccc; margin-right: 1rem;">
|
|
58
|
-
#{options}
|
|
59
|
-
<option value="#{relative_path_to_root}index.html">All Versions</option>
|
|
60
|
-
</select>
|
|
61
|
-
HTML
|
|
62
|
-
|
|
63
|
-
# Inject before the button
|
|
64
|
-
new_content = content.sub(pattern, "#{switcher_html}\n\\1")
|
|
65
|
-
|
|
66
|
-
File.write(file, new_content)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
require_relative "../rdoc_config"
|
|
9
|
-
|
|
10
|
-
class VersionedDocumentation
|
|
11
|
-
def initialize(version)
|
|
12
|
-
@version = version
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def publish_to(path, project_name:, globs:, assets: [])
|
|
16
|
-
puts "Building documentation for #{@version.name}..."
|
|
17
|
-
|
|
18
|
-
absolute_path = File.absolute_path(path)
|
|
19
|
-
gemfile_path = File.absolute_path("Gemfile")
|
|
20
|
-
custom_css_path = File.absolute_path("doc/custom.css")
|
|
21
|
-
rakefile_path = File.absolute_path("Rakefile")
|
|
22
|
-
tasks_dir_path = File.absolute_path("tasks")
|
|
23
|
-
|
|
24
|
-
@version.checkout(globs:) do |source_path|
|
|
25
|
-
# Copy current Rakefile and tasks into the temp directory
|
|
26
|
-
# This ensures all versions use the latest example generation logic
|
|
27
|
-
FileUtils.cp(rakefile_path, File.join(source_path, "Rakefile"))
|
|
28
|
-
FileUtils.cp_r(tasks_dir_path, File.join(source_path, "tasks"))
|
|
29
|
-
|
|
30
|
-
Dir.chdir(source_path) do
|
|
31
|
-
title = "#{project_name} #{@version.name}"
|
|
32
|
-
title = "#{project_name} (trunk)" if @version.edge?
|
|
33
|
-
|
|
34
|
-
# Use rake rerdoc to ensure copy_examples runs
|
|
35
|
-
# Set environment variables to override rdoc settings
|
|
36
|
-
success = system(
|
|
37
|
-
{
|
|
38
|
-
"BUNDLE_GEMFILE" => gemfile_path,
|
|
39
|
-
"RDOC_OUTPUT" => absolute_path,
|
|
40
|
-
"RDOC_TITLE" => title,
|
|
41
|
-
"RDOC_CUSTOM_CSS" => custom_css_path,
|
|
42
|
-
},
|
|
43
|
-
"bundle exec rake rerdoc"
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
# Fall back to direct rdoc call if rake fails for any reason
|
|
47
|
-
unless success
|
|
48
|
-
puts " Rake task failed, falling back to direct rdoc call..."
|
|
49
|
-
files = globs.flat_map { |glob| Dir[glob] }.uniq
|
|
50
|
-
system(
|
|
51
|
-
{ "BUNDLE_GEMFILE" => gemfile_path },
|
|
52
|
-
"bundle exec rdoc -o #{absolute_path} --main #{RDocConfig::MAIN} --title '#{title}' --template-stylesheets \"#{custom_css_path}\" #{files.join(' ')}"
|
|
53
|
-
)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Copy generated documentation to target path if it was generated elsewhere
|
|
57
|
-
# This handles cases where RDOC_OUTPUT wasn't respected (evaluated at load time)
|
|
58
|
-
temp_output_paths = ["tmp/rdoc", "doc"]
|
|
59
|
-
temp_output_paths.each do |temp_path|
|
|
60
|
-
# Check if this looks like generated rdoc (has index.html)
|
|
61
|
-
if Dir.exist?(temp_path) && !Dir.empty?(temp_path) && File.exist?(File.join(temp_path, "index.html"))
|
|
62
|
-
puts " Copying generated docs from #{temp_path} to #{absolute_path}..."
|
|
63
|
-
FileUtils.mkdir_p(absolute_path)
|
|
64
|
-
FileUtils.cp_r Dir["#{temp_path}/*"], absolute_path
|
|
65
|
-
break
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
copy_assets_to(absolute_path, assets)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
private def copy_assets_to(path, assets)
|
|
75
|
-
assets.each do |asset_dir|
|
|
76
|
-
if Dir.exist?(asset_dir)
|
|
77
|
-
destination = File.join(path, asset_dir)
|
|
78
|
-
FileUtils.mkdir_p(destination)
|
|
79
|
-
FileUtils.cp_r Dir["#{asset_dir}/*"], destination
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
data/tasks/website/website.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
require_relative "version"
|
|
9
|
-
require_relative "versioned_documentation"
|
|
10
|
-
require_relative "index_page"
|
|
11
|
-
require_relative "version_menu"
|
|
12
|
-
require "fileutils"
|
|
13
|
-
|
|
14
|
-
class Website
|
|
15
|
-
def initialize(at: "www", project_name:, globs:, assets: [])
|
|
16
|
-
@destination = at
|
|
17
|
-
@project_name = project_name
|
|
18
|
-
@globs = globs
|
|
19
|
-
@assets = assets
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def build
|
|
23
|
-
clean
|
|
24
|
-
|
|
25
|
-
versions.each do |version|
|
|
26
|
-
VersionedDocumentation.new(version).publish_to(
|
|
27
|
-
join(version.slug),
|
|
28
|
-
project_name: @project_name,
|
|
29
|
-
globs: @globs,
|
|
30
|
-
assets: @assets
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
IndexPage.new(versions).publish_to(join("index.html"), project_name: @project_name)
|
|
35
|
-
|
|
36
|
-
VersionMenu.new(root: @destination, versions:).run
|
|
37
|
-
|
|
38
|
-
puts "Website built in #{@destination}/"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def versions
|
|
42
|
-
@versions ||= Version.all
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
private def join(path)
|
|
46
|
-
File.join(@destination, path)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private def clean
|
|
50
|
-
FileUtils.rm_rf(@destination)
|
|
51
|
-
FileUtils.mkdir_p(@destination)
|
|
52
|
-
end
|
|
53
|
-
end
|
data/tasks/website.rake
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
5
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
-
#++
|
|
7
|
-
|
|
8
|
-
require "erb"
|
|
9
|
-
require "fileutils"
|
|
10
|
-
require "tmpdir"
|
|
11
|
-
require_relative "rdoc_config"
|
|
12
|
-
|
|
13
|
-
namespace :website do
|
|
14
|
-
desc "Build documentation for trunk (current dir) and all git tags"
|
|
15
|
-
task :build do
|
|
16
|
-
require_relative "website/website"
|
|
17
|
-
|
|
18
|
-
spec = Gem::Specification.load(Dir["*.gemspec"].first)
|
|
19
|
-
globs = RDocConfig::RDOC_FILES + ["*.gemspec", "doc/images/**/*", "examples/**/*"]
|
|
20
|
-
|
|
21
|
-
Website.new(
|
|
22
|
-
at: "www",
|
|
23
|
-
project_name: spec.name,
|
|
24
|
-
globs:,
|
|
25
|
-
assets: ["doc/images"] # directories to copy
|
|
26
|
-
).build
|
|
27
|
-
end
|
|
28
|
-
end
|