Skip to content

Commit 5641adf

Browse files
committed
add redirects config to conf file
1 parent 4e58808 commit 5641adf

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/docsite/rst/conf.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
import os
2121
from pathlib import Path
2222

23+
import yaml
2324

2425
DOCS_ROOT_DIR = Path(__file__).parent.resolve()
2526

26-
sys.path.insert(0, str(DOCS_ROOT_DIR.parent / '_ext'))
27-
2827
# If your extensions are in another directory, add it here. If the directory
2928
# is relative to the documentation root, use os.path.abspath to make it
3029
# absolute, like shown here.
@@ -71,7 +70,7 @@
7170
'notfound.extension',
7271
'sphinx_antsibull_ext', # provides CSS for the plugin/module docs generated by antsibull
7372
'sphinx_copybutton',
74-
'ansible_redirects',
73+
'sphinx_reredirects', # redirects pages that have been restructured or removed
7574
]
7675

7776
# Later on, add 'sphinx.ext.viewcode' to the list if you want to have
@@ -379,7 +378,7 @@
379378
autoclass_content = 'both'
380379

381380
# Note: Our strategy for intersphinx mappings is to have the upstream build location as the
382-
# canonical source.
381+
# canonical source.
383382
intersphinx_mapping = {
384383
'python': ('https://docs.python.org/2/', None),
385384
'python3': ('https://docs.python.org/3/', None),
@@ -393,3 +392,13 @@
393392
]
394393
linkcheck_workers = 25
395394
# linkcheck_anchors = False
395+
396+
# Generate redirects for pages that have been restructured or moved
397+
# if EXTRA_TAGS="-t redirects" is passed with the make invocation
398+
redirects = {}
399+
if tags.has('redirects'):
400+
redirects_config_path = DOCS_ROOT_DIR.parent / "ansible_redirects.yaml"
401+
redirect_keys = yaml.safe_load(
402+
redirects_config_path.read_text(encoding="utf-8")
403+
)
404+
redirects = redirect_keys

0 commit comments

Comments
 (0)