From 4bf0d7a0e3e5ffc4a882de6daec0beb2e6a6b292 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Tue, 22 Apr 2025 11:14:26 +0200 Subject: [PATCH 1/3] Fix read the docs canonical url --- sphinxext/opengraph/__init__.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sphinxext/opengraph/__init__.py b/sphinxext/opengraph/__init__.py index ba021a0..fe6420f 100644 --- a/sphinxext/opengraph/__init__.py +++ b/sphinxext/opengraph/__init__.py @@ -253,16 +253,11 @@ def ambient_site_url() -> str: # readthedocs addons sets the READTHEDOCS_CANONICAL_URL variable, # or defines the ``html_baseurl`` variable in conf.py if rtd_canonical_url := os.getenv('READTHEDOCS_CANONICAL_URL'): - parse_result = urlsplit(rtd_canonical_url) + return rtd_canonical_url else: msg = 'ReadTheDocs did not provide a valid canonical URL!' raise RuntimeError(msg) - # Grab root url from canonical url - return urlunsplit( - (parse_result.scheme, parse_result.netloc, parse_result.path, '', '') - ) - def social_card_for_page( config_social: dict[str, bool | str], From b05c91f652f6289dde13f0c355babdf335a44b2b Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Tue, 22 Apr 2025 11:35:46 +0200 Subject: [PATCH 2/3] Fix lint errors --- sphinxext/opengraph/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinxext/opengraph/__init__.py b/sphinxext/opengraph/__init__.py index fe6420f..574d13a 100644 --- a/sphinxext/opengraph/__init__.py +++ b/sphinxext/opengraph/__init__.py @@ -4,7 +4,7 @@ import posixpath from pathlib import Path from typing import TYPE_CHECKING -from urllib.parse import urljoin, urlparse, urlsplit, urlunsplit +from urllib.parse import urljoin, urlparse from docutils import nodes @@ -254,9 +254,8 @@ def ambient_site_url() -> str: # or defines the ``html_baseurl`` variable in conf.py if rtd_canonical_url := os.getenv('READTHEDOCS_CANONICAL_URL'): return rtd_canonical_url - else: - msg = 'ReadTheDocs did not provide a valid canonical URL!' - raise RuntimeError(msg) + msg = 'ReadTheDocs did not provide a valid canonical URL!' + raise RuntimeError(msg) def social_card_for_page( From 36a67b033c57249775319c5bcac1c536d43dde08 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Tue, 22 Apr 2025 11:39:54 +0200 Subject: [PATCH 3/3] Remove hardcoded url --- docs/conf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f1fc182..54d5a9e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -62,8 +62,6 @@ # -- Configuration for this theme -------------------------------------------- -ogp_site_url = 'https://sphinxext-opengraph.readthedocs.io/en/latest/' - # Configuration for testing but generally we use the defaults # Uncomment lines to see their effect. ogp_social_cards = {