Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Major changes
Minor changes
.............

- Read version from :file:`pyproject.toml` for documentation. [:issue:`103` by @0jc1 and @stevepiercy]
- Fix author email format. [:issue:`99` by @gboutry and @stevepiercy]
- Drop deprecated license classifier. [:issue:`101` by @gboutry]
- Use ``--allow-existing`` argument in the ``dev`` make target to avoid recreating a virtual environment with uv. [:pull:`123` by @stevepiercy]
Expand Down
20 changes: 17 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@
)
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))


def get_version_from_toml() -> str:
"""
Returns the version from the :file:`pyproject.toml` file.
Supports :pep:`621` formats. Works with Python 3.10+.
"""
path = os.path.join(os.path.dirname(__file__), "..", "pyproject.toml")
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

with open(path, "rb") as f:
data = tomllib.load(f)
return str(data.get("project", {}).get("version"))

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down Expand Up @@ -75,10 +91,8 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.8'
# The full version, including alpha/beta/rc tags.
release = '1.8.1'
version = release = get_version_from_toml()

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dev = [
"flask>=3.1.2",
"pytest>=9.0.2",
"sphinx-autobuild>=2024.10.3",
"tomli>=2.0; python_version < '3.11'",
"tornado>=6.5.4",
]

Expand Down
2 changes: 2 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.