Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use kedro-sphinx-theme #3675

Merged
merged 5 commits into from
Apr 19, 2024
Merged
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
73 changes: 0 additions & 73 deletions docs/source/_templates/layout.html

This file was deleted.

34 changes: 1 addition & 33 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from __future__ import annotations

import importlib
import os
import re
import sys
from inspect import getmembers, isclass, isfunction
Expand Down Expand Up @@ -202,7 +201,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme = "kedro-sphinx-theme"
here = Path(__file__).parent.absolute()

# Theme options are theme-specific and customise the look and feel of a theme
Expand Down Expand Up @@ -492,39 +491,8 @@ def autodoc_process_docstring(app, what, name, obj, options, lines): # noqa: PL
remove_arrows_in_examples(lines)


def env_override(default_appid):
build_version = os.getenv("READTHEDOCS_VERSION")

if build_version == "latest":
return os.environ["HEAP_APPID_QA"]
if build_version == "stable":
return os.environ["HEAP_APPID_PROD"]

return default_appid # default to Development for local builds


def _add_jinja_filters(app):
Comment on lines -495 to -506
Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking that maybe these functions should stay here, instead of being in the theme itself

# https://github.com/crate/crate/issues/10833
from sphinx.builders.latex import LaTeXBuilder
from sphinx.builders.linkcheck import CheckExternalLinksBuilder

# LaTeXBuilder is used in the PDF docs build,
# and it doesn't have attribute 'templates'
if not (isinstance(app.builder, (LaTeXBuilder, CheckExternalLinksBuilder))):
app.builder.templates.environment.filters["env_override"] = env_override


def _override_permalinks_icon(app):
# https://github.com/readthedocs/sphinx_rtd_theme/issues/98#issuecomment-1503211439
app.config.html_permalinks_icon = "¶"


def setup(app):
app.connect("builder-inited", _add_jinja_filters)
app.connect("builder-inited", _override_permalinks_icon)
app.connect("autodoc-process-docstring", autodoc_process_docstring)
# fix a bug with table wraps in Read the Docs Sphinx theme:
# https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html


# (regex, restructuredText link replacement, object) list
Expand Down
1 change: 1 addition & 0 deletions kedro/framework/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def python_call(


def find_stylesheets() -> Iterable[str]: # pragma: no cover
# TODO: Deprecate this function in favour of kedro-sphinx-theme
"""Fetch all stylesheets used in the official Kedro documentation"""
css_path = Path(__file__).resolve().parents[1] / "html" / "_static" / "css"
return (str(css_path / "copybutton.css"),)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just found out that this function exists after doing this PR, and I noticed that it's used in all the starters...

Expand Down
13 changes: 1 addition & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,9 @@ test = [
"types-toml"
]
docs = [
"docutils<0.21",
"sphinx>=5.3,<7.3",
"sphinx_rtd_theme==2.0.0",
# Regression on sphinx-autodoc-typehints 1.21
# that creates some problematic docstrings
"sphinx-autodoc-typehints==1.20.2",
"sphinx_copybutton==0.5.2",
"sphinx-notfound-page",
"kedro-sphinx-theme @ git+https://github.com/kedro-org/kedro-sphinx-theme@main",
Copy link
Member Author

Choose a reason for hiding this comment

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

If this approach is well received obviously this should be pinned to a tag, or even a proper release on PyPI

"ipykernel>=5.3, <7.0",
"myst-parser>=1.0,<2.1",
"Jinja2<3.2.0",
"sphinx-last-updated-by-git",
"sphinx-favicon",
"sphinxcontrib-youtube",
]
jupyter = [
"ipylab>=1.0.0",
Expand Down