Repository: pytorch/vision

Issue:
Extra dot in 0.12 docs
Looks like something similar to the previous release happened https://github.com/pytorch/vision/issues/4754

The newly pushed docs are https://pytorch.org/vision/0.12./ instead of https://pytorch.org/vision/0.12 (extra dot at the end), and the version tag shows a lot of extra info:

![image](https://user-images.githubusercontent.com/1190450/157628238-5e10b9ce-3e7f-4364-8822-ac838023bbab.png)


@mattip  is this something you could help us with, like you did in https://github.com/pytorch/vision/pull/4755 ?


Discussion:
I wonder how this happened. Do you have the build log from the ci run kicked off by tagging the repo?
> I wonder how this happened. Do you have the build log from the ci run kicked off by tagging the repo?

CC @brianjo 
There are two problems: the version should not be `main (0.12.0a0+9b5a3fe)` and the directory should not be `1.12.` (with a dot).

The first problem:
----------------
[here](https://app.circleci.com/pipelines/github/pytorch/vision/15537/workflows/079b1836-52a8-494a-bfd8-08bd0b32e4e3/jobs/1255738) is the run, with `VERSION=0.12.0`. But this is not used to change the version from `main (0.12.0a0+9b5a3fe)` into `1.12`. In pytorch, the [conf.py](https://github.com/pytorch/vision/blob/d0dede0e09d6d72253080cb366742a270f0ea8cd/docs/source/conf.py#L84) file was changed to avoid the name mangling. It now uses `RELEASE` and [has this](https://github.com/pytorch/pytorch/blob/bd13bc667e9a56e95b14bb3da88f170548880b91/docs/source/conf.py#L331) (paraphrasing):
```
RELEASE = os.environ.get('RELEASE', False)
version = 'master (' + torch_version + ' )'
release = 'master'
if RELEASE:
    # Turn 1.11.0aHASH into 1.11
    version = '.'.join(torch_version.split('.')[:2])
    html_title = " ".join((project, version, "documentation"))
    release = version

``` 

The second problem
------------
The script to commit the documents is [using](https://github.com/pytorch/vision/blob/d0dede0e09d6d72253080cb366742a270f0ea8cd/.circleci/config.yml#L1072) `tag=${CIRCLE_TAG:1:5}` instead of a more [clever regex](https://github.com/pytorch/pytorch/blob/bd13bc667e9a56e95b14bb3da88f170548880b91/.circleci/config.yml#L1127) `tag=$(echo $CIRCLE_TAG | sed -e 's/v*\([0-9]*\.[0-9]*\).*/\1/')`. So the tag `1.12.0` is turned into `1.12.` (5 characters) instead of `1.12`.


I will make a PR to fix this. Then the next tag (the release?) will (hopefully) build the proper documents.

Resolving patch:
diff --git a/docs/source/conf.py b/docs/source/conf.py
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -20,6 +20,8 @@
 # import sys
 # sys.path.insert(0, os.path.abspath('.'))
 
+import os
+
 import pytorch_sphinx_theme
 import torchvision
 
@@ -80,11 +82,16 @@
 # built documents.
 #
 # The short X.Y version.
-# TODO: change to [:2] at v1.0
 version = "main (" + torchvision.__version__ + " )"
 # The full version, including alpha/beta/rc tags.
-# TODO: verify this works as expected
 release = "main"
+VERSION = os.environ.get("VERSION", None)
+if VERSION:
+    # Turn 1.11.0aHASH into 1.11 (major.minor only)
+    version = ".".join(version.split(".")[:2])
+    html_title = " ".join((project, version, "documentation"))
+    release = version
+
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


Test patch: