Skip to content

Commit

Permalink
docs: fix build when async_timeout not installed
Browse files Browse the repository at this point in the history
Since we were importing `bleak` in conf.py, it required some runtime
dependencies to be installed. We can avoid this by just reading the
version from the pyproject.toml file instead.
  • Loading branch information
dlech committed Sep 21, 2022
1 parent 3c18090 commit d01fa05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import pathlib
import sys
import os

import tomli

PROJECT_ROOT_DIR = pathlib.Path(__file__).parent.parent.resolve()

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
# relative to the documentation root, use os.path.abspath to make it
Expand All @@ -31,7 +36,6 @@
# version is used.
sys.path.insert(0, project_root)

import bleak

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

Expand Down Expand Up @@ -61,10 +65,11 @@
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = bleak.__version__
# The full version, including alpha/beta/rc tags.
release = bleak.__version__
with open(PROJECT_ROOT_DIR / "pyproject.toml", "rb") as f:
release = tomli.load(f)["tool"]["poetry"]["version"]
# The short X.Y version.
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Sphinx==5.1.1
sphinx-rtd-theme==1.0.0
tomli==2.0.1

0 comments on commit d01fa05

Please sign in to comment.