Skip to content

Commit

Permalink
Use RTD environment variables instead of html_context (#10)
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
sciencewhiz authored Jan 17, 2025
1 parent d99fe3b commit 63f8178
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sphinxext/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def on_rtd() -> bool:
return os.getenv("READTHEDOCS") == "True"


def on_pr(html_context: Dict[str, str]) -> bool:
def on_pr() -> bool:
return (
html_context["github_version"].startswith(html_context["commit"])
os.getenv("READTHEDOCS_VERSION_TYPE") == "external"
or os.getenv("GITHUB_EVENT_NAME") == "pull_request"
)

Expand All @@ -47,7 +47,7 @@ def inject_changed_files(html_context: Dict[str, str], app: Sphinx) -> None:
import requests

res = requests.get(
f"https://api.github.com/repos/{html_context['github_user']}/{html_context['github_repo']}/pulls/{html_context['current_version']}/files"
f"https://api.github.com/repos/{html_context['github_user']}/{html_context['github_repo']}/pulls/{os.environ.get('READTHEDOCS_VERSION_NAME')}/files"
)

if res.status_code != requests.codes.ok:
Expand Down

0 comments on commit 63f8178

Please sign in to comment.