Commit c9c2ee2f authored by Stefan Behnel's avatar Stefan Behnel

Minor code cleanup.

parent 85431da6
...@@ -479,22 +479,25 @@ html_template = """ ...@@ -479,22 +479,25 @@ html_template = """
</html> </html>
""" """
list_redirects = [('reference/language_basics', 'userguide/language_basics')] list_redirects = [
('reference/language_basics', 'userguide/language_basics'),
]
def add_legacy_redirects(app, docname): def add_legacy_redirects(app, docname):
if app.builder.name == 'html': if app.builder.name != 'html':
for old_link, new_link in list_redirects: return
old_link = "src/" + old_link + ".html" for old_link, new_link in list_redirects:
new_link = "src/" + new_link + ".html" old_link = "src/" + old_link + ".html"
new_link = "src/" + new_link + ".html"
rel_path = os.path.relpath(new_link, os.path.dirname(old_link)) rel_path = os.path.relpath(new_link, os.path.dirname(old_link))
html_to_write = html_template.format(rel_path) html_to_write = html_template.format(rel_path)
target_path = app.outdir + '/' + old_link target_path = app.outdir + '/' + old_link
with open(target_path, "w+") as f: with open(target_path, "w+") as f:
f.write(html_to_write) f.write(html_to_write)
def setup(app): def setup(app):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment