From cee0e75566229ebbdce8437bbc2676cb13c86896 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 12 Jul 2023 17:08:48 -0400 Subject: [PATCH] docs: Add config for redirecting pages. We want to be able to move pages around and have sphinx automatically redirect to the now location when that happens. This will allow us to re-organize safely as we figure out the best way to layout the documentation. --- docs/guides/Makefile | 8 ++++++++ docs/guides/conf.py | 5 +++++ docs/guides/redirects.txt | 0 requirements/edx/doc.in | 1 + 4 files changed, 14 insertions(+) create mode 100644 docs/guides/redirects.txt diff --git a/docs/guides/Makefile b/docs/guides/Makefile index 1168ab7066..3c8a65d81c 100644 --- a/docs/guides/Makefile +++ b/docs/guides/Makefile @@ -20,3 +20,11 @@ clean: # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +update_redirects: + # This updates redirects.txt, creating redirects for any files that have moved (relative to master). + sphinx-build -b rediraffewritediff "$(SOURCEDIR)" "$(BUILDDIR)" + +check_redirects: + # Check to make sure that any files that got moved have a redirect in redirects.txt + sphinx-build -b rediraffecheckdiff "$(SOURCEDIR)" "$(BUILDDIR)" diff --git a/docs/guides/conf.py b/docs/guides/conf.py index d4d8dc7897..b18de3c48d 100644 --- a/docs/guides/conf.py +++ b/docs/guides/conf.py @@ -62,11 +62,16 @@ extensions = [ 'sphinx.ext.mathjax', 'sphinx.ext.napoleon', 'sphinxcontrib.openapi', + 'sphinxext.rediraffe', 'sphinx_design', 'code_annotations.contrib.sphinx.extensions.featuretoggles', 'code_annotations.contrib.sphinx.extensions.settings', ] +# Rediraffe related settings. +rediraffe_redirects = "redirects.txt" +rediraffe_branch = 'origin/master' + # code_annotations.(featuretoggles|settings) related settings. edxplatform_repo_url = "https://github.com/openedx/edx-platform" edxplatform_source_path = os.path.abspath( diff --git a/docs/guides/redirects.txt b/docs/guides/redirects.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/requirements/edx/doc.in b/requirements/edx/doc.in index c4bef4d4fd..0dd7ad9aa6 100644 --- a/requirements/edx/doc.in +++ b/requirements/edx/doc.in @@ -7,3 +7,4 @@ gitpython # fetch git repo information Sphinx # Documentation builder sphinx-design # provides various responsive web-components sphinxcontrib-openapi[markdown] # Be able to render openapi schema in a sphinx project +sphinxext-rediraffe # Quickly and easily redirect when we move pages around.