Skip to content

Commit 510f548

Browse files
committed
fix!
1 parent 9118449 commit 510f548

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

jupyter_sphinx/ast.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,8 @@ def run(self):
401401

402402
assert filetype in ("notebook", "nb", "script")
403403
ext = ".ipynb" if filetype in ("notebook", "nb") else ".py"
404-
output_dir = sphinx_abs_dir(self.env)
405404
download_file = self.target + ext
406-
reftarget=os.path.realpath(os.path.join(output_dir, download_file))
407-
# touch the path, so that it can be found by the download collector
408-
path = pathlib.Path(self.env.srcdir).joinpath(reftarget[1:])
409-
path.parent.mkdir(parents=True, exist_ok=True)
410-
path.touch()
411-
# make the nodes
405+
reftarget = sphinx_abs_dir(self.env, download_file)
412406
node = download_reference(self.rawtext, reftarget=reftarget)
413407
self.set_source_info(node)
414408
title = self.title if self.has_explicit_title else download_file

jupyter_sphinx/execute.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
default_notebook_names,
2323
output_directory,
2424
split_on,
25-
sphinx_abs_dir,
2625
blank_nb,
2726
)
2827
from .ast import (

jupyter_sphinx/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ def language_info(executor):
6969
return info_msg["content"]["language_info"]
7070

7171

72-
def sphinx_abs_dir(env):
72+
def sphinx_abs_dir(env, *paths):
7373
# We write the output files into
7474
# output_directory / jupyter_execute / path relative to source directory
7575
# Sphinx expects download links relative to source file or relative to
7676
# source dir and prepended with '/'. We use the latter option.
7777
return "/" + os.path.relpath(
7878
os.path.abspath(
79-
os.path.join(output_directory(env), os.path.dirname(env.docname))
79+
os.path.join(output_directory(env), os.path.dirname(env.docname), *paths)
8080
),
8181
os.path.abspath(env.app.srcdir),
8282
)

tests/test_execute.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ def test_image_mimetype_uri(doctree):
570570

571571

572572
@pytest.mark.parametrize('text,reftarget,caption', (
573-
('nb_name', '/jupyter_execute/path/to/nb_name.ipynb', 'nb_name.ipynb'),
574-
('../nb_name', '/jupyter_execute/path/nb_name.ipynb', '../nb_name.ipynb'),
575-
('text <nb_name>', '/jupyter_execute/path/to/nb_name.ipynb', 'text'),
573+
('nb_name', '/../jupyter_execute/path/to/nb_name.ipynb', 'nb_name.ipynb'),
574+
('../nb_name', '/../jupyter_execute/path/nb_name.ipynb', '../nb_name.ipynb'),
575+
('text <nb_name>', '/../jupyter_execute/path/to/nb_name.ipynb', 'text'),
576576
))
577577
def test_download_role(text, reftarget, caption, tmp_path):
578578
role = JupyterDownloadRole()

0 commit comments

Comments
 (0)