Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Templates: Expose full sphinx version tuple #9447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion doc/templating.rst
Expand Up @@ -371,7 +371,16 @@ in the future.

.. data:: sphinx_version

The version of Sphinx used to build.
The version of Sphinx used to build represented as a string for example "3.5.1".

.. data:: sphinx_version_tuple

The version of Sphinx used to build represented as a tuple of five elements.
For Sphinx version 3.5.1 beta 3 this would be `(3, 5, 1, 'beta', 3)``.
The fourth element can be one of: ``alpha``, ``beta``, ``rc``, ``final``.
``final`` always has 0 as the last element.

.. versionadded:: 4.2

.. data:: style

Expand Down
2 changes: 2 additions & 0 deletions sphinx/builders/html/__init__.py
Expand Up @@ -26,6 +26,7 @@
from docutils.utils import relative_path

from sphinx import __display_version__, package_dir
from sphinx import version_info as sphinx_version
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.config import ENUM, Config
Expand Down Expand Up @@ -509,6 +510,7 @@ def prepare_writing(self, docnames: Set[str]) -> None:
'language': self.config.language,
'css_files': self.css_files,
'sphinx_version': __display_version__,
'sphinx_version_tuple': sphinx_version,
'style': self._get_style_filename(),
'rellinks': rellinks,
'builder': self.name,
Expand Down