Преглед изворни кода

Merge branch 'bugfix/html_redirect' into 'master'

docs: fix html redirects not working

See merge request espressif/esp-idf!15928
Krzysztof Budzynski пре 4 година
родитељ
комит
75d9df0285
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      docs/conf_common.py

+ 8 - 0
docs/conf_common.py

@@ -165,3 +165,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]