Interactive ontology visualization, SHACL validation, and live TTL editing plugin for MkDocs
Project description
ontoink
Interactive ontology visualization, SHACL validation, and live TTL editing for MkDocs.
ontoink is a MkDocs plugin that transforms RDF/Turtle files into interactive, publication-ready ontology diagrams with SHACL constraint visualization. Write a simple code block in your markdown, and ontoink generates a fully interactive graph.
Features
Interactive Graph Visualization
- Formal ontology notation with distinct shapes per element type
- Hierarchical layout (dagre) optimized for ontology patterns
- Pan, zoom, fullscreen support
- Color-coded by ontology source (BFO, IAO, FOAF, Schema.org, etc.)
Visual Notation
| Element | Shape | Default Color |
|---|---|---|
| Class | Rectangle (solid border) | By ontology source |
| Individual | Ellipse | #E6E6E6 |
| Literal | Ellipse (dashed border) | #93D053 |
| Object Property | Blue solid line, filled arrow | #2563eb |
| Data Property | Green line, hollow arrow | #16a34a |
| rdf:type | Grey dashed line | #9ca3af |
| rdfs:subClassOf | Black solid line | #374151 |
| SHACL Constraint | Cyan dashed bold line | #0891b2 |
Click Popups
- Node label, type badge, full IRI (clickable)
- Copy Label / Copy IRI buttons
- Ontology source indicator
- Connected edges (incoming/outgoing)
- SHACL constraints applicable to the node
SHACL Constraint Overlay
- Constraints shown as bold dashed cyan edges with cardinality badges
[1..*] - Build-time validation using pySHACL
- Violations highlighted in the validation panel
Inline TTL Editor + Live Validation
- Expandable editor panel below each diagram
- CodeMirror with Turtle syntax highlighting
- Edit TTL data and validate against SHACL shapes in real-time
- Update the graph live from edited TTL
- Reset to original data
Export Preview + Publication-Ready Output
- PNG export — clicking PNG/SVG opens a preview dialog showing the final image
- Toggle options: include/exclude legend and namespace prefixes
- High-DPI (3x scale) with white background
- Legend rendered in a clean rounded box with proper shape icons and edge arrows
- Namespace prefixes shown as compact tags below the legend
- SVG export — vector graphics for papers and presentations
- TTL download — download the current (possibly edited) TTL data
Color Customization
- Colors button in the toolbar opens a color settings panel
- Change colors per node type (Class, Individual, Literal)
- Change colors per namespace (all BFO nodes, all FOAF nodes, etc.)
- Changes apply live to the graph and are reflected in exports
Smart Namespace Legend
- Only active prefixes (used in the graph) shown by default
- "Show all" toggle reveals all declared prefixes
- Unused prefixes shown dimmed
- Prefixes displayed as compact styled tags, separated from the main legend
Installation
pip install ontoink
Or install from source:
pip install git+https://github.com/ISE-FIZKarlsruhe/ontoink.git
Usage
1. Add to mkdocs.yml
plugins:
- search
- ontoink
markdown_extensions:
- pymdownx.superfences:
preserve_tabs: true
2. Write ontoink blocks in markdown
```ontoink
source: path/to/instance-data.ttl
shape: path/to/shacl-shape.ttl
```
3. Build or serve
mkdocs serve
Configuration Options
| Option | Default | Description |
|---|---|---|
source |
(required) | Path to TTL data file (relative to docs/) |
shape |
(optional) | Path to SHACL shape file |
height |
500px |
Height of the graph canvas |
editor |
true |
Show the "Edit & Validate" button |
legend |
true |
Show the legend panel |
namespaces |
true |
Show namespace prefixes |
Full example
```ontoink
source: shapes/foaf-person/shape-data.ttl
shape: shapes/foaf-person/shape.ttl
height: 600px
editor: true
legend: true
namespaces: true
```
How It Works
-
Build time (Python): The plugin parses your TTL files with rdflib, classifies nodes (Class/Individual/Literal), resolves labels, detects ontology sources for color coding, extracts SHACL constraints, and runs pySHACL validation. The result is serialized as JSON and embedded in the HTML.
-
Browser (JavaScript): Cytoscape.js renders the graph with dagre layout. CodeMirror provides the TTL editor. A lightweight JavaScript SHACL checker enables live validation without server round-trips.
Development
git clone https://github.com/ISE-FIZKarlsruhe/ontoink.git
cd ontoink
pip install -e ".[dev]"
pytest -v
Demo site
cd demo
mkdocs serve
Requirements
- Python >= 3.9
- MkDocs >= 1.4
- rdflib >= 6.0
- pySHACL >= 0.25.0
- pymdown-extensions >= 10.0
Browser-side dependencies are loaded from CDN (no npm/bundling needed):
- Cytoscape.js, cytoscape-dagre, cytoscape-svg
- CodeMirror 5 with Turtle mode
Contributing
Contributions are welcome. Please open an issue first to discuss proposed changes.
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure
pytestpasses - Submit a pull request
License
MIT License. See LICENSE.
Author
Ebrahim Norouzi — FIZ Karlsruhe, ISE
Acknowledgments
- Developed in the context of NFDI and NFDI-MatWerk
- Visual notation inspired by ontology diagramming best practices and formal OWL notation
- Interactive visualization powered by Cytoscape.js
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ontoink-0.1.0.tar.gz.
File metadata
- Download URL: ontoink-0.1.0.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a614b346e8f2553bbc9d4f3e7c797cdbb5561ae0a37349ddfa910a02080c472b
|
|
| MD5 |
e6a7a391e3ea8a436328c34bbede2229
|
|
| BLAKE2b-256 |
aa0a58ca2c4440ef0deec615f0d9d54a965d28c5b053e691c53224c75d4b2041
|
Provenance
The following attestation bundles were made for ontoink-0.1.0.tar.gz:
Publisher:
publish.yml on ISE-FIZKarlsruhe/ontoink
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ontoink-0.1.0.tar.gz -
Subject digest:
a614b346e8f2553bbc9d4f3e7c797cdbb5561ae0a37349ddfa910a02080c472b - Sigstore transparency entry: 1247095095
- Sigstore integration time:
-
Permalink:
ISE-FIZKarlsruhe/ontoink@f83b946961feaa408444f7df0ca419231ca31bde -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ISE-FIZKarlsruhe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f83b946961feaa408444f7df0ca419231ca31bde -
Trigger Event:
release
-
Statement type:
File details
Details for the file ontoink-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ontoink-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1c5b4c52b61ecaee55c6b0e6d0849c7a9fa2ca2e5f359aacbf10d27215eceb5
|
|
| MD5 |
7f934fad4290630d6e02cd4a9ba7350d
|
|
| BLAKE2b-256 |
b6eaf713e7f9db8ddee676d640d2399dd9a17b603ae965ed36e007bce9447182
|
Provenance
The following attestation bundles were made for ontoink-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ISE-FIZKarlsruhe/ontoink
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ontoink-0.1.0-py3-none-any.whl -
Subject digest:
f1c5b4c52b61ecaee55c6b0e6d0849c7a9fa2ca2e5f359aacbf10d27215eceb5 - Sigstore transparency entry: 1247095098
- Sigstore integration time:
-
Permalink:
ISE-FIZKarlsruhe/ontoink@f83b946961feaa408444f7df0ca419231ca31bde -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ISE-FIZKarlsruhe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f83b946961feaa408444f7df0ca419231ca31bde -
Trigger Event:
release
-
Statement type: