Patch footer documentation template

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-11-29 20:09:46 -04:00
parent 29c06e3f37
commit c8701d58c8
2 changed files with 38 additions and 19 deletions

1
.gitignore vendored
View File

@@ -34,3 +34,4 @@ google_fonts/
node_modules/ node_modules/
docs/build/ docs/build/
docs/_templates/layout.html docs/_templates/layout.html
docs/_templates/footer.html

View File

@@ -30,18 +30,21 @@ def generate_substitutions(dictionary):
def patch_theme_template(app, templates_path): def patch_theme_template(app, templates_path):
package_path = Path(sphinx_rtd_theme.__file__) package_path = Path(sphinx_rtd_theme.__file__)
source_file_path = package_path.parent / 'layout.html' template_files = ('footer.html', 'layout.html',)
destination_path = Path(app.srcdir) / templates_path replace_list=[
destination_file_path = destination_path / 'layout.html' {
'filename_pattern': 'footer.html',
with source_file_path.open(mode='r') as source_file_object: 'content_patterns': [
with destination_file_path.open(mode='w+') as destination_file_object: {
shutil.copyfileobj( 'search': '{{ _(\'Next\') }}',
fsrc=source_file_object, fdst=destination_file_object 'replace': '{{ next.title }}',
) },
{
patch_files( 'search': '{{ _(\'Previous\') }}',
path=destination_path, replace_list=[ 'replace': '{{ prev.title }}',
},
]
},
{ {
'filename_pattern': 'layout.html', 'filename_pattern': 'layout.html',
'content_patterns': [ 'content_patterns': [
@@ -52,4 +55,19 @@ def patch_theme_template(app, templates_path):
] ]
} }
] ]
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
)
patch_files(
path=destination_path, replace_list=replace_list
) )