From d1dc4288202e6be1e1570e9adeb990f4c28c18b3 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Fri, 12 Nov 2021 17:20:03 +0800 Subject: [PATCH] docs: fix html redirects not working HTML redirects for docs broke during migration to esp-docs. --- docs/conf_common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/conf_common.py b/docs/conf_common.py index 932d20dc76..03b607556b 100644 --- a/docs/conf_common.py +++ b/docs/conf_common.py @@ -171,3 +171,11 @@ languages = ['en', 'zh_CN'] google_analytics_id = os.environ.get('CI_GOOGLE_ANALYTICS_ID', None) project_homepage = 'https://github.com/espressif/esp-idf' + +# Custom added feature to allow redirecting old URLs +with open('../page_redirects.txt') as f: + lines = [re.sub(' +', ' ', line.strip()) for line in f.readlines() if line.strip() != '' and not line.startswith('#')] + for line in lines: # check for well-formed entries + if len(line.split(' ')) != 2: + raise RuntimeError('Invalid line in page_redirects.txt: %s' % line) +html_redirect_pages = [tuple(line.split(' ')) for line in lines]