|
| 1 | +"""Sphinx configuration for the OntoEnv project.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import os |
| 6 | +import sys |
| 7 | +from pathlib import Path |
| 8 | + |
| 9 | +try: # Python 3.11+ |
| 10 | + import tomllib |
| 11 | +except ModuleNotFoundError: # pragma: no cover - fallback for older interpreters |
| 12 | + import tomli as tomllib # type: ignore |
| 13 | + |
| 14 | + |
| 15 | +ROOT = Path(__file__).resolve().parent.parent |
| 16 | +PROJECT_ROOT = ROOT |
| 17 | +PYTHON_SRC = PROJECT_ROOT / "python" |
| 18 | + |
| 19 | +# Ensure the Python bindings are importable when building docs locally. |
| 20 | +sys.path.insert(0, str(PYTHON_SRC)) |
| 21 | + |
| 22 | + |
| 23 | +def _read_version() -> str: |
| 24 | + """Read the workspace version from Cargo.toml for a single source of truth.""" |
| 25 | + cargo_toml = PROJECT_ROOT / "Cargo.toml" |
| 26 | + try: |
| 27 | + with cargo_toml.open("rb") as fh: |
| 28 | + cargo = tomllib.load(fh) |
| 29 | + return cargo.get("workspace", {}).get("package", {}).get("version", "0.0.0") |
| 30 | + except Exception: |
| 31 | + return "0.0.0" |
| 32 | + |
| 33 | + |
| 34 | +project = "OntoEnv" |
| 35 | +author = "OntoEnv developers" |
| 36 | +release = _read_version() |
| 37 | +version = release |
| 38 | + |
| 39 | +extensions = [ |
| 40 | + "sphinx.ext.autodoc", |
| 41 | + "sphinx.ext.autosummary", |
| 42 | + "sphinx.ext.napoleon", |
| 43 | + "sphinx.ext.intersphinx", |
| 44 | + "sphinx.ext.viewcode", |
| 45 | +] |
| 46 | + |
| 47 | +autosummary_generate = True |
| 48 | +autodoc_typehints = "description" |
| 49 | +autodoc_mock_imports = ["rdflib", "oxrdflib"] |
| 50 | + |
| 51 | +templates_path = ["_templates"] |
| 52 | +exclude_patterns: list[str] = [ |
| 53 | + "_build", |
| 54 | + "_doctrees", |
| 55 | + "Thumbs.db", |
| 56 | + ".DS_Store", |
| 57 | + ".venv", |
| 58 | + ".venv/**", |
| 59 | +] |
| 60 | + |
| 61 | +html_theme = "furo" |
| 62 | +html_static_path = ["_static"] |
| 63 | +html_title = "OntoEnv Documentation" |
| 64 | + |
| 65 | +intersphinx_mapping = { |
| 66 | + "python": ("https://docs.python.org/3", {}), |
| 67 | + "rdflib": ("https://rdflib.readthedocs.io/en/stable", {}), |
| 68 | +} |
0 commit comments