From 7ffeae734abd18de127e9f2ad1b1814c754422f7 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 22 Oct 2022 12:39:40 +0200 Subject: [PATCH] docs: add copybutton, opengraph, rediraffe --- docs/requirements.txt | 3 +++ docs/source/conf.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index 5aa039db..5c38c561 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,7 @@ myst-parser>=0.18 pydata-sphinx-theme>=0.11 sphinx-autobuild +sphinx-copybutton sphinxcontrib-autoprogram>=0.1.7 +sphinxext-opengraph +sphinxext-rediraffe diff --git a/docs/source/conf.py b/docs/source/conf.py index ade178ef..fc2aec09 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,8 +18,11 @@ author = "Project Jupyter Contributors" # extensions = [ "myst_parser", + "sphinx_copybutton", "sphinx.ext.extlinks", "sphinxcontrib.autoprogram", + "sphinxext.opengraph", + "sphinxext.rediraffe", ] root_doc = "index" source_suffix = [".md", ".rst"] @@ -87,3 +90,43 @@ html_context = { "github_version": "main", "doc_path": "docs/source", } + + +# -- Options for linkcheck builder ------------------------------------------- +# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder +# +linkcheck_ignore = [ + r"(.*)github\.com(.*)#", # javascript based anchors + r"(.*)/#%21(.*)/(.*)", # /#!forum/jupyter - encoded anchor edge case + r"https://github.com/[^/]*$", # too many github usernames / searches in changelog + "https://github.com/jupyterhub/repo2docker/pull/", # too many PRs in changelog + "https://github.com/jupyterhub/repo2docker/compare/", # too many comparisons in changelog +] +linkcheck_anchors_ignore = [ + "/#!", + "/#%21", +] + + +# -- Options for the opengraph extension ------------------------------------- +# ref: https://github.com/wpilibsuite/sphinxext-opengraph#options +# +# This extension help others provide better thumbnails and link descriptions +# when they link to this documentation from other websites, such as +# https://discourse.jupyter.org. +# +# ogp_site_url is set automatically by RTD +ogp_image = "_static/images/logo.png" +ogp_use_first_image = True + + +# -- Options for the rediraffe extension ------------------------------------- +# ref: https://github.com/wpilibsuite/sphinxext-rediraffe#readme +# +# This extensions help us relocated content without breaking links. If a +# document is moved internally, we should configure a redirect like below. +# +rediraffe_branch = "main" +rediraffe_redirects = { + # "old-file": "new-folder/new-file-name", +}