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
4 changes: 3 additions & 1 deletion src/quantecon_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,9 @@ def get_github_src_folder(app):
context["theme_description"] = description

# Add the author if it exists
if app.config.author != "unknown":
if app.config.author in {"unknown", "Author name not set"}:
context.pop("author", None)
else:
context["author"] = app.config.author

# Absolute URLs for logo if `html_baseurl` is given
Expand Down
27 changes: 27 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ def test_build_book(file_regression, sphinx_build):

# Check a few components that should be true on each page
index_html = sphinx_build.get("index.html")
assert (
index_html.find("p", class_="qe-page__header-authors").get_text(strip=True)
== "Executable Book Project"
)
sidebar = index_html.find_all(attrs={"class": "bd-sidebar"})[0]
file_regression.check(sidebar.prettify(), extension=".html")

Expand Down Expand Up @@ -220,6 +224,29 @@ def test_build_book(file_regression, sphinx_build):
sphinx_build.clean()


def test_build_book_without_author(tmp_path):
"""Do not render Sphinx's default author placeholder in the page header."""
path_book = tmp_path / "book"
copytree(path_base, path_book)

path_conf = path_book / "conf.py"
conf = path_conf.read_text(encoding="utf8")
path_conf.write_text(
conf.replace('author = "Executable Book Project"\n', ""), encoding="utf8"
)

check_output(["sphinx-build", ".", "_build/html", "-a", "-W"], cwd=path_book)
index_html = BeautifulSoup(
(path_book / "_build" / "html" / "index.html").read_text(encoding="utf8"),
"html.parser",
)

assert (
index_html.find("p", class_="qe-page__header-authors").get_text(strip=True)
== ""
)


# def test_navbar_options(file_regression, sphinx_build):
# sphinx_build.copy()

Expand Down