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
27 changes: 27 additions & 0 deletions docs/_static/css/tirx_theme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/* The TVM brand logo is dark artwork on a transparent background, so in dark
* mode it disappears against the dark navbar/sidebar. Give it a white backing
* (dark mode only; light mode already shows it fine). */
html[data-theme="dark"] img.logo__image {
background: #ffffff;
padding: 3px 6px;
border-radius: 5px;
}
33 changes: 26 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def jupyter_notebook(script_blocks, gallery_conf, target_dir, real_func):
# -- Options for HTML output ----------------------------------------------

# The theme is set by the make target
html_theme = os.environ.get("TVM_THEME", "rtd")
html_theme = os.environ.get("TVM_THEME", "sphinx_book_theme")

on_rtd = os.environ.get("READTHEDOCS", None) == "True"
# only import rtd theme and set it if want to build docs locally
Expand All @@ -366,9 +366,25 @@ def jupyter_notebook(script_blocks, gallery_conf, target_dir, real_func):
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_theme_options = {
"logo_only": True,
}
if html_theme == "sphinx_book_theme":
html_theme_options = {
"repository_url": "https://github.com/apache/tvm",
"repository_branch": "main",
"path_to_docs": "docs/",
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": False,
"home_page_in_toc": False,
"show_navbar_depth": 1,
"show_toc_level": 2,
}
else:
html_theme_options = {
"logo_only": True,
}

if html_theme == "sphinx_book_theme":
html_css_files = ["css/tirx_theme.css"]

html_logo = "_static/img/tvm-logo-small.png"

Expand Down Expand Up @@ -561,9 +577,12 @@ def fixup_tutorials(original_url: str) -> str:
"edit_link_hook_fn": fixup_tutorials,
}

# add additional overrides
templates_path += [tlcpack_sphinx_addon.get_templates_path()]
html_static_path += [tlcpack_sphinx_addon.get_static_path()]
# add additional overrides. The tlcpack templates override layout.html for the
# RTD theme (and assume its header/footer html_context); only apply them when the
# RTD theme is active so they don't clobber another theme's own layout.
if html_theme == "sphinx_rtd_theme":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

On Read the Docs (on_rtd = True), if TVM_THEME is set to "rtd", html_theme remains "rtd" because the local normalization block on line 361 does not execute. Checking only html_theme == "sphinx_rtd_theme" will evaluate to False in this case, preventing the tlcpack_sphinx_addon templates and static overrides from being applied. We should check for both "sphinx_rtd_theme" and "rtd" to ensure correctness.

Suggested change
if html_theme == "sphinx_rtd_theme":
if html_theme in ("sphinx_rtd_theme", "rtd"):

templates_path += [tlcpack_sphinx_addon.get_templates_path()]
html_static_path += [tlcpack_sphinx_addon.get_static_path()]


def update_alias_docstring(name, obj, lines):
Expand Down
5 changes: 5 additions & 0 deletions tests/scripts/task_python_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export OMP_NUM_THREADS=1
IS_LOCAL=${IS_LOCAL:-0}
PYTHON_DOCS_ONLY=${PYTHON_DOCS_ONLY:-0}

# sphinx-book-theme is declared in docker/install/ubuntu_install_sphinx.sh, but the
# currently-published ci-gpu image predates that dependency. Install it here so the
# docs build can use the book theme until the CI image is refreshed.
uv pip install "sphinx-book-theme==1.1.4"

cleanup()
{
rm -rf /tmp/$$.log.txt
Expand Down
Loading