File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 4
4
from sphinx .errors import ExtensionError
5
5
import nbformat
6
6
from jupyter_client .kernelspec import get_kernel_spec , NoSuchKernel
7
+ from pathlib import Path
7
8
8
9
9
10
def blank_nb (kernel_name ):
@@ -74,12 +75,20 @@ def sphinx_abs_dir(env, *paths):
74
75
# output_directory / jupyter_execute / path relative to source directory
75
76
# Sphinx expects download links relative to source file or relative to
76
77
# source dir and prepended with '/'. We use the latter option.
77
- return "/" + os . path . relpath (
78
+ out_path = Path (
78
79
os .path .abspath (
79
80
os .path .join (output_directory (env ), os .path .dirname (env .docname ), * paths )
80
- ),
81
- os .path .abspath (env .app .srcdir ),
82
- )
81
+ )
82
+ ).as_posix ()
83
+
84
+ if os .name == "nt" :
85
+ # Can't get relative path between drives on Windows
86
+ return out_path
87
+
88
+ return "/" + os .path .relpath (
89
+ out_path ,
90
+ os .path .abspath (env .app .srcdir ),
91
+ )
83
92
84
93
85
94
def output_directory (env ):
You can’t perform that action at this time.
0 commit comments