From 46d5d3c6b7d1bcea1af3ad1bbb2011e63ad735de Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Fri, 22 Feb 2019 23:13:02 +0300 Subject: [PATCH] Improve static files copier --- source/_config.yml => _config.yml | 0 source/conf.py | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) rename source/_config.yml => _config.yml (100%) diff --git a/source/_config.yml b/_config.yml similarity index 100% rename from source/_config.yml rename to _config.yml diff --git a/source/conf.py b/source/conf.py index 371374a..9d638ca 100644 --- a/source/conf.py +++ b/source/conf.py @@ -13,7 +13,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os import sphinx_rtd_theme import datetime @@ -259,18 +258,31 @@ texinfo_documents = [ # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False -static_files = ['_config.yml', 'api.html', 'minecraft-auth.html', 'oauth.html', 'skin-system.html'] +static_files = [ + '../CNAME', + '../_config.yml', + 'api.html', + 'minecraft-auth.html', + 'oauth.html', + 'skin-system.html', +] from shutil import copyfile +from os import path +from sphinx.application import Sphinx def copy_static_files(app, _): + # type: (Sphinx, None) -> None if app.builder.name != 'html': return for src_name in static_files: - target_path = os.path.join(app.outdir, src_name) - src_path = os.path.join(app.srcdir, src_name) - if os.path.isfile(src_path): + src_path = path.join(app.srcdir, src_name) + target_path = path.join(app.outdir, src_name) + if path.dirname(path.normpath(target_path)) == path.dirname(app.outdir): + target_path = path.join(app.outdir, path.basename(target_path)) + + if path.isfile(src_path): copyfile(src_path, target_path) def setup(app):