Skip to content

Commit

Permalink
Fetch project information from pyproject.toml.
Browse files Browse the repository at this point in the history
  • Loading branch information
valberg committed Apr 4, 2022
1 parent 4c5aa6c commit 63b0122
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
28 changes: 14 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@
import sys
from pathlib import Path

import tomlkit

# -- Path setup --------------------------------------------------------------

here = Path(__file__).parent.resolve()
sys.path.insert(0, str(here / ".." / "src"))
sys.path.insert(0, str(here / ".."))

# -- Project information -----------------------------------------------------

project = "django-invitations"
copyright = "-"
author = "-"

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.

def _get_project_meta():
with open("../pyproject.toml") as pyproject:
file_contents = pyproject.read()

def _get_version() -> str:
lines = (here / ".." / "setup.cfg").read_text().splitlines()
version_lines = [line.strip() for line in lines if line.startswith("version = ")]
return tomlkit.parse(file_contents)["tool"]["poetry"]

assert len(version_lines) == 1
return version_lines[0].split(" = ")[1]

pkg_meta = _get_project_meta()
project = str(pkg_meta["name"])
copyright = "-"
author = "-"

version = _get_version()
# The short X.Y version
version = str(pkg_meta["version"])
# The full version, including alpha/beta/rc tags
release = version

# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
django
furo
sphinx
tomlkit

0 comments on commit 63b0122

Please sign in to comment.