diff options
Diffstat (limited to 'docs/_exts')
-rw-r--r-- | docs/_exts/redirects.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/_exts/redirects.py b/docs/_exts/redirects.py new file mode 100644 index 00000000000..4eb7b855b58 --- /dev/null +++ b/docs/_exts/redirects.py @@ -0,0 +1,19 @@ +import os + +redirects = [] + +def create_redirect(dst): + tpl = '<html><head><meta http-equiv="refresh" content="0; url={0}"><script>window.location.replace("{0}")</script></head></html>' + return tpl.format(dst) + +def create_redirects(app, docname): + if not app.builder.name == 'html': + return + for src, dst in redirects: + path = os.path.join(app.outdir, '{0}.html'.format(src)) + url = '{0}.html'.format(dst) + with open(path, 'w') as f: + f.write(create_redirect(url)) + +def setup(app): + app.connect('build-finished', create_redirects) |