diff --git a/default.nix b/default.nix index 0a54aa523..b19802c13 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,9 @@ let # Commit of the Nixpkgs repository that we want to use. nixpkgsVersion = { - date = "2021-06-02"; - rev = "84aa23742f6c72501f9cc209f29c438766f5352d"; - tarballHash = "0h7xl6q0yjrbl9vm3h6lkxw692nm8bg3wy65gm95a2mivhrdjpxp"; + date = "2023-03-25"; + rev = "dbf5322e93bcc6cfc52268367a8ad21c09d76fea"; + tarballHash = "0lwk4v9dkvd28xpqch0b0jrac4xl9lwm6snrnzx8k5lby72kmkng"; }; # Nix files that describe the Nixpkgs repository. We evaluate the expression @@ -15,10 +15,7 @@ let }) { }; - sphinxTabsPkg = ps: ps.callPackage ./extensions/sphinx-tabs.nix {}; - sphinxCopybuttonPkg = ps: ps.callPackage ./extensions/sphinx-copybutton.nix {}; - - python = pkgs.python3.withPackages (ps: [ ps.sphinx ps.sphinx_rtd_theme ps.livereload (sphinxTabsPkg ps) (sphinxCopybuttonPkg ps) ]); + python = pkgs.python3.withPackages (ps: [ ps.sphinx ps.sphinx_rtd_theme ps.livereload ps.sphinx-tabs ps.sphinx-copybutton ps.sphinxext-opengraph ]); in rec { inherit pkgs; diff --git a/docs/conf.py b/docs/conf.py index 27da71781..844603f91 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,7 +30,8 @@ import os # ones. extensions = [ 'sphinx_tabs.tabs', - 'sphinx_copybutton' + 'sphinx_copybutton', + 'sphinxext.opengraph', ] # Add any paths that contain templates here, relative to this directory. @@ -298,3 +299,15 @@ user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25 # sphinx-tabs configuration sphinx_tabs_disable_tab_closing = True + +# sphinxext-opengraph configuration + +ogp_image = '_images/logo.png' +ogp_use_first_image = True +ogp_enable_meta_description = True +ogp_description_length = 300 + +## RTD sets html_baseurl, ensures we use the correct env for canonical URLs +## Useful to generate correct meta tags for Open Graph +## Refs: https://github.com/readthedocs/readthedocs.org/issues/10226, https://github.com/urllib3/urllib3/pull/3064 +html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") diff --git a/extensions/sphinx-copybutton.nix b/extensions/sphinx-copybutton.nix deleted file mode 100644 index 8d408d300..000000000 --- a/extensions/sphinx-copybutton.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, sphinx -}: - -buildPythonPackage rec { - pname = "sphinx-copybutton"; - version = "0.4.0"; - - src = fetchFromGitHub { - owner = "executablebooks"; - repo = "sphinx-copybutton"; - rev = "v${version}"; - sha256 = "sha256-vrEIvQeP7AMXSme1PBp0ox5k8Q1rz+1cbHIO+o17Jqc="; - fetchSubmodules = true; - }; - - propagatedBuildInputs = [ - sphinx - ]; - - doCheck = false; # no tests - - pythonImportsCheck = [ "sphinx_copybutton" ]; - - meta = with lib; { - description = "A small sphinx extension to add a \"copy\" button to code blocks"; - homepage = "https://github.com/executablebooks/sphinx-copybutton"; - license = licenses.mit; - maintainers = with maintainers; [ Luflosi ]; - }; -} diff --git a/extensions/sphinx-tabs.nix b/extensions/sphinx-tabs.nix deleted file mode 100644 index f90b1c18d..000000000 --- a/extensions/sphinx-tabs.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ lib -, buildPythonPackage -, fetchPypi -, sphinx -}: - -buildPythonPackage rec { - pname = "sphinx-tabs"; - version = "3.2.0"; - - src = fetchPypi { - inherit pname version; - sha256 = "sha256:1970aahi6sa7c37cpz8nwgdb2xzf21rk6ykdd1m6w9wvxla7j4rk"; - }; - - propagatedBuildInputs = [ - sphinx - ]; - - doCheck = false; - - pythonImportsCheck = [ "sphinx_tabs" ]; - - meta = with lib; { - description = "Create tabbed content in Sphinx documentation when building HTML"; - homepage = "https://sphinx-tabs.readthedocs.io"; - license = licenses.mit; - }; -} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6cf1adb8f..0dc8d6a2a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ sphinx-copybutton sphinx-rtd-theme>=0.5.1 sphinx-tabs==3.2.0 urllib3==2.0.7 +sphinxext-opengraph==0.9.0