Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4035baf

Browse files
committed
Only warn about existing redirects if content differs.
This allows you to re-run doc builds without cleaning.
1 parent bfdbb94 commit 4035baf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

doc/sphinxext/redirect_from.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ def _generate_redirects(app, exception):
7676
return
7777
for k, v in RedirectFrom.redirects.items():
7878
p = Path(app.outdir, k + builder.out_suffix)
79+
html = HTML_TEMPLATE.format(v=v)
7980
if p.is_file():
80-
logger.warning(f'A redirect-from directive is trying to create '
81-
f'{p}, but that file already exists (perhaps '
82-
f'you need to run "make clean")')
81+
if p.read_text() != html:
82+
logger.warning(f'A redirect-from directive is trying to '
83+
f'create {p}, but that file already exists '
84+
f'(perhaps you need to run "make clean")')
8385
else:
8486
p.parent.mkdir(parents=True, exist_ok=True)
8587
with p.open("x") as file:
8688
logger.info(f'making refresh html file: {k} redirect to {v}')
87-
file.write(HTML_TEMPLATE.format(v=v))
89+
file.write(html)

0 commit comments

Comments
 (0)