Skip to content

Commit

Permalink
Fix handling of absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Apr 19, 2020
1 parent 9a79660 commit e7dfaff
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
9 changes: 9 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ Changelog
Version 0.2
===========

Version 0.2.1
-------------

* Fix handling of absolute output paths in `vpathto` and ensure that all generated paths are relative.


Version 0.2.0
-------------

* Added a way to override config variables using placeholders that expand to each version's actual value (`#4 <issue4_>`_, `#7 <issue7_>`_).


Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

author = "Jan Holthuis"
project = "sphinx-multiversion"
release = "0.2.0"
release = "0.2.1"
version = "0.2"
copyright = "{}, {}".format(time.strftime("%Y"), author)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
author="Jan Holthuis",
author_email="[email protected]",
url="https://holzhaus.github.io/sphinx-multiversion/",
version="0.2.0",
version="0.2.1",
install_requires=["sphinx >= 2.1"],
license="BSD",
packages=["sphinx_multiversion"],
Expand Down
28 changes: 23 additions & 5 deletions sphinx_multiversion/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,31 @@ def vpathto(self, other_version_name):

# Find output root
current_version = self.metadata[self.current_version_name]
relpath = pathlib.PurePath(current_version["outputdir"])
relpath_dir = relpath.joinpath(self.context["pagename"]).parent
outputroot = os.path.join(*(".." for x in relpath_dir.parts))
other_version = self.metadata[other_version_name]
outputroot = os.path.commonpath(
(current_version["outputdir"], other_version["outputdir"])
)

current_outputroot = pathlib.PurePath(
current_version["outputdir"]
).relative_to(outputroot)
other_outputroot = pathlib.PurePath(
other_version["outputdir"]
).relative_to(outputroot)

relative_path_to_outputroot = os.path.join(
*(
".."
for x in current_outputroot.joinpath(
self.context["pagename"]
).parent.parts
)
)

# Find output dir of other version
other_version = self.metadata[other_version_name]
outputdir = posixpath.join(outputroot, other_version["outputdir"])
outputdir = posixpath.join(
relative_path_to_outputroot, other_outputroot
)

if not self.vhasdoc(other_version_name):
return posixpath.join(outputdir, "index.html")
Expand Down

0 comments on commit e7dfaff

Please sign in to comment.