diff --git a/docs/changelog.rst b/docs/changelog.rst index 54e11790..9eaedcee 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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 `_, `#7 `_). diff --git a/docs/conf.py b/docs/conf.py index 7fd51c08..09284efb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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) diff --git a/setup.py b/setup.py index 469533bf..7ebd515c 100755 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ author="Jan Holthuis", author_email="holthuis.jan@googlemail.com", 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"], diff --git a/sphinx_multiversion/sphinx.py b/sphinx_multiversion/sphinx.py index 10adcea8..df9f14db 100644 --- a/sphinx_multiversion/sphinx.py +++ b/sphinx_multiversion/sphinx.py @@ -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")