Skip to content

Commit de10ee0

Browse files
committed
Issue 1059: Fix downloadable abs path
Signed-off-by: Kevin DARNE <[email protected]>
1 parent 6c2d102 commit de10ee0

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

sphinxcontrib/confluencebuilder/util.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,19 @@ def find_env_abspath(env, out_dir, path: str) -> Path | None:
257257
# later stage
258258
return None
259259

260-
if normalized_path.is_absolute():
261-
abs_path = normalized_path
260+
# some generated nodes will prefix the path of an asset with `/`,
261+
# with the intent of that path being the root from the
262+
# configured source directory instead of an absolute path on the
263+
# system -- check the environment's source directory first before
264+
# checking the full system's path
265+
if normalized_path.parts[0] == os.sep:
266+
abs_path = Path(env.srcdir, *normalized_path.parts[1:])
262267

263-
# some generated nodes will prefix the path of an asset with `/`,
264-
# with the intent of that path being the root from the
265-
# configured source directory instead of an absolute path on the
266-
# system -- check the environment's source directory first before
267-
# checking the full system's path
268-
if normalized_path.name[0] == os.sep:
269-
new_path = Path(env.srcdir, normalized_path.name[1:])
268+
if abs_path.is_file():
269+
return abs_path
270270

271-
if new_path.is_file():
272-
abs_path = new_path
271+
if normalized_path.is_absolute():
272+
abs_path = normalized_path
273273
else:
274274
abs_path = Path(env.srcdir, normalized_path)
275275

4.27 KB
Binary file not shown.

tests/unit-tests/datasets/download/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ download
88
:download:`../../assets/example.pdf`
99

1010
:download:`label<../../assets/example.pdf>`
11+
12+
:download:`files/example.pdf`
13+
14+
.. Absolute filename taken as relative to the top source directory
15+
16+
:download:`/files/example.pdf`

0 commit comments

Comments
 (0)