Skip to content

Commit 2a40b4a

Browse files
committed
touch the dowload file
1 parent 3633ed1 commit 2a40b4a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

jupyter_sphinx/ast.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ def run(self):
405405
download_file = self.target + ext
406406
reftarget=os.path.realpath(os.path.join(output_dir, download_file))
407407
# touch the path, so that it can be found by the download collector
408-
pathlib.Path(reftarget).touch()
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
409412
node = download_reference(self.rawtext, reftarget=reftarget)
410413
self.set_source_info(node)
411414
title = self.title if self.has_explicit_title else download_file

tests/test_execute.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,14 @@ def test_image_mimetype_uri(doctree):
574574
('../nb_name', '/jupyter_execute/path/nb_name.ipynb', '../nb_name.ipynb'),
575575
('text <nb_name>', '/jupyter_execute/path/to/nb_name.ipynb', 'text'),
576576
))
577-
def test_download_role(text, reftarget, caption):
577+
def test_download_role(text, reftarget, caption, tmp_path):
578578
role = JupyterDownloadRole()
579579
mock_inliner = Mock()
580580
config = {
581-
'document.settings.env.app.outdir': 'outdir',
581+
'document.settings.env.app.outdir': str(tmp_path),
582582
'document.settings.env.docname': 'path/to/docname',
583-
'document.settings.env.app.srcdir': 'srcdir',
583+
'document.settings.env.srcdir': str(tmp_path),
584+
'document.settings.env.app.srcdir': str(tmp_path),
584585
'reporter.get_source_and_line': lambda l: ('source', l)
585586
}
586587
mock_inliner.configure_mock(**config)

0 commit comments

Comments
 (0)