CLI Usage ********* The "ontoenv" CLI wraps the Rust core with commands for discovering and materializing ontology imports. Install ======= cargo install ontoenv-cli # or from the workspace: cargo build -p ontoenv-cli --release ./target/release/ontoenv --help Common tasks ============ * "ontoenv init" — create a new ontology environment in the current directory. * "ontoenv add " — register an ontology; optionally fetch its imports. * "ontoenv update" — refresh cached ontologies. * "ontoenv dump" — export the current environment for inspection. Reference ========= Start by embedding the CLI help output as the reference page. Replace this block once you settle on a stable command set: $ ontoenv --help (paste the generated help text here) Getting Started *************** This section gives you a minimal checklist to build the documentation locally and wire it into your workflows. Install doc tooling with "uv" ============================= The docs have their own "docs/pyproject.toml". Create the env and install requirements with "uv": cd docs uv sync # creates docs/.venv and installs Sphinx + Furo If you prefer to reuse an existing environment, you can instead run "uv pip install -r docs/requirements.txt". Build the docs locally ====================== cd docs uv run sphinx-build -M html . _build open _build/html/index.html Or just run the helper from the repository root (it syncs deps, builds the extension, and renders HTML): ./builddocs Need a single text file for LLM ingestion? Use the alternate target: ./builddocs llms # writes docs/_build/llms.txt Python package in editable mode =============================== To build the extension module so "autodoc" can import "ontoenv": cd python uv run maturin develop CLI binary ========== You can install the Rust CLI from crates.io or build it from the workspace: cargo install ontoenv-cli # pulls the published binary # or, from the workspace: cargo build -p ontoenv-cli --release Publishing to GitHub Pages ========================== * Build with "uv run sphinx-build -M html . _build" (or from CI). * 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". * Remember to set the Pages source to "/docs" or the dedicated branch when you push to GitHub. OntoEnv Documentation ********************* *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. Need a plain-text snapshot for LLM ingestion? Grab llms.txt, a concatenated dump of the rendered docs. Contents ^^^^^^^^ * Getting Started * Install doc tooling with "uv" * Build the docs locally * Python package in editable mode * CLI binary * Publishing to GitHub Pages * Python API Reference * "ontoenv" module * CLI Usage * Install * Common tasks * Reference Python API Reference ******************** This section documents the Python bindings exposed by the "ontoenv" package. Regenerate the stubs after changing the Rust layer so that the signatures stay current. * "ontoenv" module "ontoenv" module **************** class ontoenv.OntoEnv(path=None, recreate=False, create_or_use_cached=False, read_only=False, search_directories=None, require_ontology_names=False, strict=False, offline=False, use_cached_ontologies=False, resolution_policy=Ellipsis, root=Ellipsis, includes=None, excludes=None, temporary=False, no_search=False) Bases: "object" add(location, overwrite=False, fetch_imports=True, force=False) Add a new ontology to the OntoEnv add_no_imports(location, overwrite=False, force=False) Add a new ontology to the OntoEnv without exploring owl:imports. close() dump(includes=None) Print the contents of the OntoEnv flush() get_closure(uri, destination_graph=None, rewrite_sh_prefixes=True, remove_owl_imports=True, recursion_depth=Ellipsis) Merge the imports closure of *uri* into a single graph and return it alongside the closure list. The first element of the returned tuple is either the provided *destination_graph* (after mutation) or a brand-new *rdflib.Graph*. The second element is an ordered list of ontology IRIs in the resolved closure starting with *uri*. Set *rewrite_sh_prefixes* or *remove_owl_imports* to control post- processing of the merged triples. get_dependencies_graph(graph, destination_graph=None, recursion_depth=Ellipsis, fetch_missing=False, rewrite_sh_prefixes=True, remove_owl_imports=True) Get the dependency closure of a given graph and return it as a new graph. This method will look for *owl:imports* statements in the provided *graph*, then find those ontologies within the *OntoEnv* and compute the full dependency closure. The triples of all ontologies in the closure are returned as a new graph. The original *graph* is left untouched unless you also supply it as the *destination_graph*. Parameters: * **graph** (*rdflib.Graph*) – The graph to find dependencies for. * **destination_graph** (*Optional**[**rdflib.Graph**]*) – If provided, the dependency graph will be added to this graph instead of creating a new one. * **recursion_depth** (*int*) – The maximum depth for recursive import resolution. A negative value (default) means no limit. * **fetch_missing** (*bool*) – If True, will fetch ontologies that are not in the environment. * **rewrite_sh_prefixes** (*bool*) – If True, will rewrite SHACL prefixes to be unique. * **remove_owl_imports** (*bool*) – If True, will remove *owl:imports* statements from the returned graph. Returns: A tuple containing the populated dependency graph and the sorted list of imported ontology IRIs. Return type: tuple[rdflib.Graph, list[str]] get_graph(uri) Get the graph with the given URI as an rdflib.Graph get_importers(uri) Get the names of all ontologies that import the given ontology get_ontology(uri) Get the ontology metadata with the given URI get_ontology_names() Get the names of all ontologies in the OntoEnv import_dependencies(graph, recursion_depth=Ellipsis, fetch_missing=False) Import the dependencies referenced by *owl:imports* triples in *graph*. When *fetch_missing* is true, the environment attempts to download unresolved imports before computing the closure. After merging the closure triples into *graph*, all *owl:imports* statements are removed. The returned list contains the deduplicated ontology IRIs that were successfully imported. import_graph(destination_graph, uri, recursion_depth=Ellipsis) is_offline() is_strict() list_closure(uri, recursion_depth=Ellipsis) List the ontologies in the imports closure of the given ontology no_search() requires_ontology_names() resolution_policy() set_no_search(no_search) set_offline(offline) set_require_ontology_names(require) set_resolution_policy(policy) set_strict(strict) store_path() to_rdflib_dataset() Convert the OntoEnv to an in-memory rdflib.Dataset populated with all named graphs update(all=False) class ontoenv.Ontology Bases: "object" id imports last_updated location name namespace_map version_properties ontoenv.run_cli(args) Run the Rust CLI implementation and return its process-style exit code.