diff --git a/docs/conf.py b/docs/conf.py index 882b7bb..fbd4fee 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,6 +42,27 @@ ) sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) + +def get_version_from_toml(): + """ + Returns the version from the pyproject.toml file. + Supports PEP 621 formats. Works with Python 3.10+. + """ + path = os.path.join(os.path.dirname(__file__), '..', 'pyproject.toml') + version = "2.0.0" + try: + 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", version)) + except Exception as e: + pass + return version + # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. @@ -78,7 +99,7 @@ # The short X.Y version. version = '1.8' # The full version, including alpha/beta/rc tags. -release = '1.8.1' +release = get_version_from_toml() # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.