Skip to content

Commit a0dcbd7

Browse files
committed
Do not overwrite files in _static if user already has custom versions of those files
1 parent a74b13e commit a0dcbd7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

jupyter_sphinx/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,30 @@ def builder_inited(app):
113113
app.add_js_file(embed_url)
114114

115115

116+
def copy_file(src, dst):
117+
if not (dst / src.name).exists():
118+
copy_asset(str(src), str(dst))
119+
120+
116121
def build_finished(app, env):
117122
if app.builder.format != "html":
118123
return
119124

120125
module_dir = Path(__file__).parent
121-
outdir = Path(app.outdir)
126+
static = Path(app.outdir) / "_static"
122127

123128
# Copy stylesheet
124-
src = module_dir / "css"
125-
dst = outdir / "_static"
126-
copy_asset(src, dst)
129+
src = module_dir / "css" / "jupyter-sphinx.css"
130+
copy_file(src, static)
127131

128132
thebe_config = app.config.jupyter_sphinx_thebelab_config
129133
if not thebe_config:
130134
return
131135

132136
# Copy all thebelab related assets
133-
src = module_dir / "thebelab"
134-
copy_asset(src, dst)
137+
src_dir = module_dir / "thebelab"
138+
for fname in ["thebelab-helper.js", "thebelab.css"]:
139+
copy_file(src_dir / fname, static)
135140

136141

137142
##############################################################################

0 commit comments

Comments
 (0)