Skip to content

Commit 747302a

Browse files
committed
Update README and examples
1 parent c7b861d commit 747302a

File tree

7 files changed

+1504
-1250
lines changed

7 files changed

+1504
-1250
lines changed

README.md

Lines changed: 50 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# GHERKIN PROCESSOR
44

5-
A Python package that converts Gherkin scenarios into Python dataclass objects. It offers flexible conversion with strict or relaxed validation of the Gherkin syntax.
5+
**Gherkin Processor** is a Python package that processes Gherkin files into Python *dataclasses*. It provides utilities for validating, processing, and saving Gherkin scenarios in both text and JSON formats.
66

77
---
88

@@ -21,105 +21,80 @@ A Python package that converts Gherkin scenarios into Python dataclass objects.
2121

2222
## Features
2323

24-
- Converts Gherkin scenarios into Python `dataclasses` for easy manipulation and analysis.
25-
- Supports strict format validation, ensuring the Gherkin scenarios follow the correct syntax.
26-
- Allows conversion of scenarios even with minor syntax errors, making it more robust.
27-
- Built-in flexibility for customization and extension.
24+
- Gherkin scenario validation
25+
- Gherkin scenario syntax issue description
26+
- Gherkin scenario content processing into Python dataclass
27+
- Save processed scenarios in text or JSON format
28+
- Directly load scenarios from file paths
2829

2930
## Installation
3031

31-
```shell
32-
# 1. Clone the Github repository
33-
git clone https://github.com/MarkLehoczky/gherkin-processor.git
34-
35-
# 2. Install package with pip
36-
pip install gherkin-processor
37-
```
38-
39-
## Usage
40-
41-
### Script
42-
43-
```python
44-
from dataclasses import asdict
45-
from json import dumps
32+
You can install the **Gherkin Processor** package by cloning the repository or downloading from the releases.
4633

47-
from gherkin_processor.utils import scenario
48-
from gherkin_processor.scenario import Scenario
34+
### Clone the Repository
4935

50-
# Loads a Gherkin scenario from a file and processes it into a python data class.
51-
with open("scenario.txt", "r", encoding="utf-8") as scenario_text_file:
52-
scenario_text: str = scenario_text_file.read()
53-
scenario_instance: Scenario = scenario.process(scenario_text)
36+
```sh
37+
# 1. Clone the repository
38+
git clone https://github.com/MarkLehoczky/gherkin-processor.git
5439

55-
# Prints some of the scenario components to the standard output.
56-
print(", ".join(scenario_instance.tags))
57-
print(scenario_instance.name)
40+
# 2. Navigate to the cloned directory
41+
cd gherkin-processor
5842

59-
# Converts the scenario into dictionary format, then saves it as a json.
60-
with open("scenario.json", "w") as scenario_json_file:
61-
scenario_json: dict = asdict(scenario_instance)
62-
scenario_json_file.write(dumps(scenario_json, indent=4))
43+
# Install the package via 'pip'
44+
pip install .
6345
```
6446

65-
## Dataclass Structure
47+
### Download from Releases
6648

67-
The resulting Python dataclass structure represents the Gherkin scenario hierarchy. Here's an example of what the structure looks like:
49+
1. Go to the [Releases](https://github.com/MarkLehoczky/gherkin-processor/releases) page.
50+
2. Download the latest release.
51+
3. Extract the downloaded file.
52+
4. Navigate to the extracted directory.
53+
5. Install the package with the following command:
6854

69-
```python
70-
@dataclass
71-
class Scenario:
72-
tags: List[str]
73-
name: str
74-
steps: List[Dict[str, Dict[str, List[str]] | str]]
75-
template_table: Optional[Dict[str, List[str]]]
55+
```sh
56+
pip install .
7657
```
7758

78-
*Depending whether a step is followed by docstring or table, the `steps` variable's structure may change.*
59+
## Usage
7960

80-
## Prerequisites
61+
### Command Line Interface
8162

82-
### Mandatory
63+
The **Gherkin Processor** can be used via the command line interface (CLI).
8364

84-
- Python 3.10 or newer version
65+
```sh
66+
gherkin-processor [-h] -i INPUT [-p] [-s] [--save-as-json] [--validate]
67+
```
8568

86-
### Advised
69+
#### Options
8770

88-
#### VSCode extensions
71+
```text
72+
-h, --help show this help message and exit
73+
-i INPUT, --input INPUT specify the input Gherkin file location to process
74+
-p, --print print the processed Gherkin scenario to the standard output
75+
-s, --save save the processed Gherkin scenario to a file
76+
--save-as-json save the processed Gherkin scenario to a file in JSON format
77+
--validate validate the input Gherkin file syntax
78+
```
79+
80+
See the [CLI examples](examples/cli.ipynb) for details.
8981

90-
The following extensions are listed in the `.vscode/extensions.json` file.
82+
### Python API
9183

92-
- [autoDocstring - Python Docstring Generator](https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring)
93-
- [autoflake](https://marketplace.visualstudio.com/items?itemName=mikoz.autoflake-extension)
94-
- [Black Formatter](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter)
95-
- [Mypy Type Checker](https://marketplace.visualstudio.com/items?itemName=ms-python.mypy-type-checker)
96-
- [Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance)
97-
- [Pylint](https://marketplace.visualstudio.com/items?itemName=ms-python.pylint)
98-
- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
99-
- [Python Debugger](https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy)
100-
- [Python Docstring Highlighter](https://marketplace.visualstudio.com/items?itemName=rodolphebarbanneau.python-docstring-highlighter)
101-
- [Python Test Explorer for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=littlefoxteam.vscode-python-test-adapter)
102-
- [Python Type Hint](https://marketplace.visualstudio.com/items?itemName=njqdev.vscode-python-typehint)
84+
The **Gherkin Processor** can also be used programmatically in a Python code.
10385

104-
#### Python packages
86+
```python
87+
from gherkin_processor.utils import scenario # file
88+
from gherkin_processor.scenario import Scenario # class
10589

106-
The following packages are listed in the `requirements.txt` file.
107-
To install them simply use the following command:
90+
# Load and process the scenario from a file
91+
processed_scenario: Scenario = scenario.load("path/to/scenario.feature")
10892

109-
```shell
110-
pip install -r requirements.txt
93+
# Save the processed scenario to a file
94+
scenario.save(processed_scenario, "path/to/saved_scenario.feature")
11195
```
11296

113-
- pylint
114-
- mypy
115-
- pyflakes
116-
- radon
117-
- black
118-
- pycodestyle
119-
- pydocstyle
120-
- bandit
121-
- pytest
122-
- pytest-cov
97+
See the [API examples](examples/api.ipynb) and [Data class structure](examples/data.ipynb) for details.
12398

12499
## License
125100

0 commit comments

Comments
 (0)