Metadata-Version: 2.4
Name: saref-pypeline
Version: 0.6.0
Summary: SAREF pipeline tools: check SAREF projects against ETSI TS 103 673, generate their documentation website and Technical Specifications
Author-email: Maxime Lefrançois <maxime.lefrancois@emse.fr>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://saref.etsi.org/
Project-URL: Repository, https://labs.etsi.org/rep/saref/saref-pypeline
Project-URL: Issues, https://labs.etsi.org/rep/saref/saref-pypeline/-/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-gitlab
Requires-Dist: requests
Requires-Dist: rdflib~=7.0.0
Requires-Dist: gitpython
Requires-Dist: beautifulsoup4
Requires-Dist: markdown
Requires-Dist: pyyaml
Provides-Extra: check
Requires-Dist: owlready2; extra == "check"
Requires-Dist: pyshacl; extra == "check"
Provides-Extra: website
Requires-Dist: jinja2; extra == "website"
Requires-Dist: dominate; extra == "website"
Requires-Dist: lunr>=0.8.0; extra == "website"
Requires-Dist: pygments; extra == "website"
Requires-Dist: rcssmin>=1.2.1; extra == "website"
Requires-Dist: rjsmin>=1.2.4; extra == "website"
Provides-Extra: ts
Requires-Dist: python-docx; extra == "ts"
Requires-Dist: dominate; extra == "ts"
Requires-Dist: pygments; extra == "ts"
Provides-Extra: ts2md
Requires-Dist: saref-pypeline[ts]; extra == "ts2md"
Provides-Extra: all
Requires-Dist: saref-pypeline[check]; extra == "all"
Requires-Dist: saref-pypeline[website]; extra == "all"
Requires-Dist: saref-pypeline[ts]; extra == "all"
Dynamic: license-file

# SAREF Pypeline

This project provides a number of tools to SAREF ontology developers:

* check the conformance of a SAREF project against ETSI TS 103 673 [[1]](#[1])
* generate the documentation website https://saref.etsi.org/
* generate ETSI Technical Specification documents from the sources of the ontology

## Installation

NOTE: SAREF Pypeline has been tested on Linux and Windows WSL2. It's not a goal at the moment to ensure it's working in every environment, or provide support for installing and using it. 

**Prerequisites:** 

* [`uv`](https://docs.astral.sh/uv/) (recommended) or `pipx` with Python >= 3.13
* for command `check`: Java >= 11


**With uv:** 

```
uv tool install 'saref-pypeline[check]'
```

**With pipx:** 

```
pipx install 'saref-pypeline[check]'
```

**For local development:** 

```
git clone https://labs.etsi.org/rep/saref/saref-pypeline.git
cd saref-pypeline
pip install -e .[check,website,ts]
```

**Optional cache:** if the package [`rdflib-leveldb`](https://github.com/RDFLib/rdflib-leveldb) is installed, the documents loaded are cached in the `target/dataset` folder between runs. It requires [`leveldb`](https://github.com/google/leveldb) (package `libleveldb-dev` on ubuntu), and is not available on PyPI:

```
uv tool install 'saref-pypeline[check]' --with 'rdflib-leveldb @ git+https://github.com/RDFLib/rdflib-leveldb'
```

## Basic usage

Run as follows:

```
$ saref-dev --help
usage: saref-dev [-h] {clean,check,website,ts,ts2md,help} ...

Check or document SAREF projects.

positional arguments:
  {clean,check,website,ts,ts2md,help}
    clean               Delete the target folder.
    check               Check a SAREF project.
    website             Generate the documentation website for a SAREF project.
    ts                  Generate the Technical Specification (DOCX) for a SAREF project.
    ts2md               Experimental - Extract documentation files from the Technical Specification (DOCX) of a SAREF project.
    help                Show the help message and exit.

options:
  -h, --help            show this help message and exit

Optional features require extras, e.g. uv tool install 'saref-pypeline[website]'
```

Commands `check`, `website`, `ts`, take a set of common options:

```
$ saref-dev check --help
usage: saref-dev check [-h] [--verbose] [--strict] [-s DIR] [-p REGEX] [-v REGEX] [-d REGEX] [--skip-fetch] [-c REGEX] [directory]

Check a SAREF project.

positional arguments:
  directory             Project directory (default: current directory).

options:
  -h, --help            show this help message and exit
  --verbose, -V         Increase verbosity level (default: INFO. -V: DEBUG. -VV: TRACE.).
  --strict              Only consider release branches.
  -s, --sources DIR     Path to the folder where projects are stored/cloned (default: target/sources relative to the project directory).
  --skip-fetch          Skip git fetch for source folders.
  -p, --include-projects REGEX
                        Regex to select which projects to process. Regexes are evaluated against the project name (e.g., "SAREF", "^SAREF4[A-E]"). Can be given multiple times. Shall only be used on the saref-portal project.
  -v, --include-versions REGEX
                        Regex to select which project versions to process. Regexes are evaluated against the project name and version (e.g., "SAREF V4.1.1", "^SAREF4[A-E] V2.1.1"). Shall be compatible with --include-projects. Can be given multiple times.
                        Shall only be used on the saref-portal project.
  -d, --include-documents REGEX
                        Regex to select which documents to check (ontologies, examples, vocabularies, patterns). Evaluated against the path to the documents. Can be given multiple times.
  -c, --include-clauses REGEX
                        Regex to select which clauses to check. Regexes Evaluated against the TS and clause name (e.g., "TS103673 Clause 9.7.1"). Can be given multiple times.

This command require extra 'check', install with uv tool install 'saref-pypeline[check]'
```

Optional features require extras, e.g.:

```
uv tool install 'saref-pypeline[check]'
uv tool install 'saref-pypeline[website]'
```

Option `-c` is only available for `check`.

The project is deduced from the name of the project directory (e.g., `saref4abcd`), or else from the name of the repository of its git remote `origin`.

Command `check` exits with code 1 if some error is reported, so it can be used in continuous integration.


## About

The SAREF pypeline is part of the SAREF Development Framework. The following projects contributed to the SAREF Pipeline:

* [ETSI STF 578](https://portal.etsi.org/STF/STFs/STF-HomePages/STF578): "Specification of the SAREF development framework and workflow, and development of the Community SAREF Portal for user engagement"
* [ETSI STF 653](https://portal.etsi.org/XTFs/#/xTF/653): "SAREF Patterns"
* [StandICT.eu 2026 grant 07-968](https://standict.eu/): "Improving the ETSI TC SmartM2M SAREF publication framework and workflow"

The SAREF pypeline is a port to python of the [SAREF pipeline](https://labs.etsi.org/rep/saref/saref-pipeline), with more features and improved performances.


## References

* <a id="[1]"></a> [ETSI TS 103 673 V1.2.1](https://www.etsi.org/deliver/etsi_ts/103600_103699/103673/01.02.01_60/ts_103673v010201p.pdf): "SmartM2M; SAREF Development Framework and Workflow, Streamlining the Development of SAREF and its Extensions"


## License

The content of this repository is licensed under the terms of the BSD-3-Clause LICENSE:

  https://opensource.org/licenses/BSD-3-Clause

## TODO

Known limitations:

* [] ts generation: missing general axioms

## For maintainers

Docker image tag and library version is automatically computed from git tag.
Use tool `bump-my-version` to read the Git history/tags, increment `major`, `minor`, or `patch`, and create the corresponding Git tag.

```
uv tool install bump-my-version
```

Then to tag and push a new version (ex. `minor`):

```
bump-my-version bump minor
```
