Skip to content

Commit 055d311

Browse files
authored
Merge pull request #26 from gtfierro/docs
Add Sphinx docs and Pages deployment workflow
2 parents 56e1d72 + fb636f5 commit 055d311

File tree

16 files changed

+801
-0
lines changed

16 files changed

+801
-0
lines changed

.github/workflows/pages.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Deploy Sphinx docs to GitHub Pages using the builddocs helper.
2+
name: Deploy docs to Pages
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
deploy:
20+
environment:
21+
name: github-pages
22+
url: ${{ steps.deployment.outputs.page_url }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Pages
29+
uses: actions/configure-pages@v5
30+
31+
- name: Install system dependencies
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y libssl-dev pkg-config
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.12"
40+
41+
- name: Install Rust toolchain
42+
uses: dtolnay/rust-toolchain@stable
43+
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v3
46+
with:
47+
version: "latest"
48+
49+
- name: Sync docs environment
50+
working-directory: docs
51+
env:
52+
UV_SYSTEM_RESOLVE: "0"
53+
run: uv sync --project .
54+
55+
- name: Install ontoenv into docs venv
56+
working-directory: docs
57+
env:
58+
UV_SYSTEM_RESOLVE: "0"
59+
run: uv pip install --project . -e ../python
60+
61+
- name: Build Sphinx HTML
62+
working-directory: docs
63+
env:
64+
UV_SYSTEM_RESOLVE: "0"
65+
run: uv run --project . sphinx-build -M html . _build
66+
67+
- name: Upload artifact
68+
uses: actions/upload-pages-artifact@v3
69+
with:
70+
path: docs/_build/html
71+
72+
- name: Deploy to GitHub Pages
73+
id: deployment
74+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
/target
22
.ontoenv
3+
docs/_build/
4+
docs/_doctrees/
5+
docs/.venv/
6+
.uv-cache/

builddocs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5+
export UV_CACHE_DIR="${UV_CACHE_DIR:-"$ROOT/.uv-cache"}"
6+
export UV_SYSTEM_RESOLVE="${UV_SYSTEM_RESOLVE:-0}"
7+
8+
pushd "$ROOT/docs"
9+
MODE="${1:-html}"
10+
if [[ "$MODE" != "html" && "$MODE" != "llms" ]]; then
11+
echo "Usage: $0 [html|llms]" >&2
12+
exit 64
13+
fi
14+
15+
# Ensure the docs environment is provisioned.
16+
uv sync --project .
17+
18+
# Install the Python extension into the docs venv so autodoc can import it.
19+
uv pip install --project . -e "$ROOT/python"
20+
21+
if [[ "$MODE" == "html" ]]; then
22+
uv run --project . sphinx-build -M html . _build
23+
else
24+
uv run --project . sphinx-build -M text . _build
25+
find _build/text -name '*.txt' -print | sort | xargs cat > _build/llms.txt
26+
echo "Wrote _build/llms.txt"
27+
fi
28+
popd

docs/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Minimal Makefile for Sphinx documentation
2+
SPHINXBUILD ?= sphinx-build
3+
SOURCEDIR = .
4+
BUILDDIR = _build
5+
6+
.PHONY: help clean html llms
7+
8+
help:
9+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)"
10+
11+
html:
12+
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)"
13+
14+
# Produce a single concatenated text file for LLM ingestion.
15+
llms:
16+
@$(SPHINXBUILD) -M text "$(SOURCEDIR)" "$(BUILDDIR)"
17+
@find "$(BUILDDIR)/text" -name '*.txt' -print | sort | xargs cat > "$(BUILDDIR)/llms.txt"
18+
@echo "Wrote $(BUILDDIR)/llms.txt"
19+
20+
clean:
21+
rm -rf "$(BUILDDIR)"

docs/_static/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

docs/_templates/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

docs/cli/index.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CLI Usage
2+
=========
3+
4+
The ``ontoenv`` CLI wraps the Rust core with commands for discovering and materializing ontology imports.
5+
6+
Install
7+
-------
8+
9+
.. code-block:: bash
10+
11+
cargo install ontoenv-cli
12+
# or from the workspace:
13+
cargo build -p ontoenv-cli --release
14+
./target/release/ontoenv --help
15+
16+
Common tasks
17+
------------
18+
19+
- ``ontoenv init`` — create a new ontology environment in the current directory.
20+
- ``ontoenv add <path-or-iri>`` — register an ontology; optionally fetch its imports.
21+
- ``ontoenv update`` — refresh cached ontologies.
22+
- ``ontoenv dump`` — export the current environment for inspection.
23+
24+
Reference
25+
---------
26+
27+
Start by embedding the CLI help output as the reference page. Replace this block once you settle on a stable command set:
28+
29+
.. code-block:: text
30+
31+
$ ontoenv --help
32+
(paste the generated help text here)
33+

docs/conf.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
}

docs/getting-started.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Getting Started
2+
===============
3+
4+
This section gives you a minimal checklist to build the documentation locally and wire it into your workflows.
5+
6+
Install doc tooling with ``uv``
7+
----------------------------------------
8+
9+
The docs have their own ``docs/pyproject.toml``. Create the env and install requirements with ``uv``:
10+
11+
.. code-block:: bash
12+
13+
cd docs
14+
uv sync # creates docs/.venv and installs Sphinx + Furo
15+
16+
If you prefer to reuse an existing environment, you can instead run ``uv pip install -r docs/requirements.txt``.
17+
18+
Build the docs locally
19+
----------------------
20+
21+
.. code-block:: bash
22+
23+
cd docs
24+
uv run sphinx-build -M html . _build
25+
open _build/html/index.html
26+
27+
Or just run the helper from the repository root (it syncs deps, builds the extension, and renders HTML):
28+
29+
.. code-block:: bash
30+
31+
./builddocs
32+
33+
Need a single text file for LLM ingestion? Use the alternate target:
34+
35+
.. code-block:: bash
36+
37+
./builddocs llms # writes docs/_build/llms.txt
38+
39+
Python package in editable mode
40+
-------------------------------
41+
42+
To build the extension module so ``autodoc`` can import ``ontoenv``:
43+
44+
.. code-block:: bash
45+
46+
cd python
47+
uv run maturin develop
48+
49+
CLI binary
50+
----------
51+
52+
You can install the Rust CLI from crates.io or build it from the workspace:
53+
54+
.. code-block:: bash
55+
56+
cargo install ontoenv-cli # pulls the published binary
57+
# or, from the workspace:
58+
cargo build -p ontoenv-cli --release
59+
60+
Publishing to GitHub Pages
61+
--------------------------
62+
63+
- Build with ``uv run sphinx-build -M html . _build`` (or from CI).
64+
- Publish the contents of ``docs/_build/html`` to your Pages branch (e.g., ``gh-pages``) or configure Pages to read from ``docs`` if you use ``sphinx-build -M dirhtml``.
65+
- Remember to set the Pages source to ``/docs`` or the dedicated branch when you push to GitHub.

docs/index.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
OntoEnv Documentation
2+
=====================
3+
4+
`OntoEnv` is a lightweight environment manager for RDF ontologies. The project ships a Rust core, a Python package, and a CLI so you can fetch, inspect, and reuse ontology imports from scripts or the command line.
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
:caption: Contents
9+
10+
getting-started
11+
python-api/index
12+
cli/index
13+

0 commit comments

Comments
 (0)