docs(themes): add authoring guide for TOML theme system
This commit is contained in:
@@ -58,6 +58,12 @@ def test_get_syntax_palette_for_theme(tmp_path, monkeypatch):
|
||||
(themes_dir / "solarized_light.toml").write_text(
|
||||
'syntax_palette = "light"\n[colors]\nwindow_bg = [253, 246, 227]\n'
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
mock_style = MagicMock()
|
||||
mock_imgui = MagicMock()
|
||||
mock_imgui.get_style.return_value = mock_style
|
||||
mock_imgui.ImVec2.side_effect = lambda x, y: (x, y)
|
||||
monkeypatch.setattr(theme, "imgui", mock_imgui)
|
||||
monkeypatch.setattr(theme, "get_global_themes_path", lambda: themes_dir)
|
||||
theme.load_themes_from_disk()
|
||||
assert theme.get_syntax_palette_for_theme("solarized_light") == "light"
|
||||
@@ -97,6 +103,95 @@ def test_solarized_light_uses_light_syntax_palette(tmp_path, monkeypatch):
|
||||
(themes_dir / "solarized_light.toml").write_text(
|
||||
'syntax_palette = "light"\n[colors]\nwindow_bg = [253, 246, 227]\n'
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
mock_style = MagicMock()
|
||||
mock_imgui = MagicMock()
|
||||
mock_imgui.get_style.return_value = mock_style
|
||||
mock_imgui.ImVec2.side_effect = lambda x, y: (x, y)
|
||||
monkeypatch.setattr(theme, "imgui", mock_imgui)
|
||||
monkeypatch.setattr(theme, "get_global_themes_path", lambda: themes_dir)
|
||||
theme.load_themes_from_disk()
|
||||
assert theme.get_syntax_palette_for_theme("solarized_light") == "light"
|
||||
|
||||
|
||||
def test_solarized_dark_apply_does_not_raise(tmp_path, monkeypatch):
|
||||
from src import paths as paths_mod
|
||||
|
||||
themes_dir = tmp_path / "themes"
|
||||
themes_dir.mkdir()
|
||||
(themes_dir / "solarized_dark.toml").write_text(
|
||||
'syntax_palette = "dark"\n[colors]\nwindow_bg = [0, 43, 54]\n'
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
mock_style = MagicMock()
|
||||
mock_imgui = MagicMock()
|
||||
mock_imgui.get_style.return_value = mock_style
|
||||
mock_imgui.ImVec2.side_effect = lambda x, y: (x, y)
|
||||
monkeypatch.setattr(theme, "imgui", mock_imgui)
|
||||
monkeypatch.setattr(theme, "get_global_themes_path", lambda: themes_dir)
|
||||
theme.load_themes_from_disk()
|
||||
try:
|
||||
theme.apply("solarized_dark")
|
||||
except Exception as e:
|
||||
pytest.fail(f"apply(solarized_dark) raised: {e}")
|
||||
assert theme.get_current_palette() == "solarized_dark"
|
||||
|
||||
|
||||
def test_gruvbox_dark_apply_does_not_raise(tmp_path, monkeypatch):
|
||||
from src import paths as paths_mod
|
||||
|
||||
themes_dir = tmp_path / "themes"
|
||||
themes_dir.mkdir()
|
||||
(themes_dir / "gruvbox_dark.toml").write_text(
|
||||
'syntax_palette = "retro_blue"\n[colors]\nwindow_bg = [40, 40, 40]\n'
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
mock_style = MagicMock()
|
||||
mock_imgui = MagicMock()
|
||||
mock_imgui.get_style.return_value = mock_style
|
||||
mock_imgui.ImVec2.side_effect = lambda x, y: (x, y)
|
||||
monkeypatch.setattr(theme, "imgui", mock_imgui)
|
||||
monkeypatch.setattr(theme, "get_global_themes_path", lambda: themes_dir)
|
||||
theme.load_themes_from_disk()
|
||||
theme.apply("gruvbox_dark")
|
||||
assert theme.get_current_palette() == "gruvbox_dark"
|
||||
|
||||
|
||||
def test_moss_apply_does_not_raise(tmp_path, monkeypatch):
|
||||
from src import paths as paths_mod
|
||||
|
||||
themes_dir = tmp_path / "themes"
|
||||
themes_dir.mkdir()
|
||||
(themes_dir / "moss.toml").write_text(
|
||||
'syntax_palette = "mariana"\n[colors]\nwindow_bg = [40, 47, 49]\n'
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
mock_style = MagicMock()
|
||||
mock_imgui = MagicMock()
|
||||
mock_imgui.get_style.return_value = mock_style
|
||||
mock_imgui.ImVec2.side_effect = lambda x, y: (x, y)
|
||||
monkeypatch.setattr(theme, "imgui", mock_imgui)
|
||||
monkeypatch.setattr(theme, "get_global_themes_path", lambda: themes_dir)
|
||||
theme.load_themes_from_disk()
|
||||
theme.apply("moss")
|
||||
assert theme.get_current_palette() == "moss"
|
||||
|
||||
|
||||
def test_solarized_light_apply_does_not_raise(tmp_path, monkeypatch):
|
||||
from src import paths as paths_mod
|
||||
|
||||
themes_dir = tmp_path / "themes"
|
||||
themes_dir.mkdir()
|
||||
(themes_dir / "solarized_light.toml").write_text(
|
||||
'syntax_palette = "light"\n[colors]\nwindow_bg = [253, 246, 227]\n'
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
mock_style = MagicMock()
|
||||
mock_imgui = MagicMock()
|
||||
mock_imgui.get_style.return_value = mock_style
|
||||
mock_imgui.ImVec2.side_effect = lambda x, y: (x, y)
|
||||
monkeypatch.setattr(theme, "imgui", mock_imgui)
|
||||
monkeypatch.setattr(theme, "get_global_themes_path", lambda: themes_dir)
|
||||
theme.load_themes_from_disk()
|
||||
theme.apply("solarized_light")
|
||||
assert theme.get_current_palette() == "solarized_light"
|
||||
|
||||
Reference in New Issue
Block a user