26 February 2025, 01:43 (GMT)
25 February 2025, 22:32 (GMT)
Default env vars in Read the Docs
Read the Docs (RTD) defines some default environmental variables. These can be grabbed when building a static site.
To get the version, add this to the conf.py
of a Sphinx project:
import os
version = os.getenv("READTHEDOCS_VERSION")
html_context = {
"version": version,
}
This can then be injected into a HTML template:
<p>Docs for release: {{ version }}.</p>