Skip to content

Commit 689ff29

Browse files
authored
fix version wrangling in docs (#7600)
1 parent abc40ef commit 689ff29

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

.github/workflows/docs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ jobs:
4343
pip install --progress-bar=off -r requirements.txt
4444
echo '::endgroup::'
4545
46+
if [[ ${{ github.event_name }} == push && (${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*)) ]]; then
47+
echo '::group::Enable version string sanitization'
48+
# This environment variable just has to exist and must not be empty. The actual value is arbitrary.
49+
# See docs/source/conf.py for details
50+
export TORCHVISION_SANITIZE_VERSION_STR_IN_DOCS=1
51+
echo '::endgroup::'
52+
fi
53+
4654
# The runner does not have sufficient memory to run with as many processes as there are
4755
# cores (`-j auto`). Thus, we limit to a single process (`-j 1`) here.
4856
sed -i -e 's/-j auto/-j 1/' Makefile

docs/source/conf.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,15 @@
9292
# The version info for the project you're documenting, acts as replacement for
9393
# |version| and |release|, also used in various other places throughout the
9494
# built documents.
95-
#
96-
# The short X.Y version.
97-
version = "main (" + torchvision.__version__ + " )"
98-
# The full version, including alpha/beta/rc tags.
99-
release = "main"
100-
VERSION = os.environ.get("VERSION", None)
101-
if VERSION:
95+
# version: The short X.Y version.
96+
# release: The full version, including alpha/beta/rc tags.
97+
if os.environ.get("TORCHVISION_SANITIZE_VERSION_STR_IN_DOCS", None):
10298
# Turn 1.11.0aHASH into 1.11 (major.minor only)
103-
version = ".".join(version.split(".")[:2])
99+
version = release = ".".join(torchvision.__version__.split(".")[:2])
104100
html_title = " ".join((project, version, "documentation"))
105-
release = version
101+
else:
102+
version = f"main ({torchvision.__version__})"
103+
release = "main"
106104

107105

108106
# The language for content autogenerated by Sphinx. Refer to documentation

0 commit comments

Comments
 (0)