diff --git a/docs/conf.py b/docs/conf.py index 8aa3ece2..fcf307bc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,13 +8,33 @@ import os import sys - -sys.path.insert(0, os.path.abspath("..")) +import subprocess +import tomli + +# Get script directory and workspace root +script_dir = os.path.dirname(os.path.abspath(__file__)) +workspace_root = os.path.abspath(os.path.join(script_dir, "..")) +sys.path.insert(0, workspace_root) + +# Read version from pyproject.toml +with open(os.path.join(workspace_root, "pyproject.toml"), "r", encoding="utf-8") as f: + pyproject = tomli.loads(f.read()) +version = pyproject["project"]["version"] + +# Get git commit hash +try: + git_hash = ( + subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) + .decode("ascii") + .strip() + ) + release = f"{version}+{git_hash}" +except subprocess.CalledProcessError: + release = version project = "CamTools" copyright = "2024, Yixing Lao" author = "Yixing Lao" -release = "0.1" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/coordinates.rst b/docs/coordinates.rst index 15e12de3..512268b1 100644 --- a/docs/coordinates.rst +++ b/docs/coordinates.rst @@ -1,5 +1,5 @@ -Camera Coordinate System -======================== +Camera Coordinates +================== A homogeneous point ``[X, Y, Z, 1]`` in the world coordinate can be projected to a homogeneous point ``[x, y, 1]`` in the image (pixel) coordinate using the diff --git a/pyproject.toml b/pyproject.toml index d6dab6d2..67401617 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,7 @@ docs = [ "sphinx-rtd-theme", "myst-parser", "furo", + "tomli", ] torch = [ "torch>=1.8.0",