|
1 | 1 | # Contributing |
2 | | -A brief contributing guide for the Incydr python SDK. |
3 | | - |
4 | | -Examples of all the steps documented here can be found in the existing clients. |
5 | | - |
6 | | -## Adding a client |
7 | | - |
8 | | - |
9 | | -- Create a `_client_name/` folder within the `incydr` package. |
10 | | - - Create a `client.py` and `models.py` module within this folder. |
11 | | -- Create pydantic models from the OpenAPI specs for the desired client. |
12 | | - - The [datamodel-code-generator project](https://pydantic-docs.helpmanual.io/datamodel_code_generator/) can be used to generate these models. |
13 | | - - Organize the appropriate models into your `/_client_name/models.py` module, adjusting descriptions and type checking as necessary. |
14 | | - - Any enums that will be needed by end-users should go into the `incydr/enums/models.py` module. |
15 | | -- Create a class for your client (`class ClientName`) with a version property (ex: `v1`) |
16 | | -- Create a versioned class for your client (`class ClientNameV1`) accessible through the previously defined version property. |
17 | | -- Create methods for wrapping the desired API calls within the versioned client class. |
18 | | -- Tests for the client should be added into the tests package within `/tests/test_client_name.py`. |
19 | | - - Run tests with `hatch run test:cov` |
20 | | -- Run the style linter with `hatch run style:check` |
21 | | -- Serve docs locally with `hatch run docs:serve` |
22 | | - |
23 | | -## Documenting a client |
24 | | - |
25 | | -- Add the appropriate docstrings to the models and methods for your client. |
26 | | -- Import response models and add them to the `__all__` definition in the `/incydr/models.py` module. |
27 | | -- Adds those models to the `/docs/models.md` file with the appropriate header(s). |
28 | | -- Add a `client_name.md` to the `docs/` directory and add the following to generate documentation from the method docstrings (replace the ClientName with your client's class name): |
29 | | - |
30 | | -```markdown |
31 | | -::: incydr._devices.client.ClientNameV1 |
32 | | - :docstring: |
33 | | - :members: |
| 2 | + |
| 3 | +## Install hatch |
| 4 | + |
| 5 | +```bash |
| 6 | +pip install hatch |
| 7 | +``` |
| 8 | + |
| 9 | +#### Run style checks |
| 10 | + |
| 11 | +```bash |
| 12 | +hatch run style:check |
| 13 | +``` |
| 14 | + |
| 15 | +```bash |
| 16 | +hatch run style:check-no-diff |
34 | 17 | ``` |
35 | 18 |
|
36 | | -- Add your `client_name.md` file to the `nav` section of the `mkdocs.yml` config file. |
| 19 | +#### Run tests with coverage |
| 20 | + |
| 21 | +```bash |
| 22 | +hatch run test:cov |
| 23 | +``` |
| 24 | + |
| 25 | +```bash |
| 26 | +hatch run test:no-cov |
| 27 | +``` |
| 28 | + |
| 29 | +#### Serve docs locally |
| 30 | + |
| 31 | +```bash |
| 32 | +hatch run docs:serve |
| 33 | +``` |
0 commit comments