# UJO Schema

[![pipeline status](https://git.industrial-devops.org/titan/related-projects/ujoschema-py/badges/master/pipeline.svg)](https://git.industrial-devops.org/titan/related-projects/ujoschema-py/-/commits/master) [![pypi](https://img.shields.io/pypi/v/UJOSchema.svg)](https://pypi.org/project/UJOSchema/) [![license](https://img.shields.io/pypi/l/UJOSchema.svg)](https://pypi.org/project/UJOSchema/)

Documentation of UJO Schema and a Python implementation of a parser and related tools.

## Install Requirements

There a a number of packages required to be installes with python.

```
pip install -r requirements.txt
```

## Convert UJO Schema to markdown documentation

UJO Schema files can be converted into a markdown documentation.

__Usage:__

```
Usage:
  UJOSchema (-h | --help)
  UJOSchema into markdown <source> [-d FOLDER] [-e EXTENSION]
  UJOSchema into binary <source> [-d FOLDER] [-e EXTENSION] [-t TARGET]
  UJOSchema into json <source> [-d FOLDER] [-e EXTENSION] [-t TARGET]

Options:
  -h --help  Show this screen.

  into markdown <source>
      convert given SOURCE (file or folder) to markdown

  into binary <source>
      convert given SOURCE (file or folder) to binary

  into json <source>
      convert given SOURCE (file or folder) to JSON

  -d FOLDER --destination FOLDER
      destination folder for generated files [default: .]

  -e EXTENSION --extension EXTENSION
      if SOURCE is a folder, only process files with the specified extension [default: .ujs]

  -t TARGET --target TARGET
      name of a definition target. other types in the schema will be ignored, unless nested.
```

__Example:__

```
python -m UJOSchema into markdown .\examples\ujs2md -d testoutput
```

# Generate Documentation

For code documentation [Sphinx]() is used together with the
[Napoleon](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/index.html)
extension.

On Windows you can generate the documentation with:

```
./doc/make.bat html
```

For Linux there is a `Makefile` prepared, but not yet tested.

# Code Quality

A variety of tools can assist in writing quality code. This chapter explains
which are used and how tu run them.

## pylint

Linting is performed with [pylint](https://www.pylint.org). To define the
intended checks `.pylintrc` is used to configure linting for this project.

A default configuration file was generated with

```
pylint --generate-rcfile
```

The generated file was than modified to exclude some tests.

Running pylint for the python code in this project the following commands are
used:

```
pylint --rcfile=.pylintrc .\UJOSchema\
```

## flake8

To make sure the PEP8 standard is applied to the code flake8 can be added to
the static tests.

For this project we exclude various errors, warnings and notifications because
they do not make sense at this time. This may change while refactoring is
considered.

You can run flake 8 with:

```
flake8
```

It finds all the python files in this project.
The configuration for this project is read from `.flake8` in  the project
root directory.

## run unit tests

```
python -m pytest
```
