diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d5aec182a70..f4cc76db05e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -43,6 +43,14 @@ jobs: pip install --progress-bar=off -r requirements.txt echo '::endgroup::' + if [[ ${{ github.event_name }} == push && (${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*)) ]]; then + echo '::group::Enable version string sanitization' + # This environment variable just has to exist and must not be empty. The actual value is arbitrary. + # See docs/source/conf.py for details + export TORCHVISION_SANITIZE_VERSION_STR_IN_DOCS=1 + echo '::endgroup::' + fi + # The runner does not have sufficient memory to run with as many processes as there are # cores (`-j auto`). Thus, we limit to a single process (`-j 1`) here. sed -i -e 's/-j auto/-j 1/' Makefile diff --git a/docs/source/conf.py b/docs/source/conf.py index 6d748f5b717..4bb75fe6eeb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -92,17 +92,15 @@ # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -# -# The short X.Y version. -version = "main (" + torchvision.__version__ + " )" -# The full version, including alpha/beta/rc tags. -release = "main" -VERSION = os.environ.get("VERSION", None) -if VERSION: +# version: The short X.Y version. +# release: The full version, including alpha/beta/rc tags. +if os.environ.get("TORCHVISION_SANITIZE_VERSION_STR_IN_DOCS", None): # Turn 1.11.0aHASH into 1.11 (major.minor only) - version = ".".join(version.split(".")[:2]) + version = release = ".".join(torchvision.__version__.split(".")[:2]) html_title = " ".join((project, version, "documentation")) - release = version +else: + version = f"main ({torchvision.__version__})" + release = "main" # The language for content autogenerated by Sphinx. Refer to documentation