-
-
Notifications
You must be signed in to change notification settings - Fork 66
Require Python 3.10 and Sphinx 7.3 #221
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7be97e2
Drop Python 3.9
AA-Turner 1d36ee8
Return version key in ``setup()``
AA-Turner 7c199fa
Require Sphinx 7.2+
AA-Turner 54c28a5
Require Sphinx 7.3+
AA-Turner 044d53a
Move @import to [[theme.stylesheets]]
AA-Turner dbda1e8
`tomllib` is new in Python 3.11, not 3.10
AA-Turner f2c2dbb
Merge branch 'master' into drop-reqs
AA-Turner 427f7c5
post-merge
AA-Turner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
import hashlib | ||
import os | ||
from functools import cache | ||
from pathlib import Path | ||
from typing import Any | ||
from typing import TYPE_CHECKING | ||
|
||
import sphinx.application | ||
from sphinx.builders.html import StandaloneHTMLBuilder | ||
if TYPE_CHECKING: | ||
from sphinx.application import Sphinx | ||
from sphinx.util.typing import ExtensionMetadata | ||
|
||
THEME_PATH = Path(__file__).parent.resolve() | ||
THEME_PATH = Path(__file__).resolve().parent | ||
|
||
|
||
@cache | ||
def _asset_hash(path: str) -> str: | ||
"""Append a `?digest=` to an url based on the file content.""" | ||
full_path = THEME_PATH / path.replace("_static/", "static/") | ||
digest = hashlib.sha1(full_path.read_bytes()).hexdigest() | ||
|
||
return f"{path}?digest={digest}" | ||
|
||
|
||
def _add_asset_hashes(static: list[str], add_digest_to: list[str]) -> None: | ||
for asset in add_digest_to: | ||
index = static.index(asset) | ||
static[index].filename = _asset_hash(asset) # type: ignore[attr-defined] | ||
|
||
|
||
def _html_page_context( | ||
app: sphinx.application.Sphinx, | ||
pagename: str, | ||
templatename: str, | ||
context: dict[str, Any], | ||
doctree: Any, | ||
) -> None: | ||
if app.config.html_theme != "python_docs_theme": | ||
return | ||
|
||
assert isinstance(app.builder, StandaloneHTMLBuilder) | ||
|
||
if (4,) <= sphinx.version_info < (7, 1) and "css_files" in context: | ||
if "_static/pydoctheme.css" not in context["css_files"]: | ||
raise ValueError( | ||
"This documentation is not using `pydoctheme.css` as the stylesheet. " | ||
"If you have set `html_style` in your conf.py file, remove it." | ||
) | ||
|
||
_add_asset_hashes( | ||
context["css_files"], | ||
["_static/pydoctheme.css"], | ||
) | ||
|
||
|
||
def setup(app): | ||
app.require_sphinx("3.4") | ||
|
||
current_dir = os.path.abspath(os.path.dirname(__file__)) | ||
app.add_html_theme("python_docs_theme", current_dir) | ||
|
||
app.connect("html-page-context", _html_page_context) | ||
def setup(app: Sphinx) -> ExtensionMetadata: | ||
app.require_sphinx("7.3") | ||
app.add_html_theme("python_docs_theme", THEME_PATH) | ||
|
||
return { | ||
"version": "2024.12", | ||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"parallel_read_safe": True, | ||
"parallel_write_safe": True, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[theme] | ||
inherit = "default" | ||
stylesheets = [ | ||
"classic.css", | ||
"pydoctheme.css", | ||
] | ||
pygments_style = { default = "default", dark = "monokai" } | ||
|
||
[options] | ||
bodyfont = "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif" | ||
headfont = "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif" | ||
footerbgcolor = "white" | ||
footertextcolor = "#555555" | ||
relbarbgcolor = "white" | ||
relbartextcolor = "#666666" | ||
relbarlinkcolor = "#444444" | ||
sidebarbgcolor = "white" | ||
sidebartextcolor = "#444444" | ||
sidebarlinkcolor = "#444444" | ||
sidebarbtncolor = "#cccccc" | ||
bgcolor = "white" | ||
textcolor = "#222222" | ||
linkcolor = "#0090c0" | ||
visitedlinkcolor = "#00608f" | ||
headtextcolor = "#1a1a1a" | ||
headbgcolor = "white" | ||
headlinkcolor = "#aaaaaa" | ||
codebgcolor = "#eeffcc" | ||
codetextcolor = "#333333" | ||
|
||
hosted_on = "" | ||
issues_url = "" | ||
license_url = "" | ||
root_name = "Python" | ||
root_url = "https://www.python.org/" | ||
root_icon = "py.svg" | ||
root_icon_alt_text = "Python logo" | ||
root_include_title = "True" | ||
copyright_url = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
setuptools | ||
Babel | ||
Jinja2 | ||
tomli; python_version < "3.10" | ||
tomli; python_version < "3.11" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.