Skip to content

Commit

Permalink
docs: update configuration and improve documentation structure
Browse files Browse the repository at this point in the history
feat(docs/conf.py): dynamically read version and git hash for release info
refactor(docs/coordinates.rst): simplify section title for clarity
chore(pyproject.toml): add tomli as a dependency for version parsing
  • Loading branch information
yxlao committed Dec 28, 2024
1 parent ca3b7ac commit 170ba87
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
26 changes: 23 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/coordinates.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ docs = [
"sphinx-rtd-theme",
"myst-parser",
"furo",
"tomli",
]
torch = [
"torch>=1.8.0",
Expand Down

0 comments on commit 170ba87

Please sign in to comment.