Skip to content

Commit e7dfaff

Browse files
committed
Fix handling of absolute paths
1 parent 9a79660 commit e7dfaff

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

docs/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ Changelog
77
Version 0.2
88
===========
99

10+
Version 0.2.1
11+
-------------
12+
13+
* Fix handling of absolute output paths in `vpathto` and ensure that all generated paths are relative.
14+
15+
16+
Version 0.2.0
17+
-------------
18+
1019
* Added a way to override config variables using placeholders that expand to each version's actual value (`#4 <issue4_>`_, `#7 <issue7_>`_).
1120

1221

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
author = "Jan Holthuis"
66
project = "sphinx-multiversion"
7-
release = "0.2.0"
7+
release = "0.2.1"
88
version = "0.2"
99
copyright = "{}, {}".format(time.strftime("%Y"), author)
1010

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
author="Jan Holthuis",
2121
author_email="holthuis.jan@googlemail.com",
2222
url="https://holzhaus.github.io/sphinx-multiversion/",
23-
version="0.2.0",
23+
version="0.2.1",
2424
install_requires=["sphinx >= 2.1"],
2525
license="BSD",
2626
packages=["sphinx_multiversion"],

sphinx_multiversion/sphinx.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,31 @@ def vpathto(self, other_version_name):
9999

100100
# Find output root
101101
current_version = self.metadata[self.current_version_name]
102-
relpath = pathlib.PurePath(current_version["outputdir"])
103-
relpath_dir = relpath.joinpath(self.context["pagename"]).parent
104-
outputroot = os.path.join(*(".." for x in relpath_dir.parts))
102+
other_version = self.metadata[other_version_name]
103+
outputroot = os.path.commonpath(
104+
(current_version["outputdir"], other_version["outputdir"])
105+
)
106+
107+
current_outputroot = pathlib.PurePath(
108+
current_version["outputdir"]
109+
).relative_to(outputroot)
110+
other_outputroot = pathlib.PurePath(
111+
other_version["outputdir"]
112+
).relative_to(outputroot)
113+
114+
relative_path_to_outputroot = os.path.join(
115+
*(
116+
".."
117+
for x in current_outputroot.joinpath(
118+
self.context["pagename"]
119+
).parent.parts
120+
)
121+
)
105122

106123
# Find output dir of other version
107-
other_version = self.metadata[other_version_name]
108-
outputdir = posixpath.join(outputroot, other_version["outputdir"])
124+
outputdir = posixpath.join(
125+
relative_path_to_outputroot, other_outputroot
126+
)
109127

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

0 commit comments

Comments
 (0)