diff --git a/.gitignore b/.gitignore index 9104d6592e..41c58947cd 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ google_fonts/ node_modules/ docs/build/ docs/_templates/layout.html +docs/_templates/footer.html diff --git a/docs/utils.py b/docs/utils.py index adabac56fc..571327dec2 100644 --- a/docs/utils.py +++ b/docs/utils.py @@ -30,26 +30,44 @@ def generate_substitutions(dictionary): def patch_theme_template(app, templates_path): package_path = Path(sphinx_rtd_theme.__file__) - source_file_path = package_path.parent / 'layout.html' - destination_path = Path(app.srcdir) / templates_path - destination_file_path = destination_path / 'layout.html' + template_files = ('footer.html', 'layout.html',) + replace_list=[ + { + 'filename_pattern': 'footer.html', + 'content_patterns': [ + { + 'search': '{{ _(\'Next\') }}', + 'replace': '{{ next.title }}', + }, + { + 'search': '{{ _(\'Previous\') }}', + 'replace': '{{ prev.title }}', + }, + ] + }, + { + 'filename_pattern': 'layout.html', + 'content_patterns': [ + { + 'search': '\n \n\n
', + 'replace': '{% include "message_area.html" %}\n \n\n
', + }, + ] + } + ] + + for template_file in template_files: + source_file_path = package_path.parent / template_file#'layout.html' + destination_path = Path(app.srcdir) / templates_path + destination_file_path = destination_path / template_file#'layout.html' + + with source_file_path.open(mode='r') as source_file_object: + with destination_file_path.open(mode='w+') as destination_file_object: + shutil.copyfileobj( + fsrc=source_file_object, fdst=destination_file_object + ) - with source_file_path.open(mode='r') as source_file_object: - with destination_file_path.open(mode='w+') as destination_file_object: - shutil.copyfileobj( - fsrc=source_file_object, fdst=destination_file_object - ) patch_files( - path=destination_path, replace_list=[ - { - 'filename_pattern': 'layout.html', - 'content_patterns': [ - { - 'search': '\n \n\n
', - 'replace': '{% include "message_area.html" %}\n \n\n
', - }, - ] - } - ] + path=destination_path, replace_list=replace_list )