Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
python -m pip install "sphinx~=${{ matrix.sphinx-version }}.0"
python -m pip install .

- name: Test theme templates
run: python -m unittest discover -s tests

- name: Run Sphinx
run: >
sphinx-build
Expand Down
3 changes: 3 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-22.04
tools:
Expand Down
2 changes: 1 addition & 1 deletion alabaster/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img class="logo" src="{{ pathto('_static/' ~ theme_logo, 1) }}" alt="Logo" />
{% if theme_logo_name|lower == 'true' %}
<h1 class="logo logo-name">{{ project }}</h1>
{% elif theme_logo_name|lower != 'false' %}
{% elif theme_logo_name is not none and theme_logo_name|lower != 'false' %}
<h1 class="logo logo-name">{{ theme_logo_name }}</h1>
{% endif %}
</a>
Expand Down
36 changes: 36 additions & 0 deletions tests/test_logo_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import unittest
from pathlib import Path

from jinja2 import Environment, FileSystemLoader


class LogoNameTests(unittest.TestCase):
def render(self, name):
env = Environment(
loader=FileSystemLoader(Path(__file__).parents[1] / "alabaster")
)
return env.get_template("about.html").render(
theme_logo="logo.png",
theme_logo_name=name,
project="Project title",
master_doc="index",
pathto=lambda path, *args: path,
)

def test_none_does_not_render_as_a_name(self):
self.assertNotIn('class="logo logo-name"', self.render(None))

def test_boolean_options(self):
for value in (True, "true", "True"):
with self.subTest(value=value):
self.assertIn(
'class="logo logo-name">Project title</h1>', self.render(value)
)
for value in (False, "false", "False"):
with self.subTest(value=value):
self.assertNotIn('class="logo logo-name"', self.render(value))

def test_custom_name(self):
self.assertIn(
'class="logo logo-name">Custom name</h1>', self.render("Custom name")
)
Loading