Skip to content

Commit 282094d

Browse files
committed
use importlib.metadata to get project information for sphinx
Signed-off-by: Bradley Reynolds <[email protected]>
1 parent e5c3199 commit 282094d

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

docs/source/conf.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@
44
https://www.sphinx-doc.org/en/master/usage/configuration.html
55
"""
66

7-
from pathlib import Path
8-
9-
try:
10-
from tomllib import loads as toml_loads
11-
except ImportError:
12-
from toml import loads as toml_loads
13-
14-
from api import __version__
15-
16-
project_config = toml_loads(Path("../../pyproject.toml").read_text())
17-
project: str = project_config["project"]["name"]
18-
release: str = __version__
19-
REPO_LINK: str = project_config["project"]["urls"]["repository"]
20-
copyright: str = project_config["tool"]["sphinx"]["copyright"] # noqa: A001
21-
author: str = project_config["tool"]["sphinx"]["author"]
7+
from importlib.metadata import metadata
8+
9+
project_metadata = metadata("api.letsbuilda.dev")
10+
project: str = project_metadata["Name"]
11+
release: str = project_metadata["Version"]
12+
REPO_LINK: str = project_metadata["Project-URL"].replace("repository, ", "")
13+
copyright: str = "Let's build a ..." # noqa: A001
14+
author: str = "Let's build a ... community"
2215

2316
# Add any Sphinx extension module names here, as strings. They can be
2417
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ docs = [
3535
"furo",
3636
"sphinx-autoapi",
3737
"releases",
38-
"toml",
3938
]
4039

4140
[build-system]
@@ -45,10 +44,6 @@ build-backend = "setuptools.build_meta"
4544
[tool.setuptools.dynamic]
4645
version = { attr = "api.__version__" }
4746

48-
[tool.sphinx]
49-
copyright = "Let's build a ..."
50-
author = "Bradley Reynolds"
51-
5247
[tool.black]
5348
target-version = ["py310"]
5449
line-length = 120

0 commit comments

Comments
 (0)