Skip to content

Commit

Permalink
Issue 1059: Fix downloadable abs path
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin DARNE <[email protected]>
  • Loading branch information
Paldari committed Nov 8, 2024
1 parent 6c2d102 commit de10ee0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sphinxcontrib/confluencebuilder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,19 @@ def find_env_abspath(env, out_dir, path: str) -> Path | None:
# later stage
return None

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

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

if new_path.is_file():
abs_path = new_path
if normalized_path.is_absolute():
abs_path = normalized_path
else:
abs_path = Path(env.srcdir, normalized_path)

Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/unit-tests/datasets/download/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ download
:download:`../../assets/example.pdf`

:download:`label<../../assets/example.pdf>`

:download:`files/example.pdf`

.. Absolute filename taken as relative to the top source directory
:download:`/files/example.pdf`

0 comments on commit de10ee0

Please sign in to comment.