Metadata-Version: 2.4
Name: pyobjectscript_gen
Version: 1.0
Summary: Objectscript class code generation library for Python
Project-URL: Documentation, https://readthedocs.org
Project-URL: Repository, https://github.com/Antoine-dh/pyobjectscript_gen.git
Project-URL: Bug Tracker, https://github.com/Antoine-dh/pyobjectscript_gen/issues
Project-URL: Changelog, https://github.com/Antoine-dh/pyobjectscript_gen/blob/master/CHANGELOG.md
Author: Antoine-dh
Maintainer: Antoine-dh
License-Expression: GPL-3.0
Keywords: cls,code generation,intersystems,iris,objectscript
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: jinja2>=3.0
Description-Content-Type: text/markdown

# PyObjectscript Gen

Objectscript class code generation library for Python

---

## Features

- Objectscript class code generation 
- Clean and simple to use interface in python
- Extensible classes for custom usage

---

## Installation

You can install the package using pip:

```shell
pip install pyobjectscript_gen
````

Or from source:

```shell
git clone https://github.com/Antoine-dh/pyobjectscript_gen.git
pip install .
```

---

## Usage

Here's a basic example of how to use the library:

```python
from pyobjectscript_gen.cls import *

cls = Class(
    name="Demo.MyExample.MyClass",
    extends=["%RegisteredObject"]
)

# example of declaratively creating properties
cls.components = [
    Property(
        name="Property1",
        type="%String",
    ),
    Property(
        name="Property2",
        type="%Numeric",
    ),
]

# example of iteratively creating a method
method = Method("MyMethod")
method.return_type = "%String"
method.impl = [
    "set returnvalue=..Property1_..Property2",
    "quit returnvalue"
]

# append method to class components
cls.components.append(method)

# generate on sys.stdout
cls.generate()
```

See the generated class in `examples/generated/basic.cls`

---

## Requirements

* Python 3.9+
* Jinja2

---

## Documentation

You can find the full documentation at: [Read the docs](https://pyobjectscript-gen.readthedocs.io/en/latest/)

All the documentation can also be found in code with python docstrings in `src/pyobjectscript_gen/cls.py`

---

## Running Examples

All examples code can be found in `examples/` and their respective output classes in `examples/generated/`

```bash
# Basic class example with 2 properties and a method
python3 -m examples.basic > basic.cls

# Test class for every features capable to be generated by the library
python3 -m examples.features > features.cls

# Real life example of multiple classes generation using custom subclasses of the library's components
# Generates a simple REST example with a business operation, request and response classes in the specified directory
mkdir output/
python3 -m examples.rest ./output/
```

More examples to come...

---

## Contributing

Contributions are welcome!

To get started:

```bash
git clone https://github.com/Antoine-dh/pyobjectscript_gen.git
python -m venv .venv
source .venv/bin/activate  # On Windows, use .venv\bin\activate.bat
pip install -r requirements.txt
```

---

## License

This project is licensed under the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.txt).
