Get version in docs config

This commit is contained in:
Eugenio Lacuesta 2020-04-10 16:48:42 -03:00
parent f97fec5ebd
commit 24a1d9acae
No known key found for this signature in database
GPG Key ID: DA3EF2D0913E9810
1 changed files with 7 additions and 4 deletions

View File

@ -14,6 +14,7 @@
import sys
from datetime import datetime
from os import path
from pathlib import Path
# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
@ -59,10 +60,10 @@ copyright = '2008{}, Scrapy developers'.format(datetime.now().year)
#
# The short X.Y version.
try:
import scrapy
version = '.'.join(map(str, scrapy.version_info[:2]))
release = scrapy.__version__
except ImportError:
version_path = Path(__file__).parent.absolute().parent.joinpath("scrapy/VERSION")
version = version_path.read_text().strip()
release = version.rsplit(".", 1)[0]
except Exception:
version = ''
release = ''
@ -295,3 +296,5 @@ intersphinx_mapping = {
# ------------------------------------
hoverxref_auto_ref = True
hoverxref_project = "scrapy"
hoverxref_version = release