Skip to content

Commit 908abd6

Browse files
committed
docs: cleaned and updated documentation
1 parent 49c5601 commit 908abd6

8 files changed

+257
-196
lines changed

CONTRIBUTING.md

+132-67
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,119 @@ If an issue for the changes you intend to make does not exist, create one.
77

88
1. Raise an issue for the changes you wish to make (or start working on a pre-existing issue).
99
2. Make a feature branch for your changes.
10-
> Name the branch as add_<name_of_the_function_to_be_added>
10+
11+
> Name the branch as <issue_number>-add-<name_of_the_function_to_be_added> or something as descriptive
12+
1113
3. Base your feature branch on the master branch.
14+
1215
> Remember to
13-
``` console
16+
17+
```bash
1418
git pull
1519
```
16-
before checking out to a new branch.
17-
18-
4. Do all
19-
- editing
20-
- formatting
2120

22-
and
23-
24-
- testing
21+
before checking out to a new branch.
2522

26-
on the issue-specific branch. Commit only to that branch, do not edit the master branch directly.
23+
4. Do all editing formatting and testing on the issue-specific branch.
24+
Commit only to that branch, do not edit the master branch directly.
2725

28-
5. Once you have something working, make sure your commits are according to the desired coding style and that your branch contains appropriate documentation and tests.
26+
5. Once you have something working, make sure your commits are
27+
according to the desired coding style and that your branch contains
28+
appropriate documentation and tests.
2929

30-
6. Create a pull request (PR) to merge your branch into the master. In it, summarize your changes.
31-
Assign a reviewer / reviewers for the PR.
30+
6. Create a pull request (PR) to merge your branch into the master. In
31+
it, summarize your changes. Assign a reviewer / reviewers for the
32+
PR.
3233

3334
## Terminology and general coding principles
3435

3536
1. Packages
3637

37-
The folders at eis_toolkit/eis_toolkit are called packages. The initial division to packages already exist. Feel free to suggest modifications to the
38-
current package division via creating an issue for it! Note that the packages can split up into sub packages if needed. Subpackages' names should also represent the main purpose of the modules belonging to the particular subpackage.
38+
The folders inside `./eis_toolkit` are called subpackages. Feel free to suggest
39+
modifications to the current subpackage division via creating an issue for it!
40+
Note that the subpackages can split up into more subpackages if needed.
3941

4042
2. Modules
4143

42-
Module names come from the names of the .py files containing function declarations. You will need to create a new python file for each functionality. The name of the file containing the function declaration(s) for providing the functionality will be essentially the same as the function’s name but instead of the basic form use –ing form if it makes sense.
44+
Module names come from the names of the .py files containing function
45+
declarations. You will need to create a new python file for each functionality.
46+
The name of the file containing the function declaration(s) for providing the
47+
functionality will be essentially the same as the function’s name but instead
48+
of the basic form use –ing form if it makes sense.
4349

44-
- Try to create modules in a way that each module contains only one functionality. Split this functionality into two function declarations: one for external use and one (the core functionality) for internal use. See e.g. implementation of [clipping functionality](./eis_toolkit/raster_processing/clipping.py) for reference.
50+
- Try to create modules in a way that each module contains only one
51+
functionality. Split this functionality into two function
52+
declarations: one for external use and one (the core functionality)
53+
for internal use. See e.g. implementation of [clipping
54+
functionality](./eis_toolkit/raster_processing/clipping.py) for
55+
reference.
4556

4657
1. Functions
4758

48-
Name each function according to what it is supposed to do. Try to express the purpose as simplistic as possible. In principle, each function should be creted for executing one task. We prefer modular structure and low hierarchy by trying to avoid nested function declarations. It is highly recommended to call other functions for executing sub tasks.
59+
Name each function according to what it is supposed to do. Try to
60+
express the purpose as simplistic as possible. In principle, each
61+
function should be created for executing one task. We prefer modular
62+
structure and low hierarchy by trying to avoid nested function
63+
declarations. It is highly recommended to call other functions for
64+
executing sub tasks.
4965

5066
**Example (packages, modules & functions):**
5167

52-
Create a function which clips a raster file with polygon -> name the function as clip. Write this function declaration into a new python file with name clipping.py inside of the eis_toolkit/eis_toolkit/raster_processing folder.
68+
Create a function which clips a raster file with polygon -\> name the
69+
function as clip. Write this function declaration into a new python file
70+
with name clipping.py inside of the
71+
`eis_toolkit/raster_processing` folder.
5372

5473
4. Classes
5574

56-
A class can be defined inside of a module or a function. Class names should begin with a capital letter and follow the CamelCase naming convention: if a class name contains multiple words, the spaces are simply ignored and each separate word begins with capital letters.
75+
A class can be defined inside of a module or a function. Class names
76+
should begin with a capital letter and follow the CamelCase naming
77+
convention: if a class name contains multiple words, the spaces are
78+
simply ignored and each separate word begins with capital letters.
79+
80+
When implementing the toolkit functions, create classes only when they
81+
are clearly beneficial.
5782

58-
When implementing the toolkit functions, create classes only when they are clearly beneficial.
59-
> If you create new custom exception classes, add them directly into eis_toolkit/eis_toolkit/exceptions.py file.
83+
> If you create new custom exception classes, add them directly into
84+
> `eis_toolkit/exceptions.py` file.
6085
6186
5. Variables
6287

63-
Avoid using global variables. Name your variables clearly for code maintainability and to avoid bugs.
88+
Avoid using global variables. Name your variables clearly for code
89+
maintainability and to avoid bugs.
6490

6591
6. Docstrings and code comments
6692

67-
For creating docstrings, we rely on google convention (see section 3.8 in [link](https://google.github.io/styleguide/pyguide.html) for more detailed instructions). Let’s try to minimize the amount of code comments. Well defined docstrings should do most of the job with clear code structure.
93+
For creating docstrings, we rely on google convention (see section 3.8
94+
in [link](https://google.github.io/styleguide/pyguide.html) for more
95+
detailed instructions). Let's try to minimize the amount of code
96+
comments. Well defined docstrings should do most of the job with clear
97+
code structure.
6898

6999
## Naming policy
70100

71-
General guidelines about naming policy (applies to package, module, function, class and variable names):
72-
- all names should be given in English
73-
- avoid too cryptic names by using complete words
74-
- if the name consists of multiple words, use snake_case so replace space with underscore character (_) (CamelCase is used for classes as an exception to this rule)
75-
- do not include special characters, capital letters or numbers into the names unless in case of using numbers in variable names and there is an unavoidable need for it / using numbers significantly increases clarity
101+
General guidelines about naming policy (applies to package, module,
102+
function, class and variable names):
103+
104+
- all names should be given in English
105+
106+
- avoid too cryptic names by using complete words
107+
108+
- if the name consists of multiple words, use snake_case so replace
109+
space with underscore character (\_) (CamelCase is used for classes
110+
as an exception to this rule)
111+
112+
- do not include special characters, capital letters or numbers into
113+
the names unless in case of using numbers in variable names and
114+
there is an unavoidable need for it / using numbers significantly
115+
increases clarity
76116

77117
## Code style
78118

79119
### pre-commit
80120

81-
> Note that pre-commit was added as the primary style check tool later in the project and you need to install and enable it manually!
121+
> Note that pre-commit was added as the primary style check tool later
122+
> in the project and you need to install and enable it manually!
82123
83124
The repository contains a `.pre-commit-config.yaml` file that has configuration
84125
to run a set of [`pre-commit`](https://pre-commit.com) hooks. As the name
@@ -90,14 +131,14 @@ copy of the repository to run.
90131
To install `pre-commit` on Debian or Ubuntu -based systems with `apt` as
91132
the package manager you should be able to run:
92133

93-
``` console
134+
```bash
94135
apt update
95136
apt install pre-commit
96137
```
97138

98139
Alternatively, it can be installed with the system installation of `Python`:
99140

100-
``` console
141+
```bash
101142
pip install pre-commit
102143
```
103144

@@ -107,7 +148,7 @@ methods (<https://pre-commit.com>).
107148
To enable the hooks locally, enter the directory with your local
108149
version of `eis_toolkit`, and run:
109150

110-
``` console
151+
```bash
111152
pre-commit install
112153
```
113154

@@ -119,7 +160,7 @@ the commit.
119160
To disable the hooks and allow commits even with errors pointed out by
120161
`pre-commit`, you can add the `--no-verify` option to the `git` command-line:
121162

122-
``` console
163+
```bash
123164
git commit -m "<message>" --no-verify
124165
```
125166

@@ -129,33 +170,37 @@ out by `pre-commit`.
129170
You can also run the hooks without committing on all files. Make sure you save
130171
any text changes as `pre-commit` can modify unformatted files:
131172

132-
``` console
173+
```bash
133174
pre-commit run --all-files
134175
```
135176

136-
137177
## Testing
138178

139-
Creating and executing tests improves code quality and helps to ensure that nothing gets broken
140-
after merging the PR.
179+
Creating and executing tests improves code quality and helps to ensure
180+
that nothing gets broken after merging the PR.
141181

142182
> **Please** note that creating and running tests is not optional!
143183
144184
Create a new python file into eis_toolkit/tests folder every time you wish to add a new functionality
145185
into eis_toolkit. Name that file as <name_of_the_function_to_be_added>_test.py.
146186

147-
In this test file you can declare all test functions related to the new function. Add a function at least for testing that
148-
- the new function works as expected (in this you can utilize other software for generating the reference solution)
149-
- custom exception class errors get fired when expected
187+
In this test file you can declare all test functions related to the new
188+
function. Add a function at least for testing that
150189

151-
You can utilize both local and remote test data in your tests.
152-
For more information about creating and running tests, take a look at [test instructions](./instructions/testing.md).
190+
- the new function works as expected (in this you can utilize other
191+
software for generating the reference solution)
192+
- custom exception class errors get fired when expected
153193

154-
## Documentation
194+
You can utilize both local and remote test data in your tests. For more
195+
information about creating and running tests, take a look at [test
196+
instructions](./instructions/testing.md).
155197

156-
When adding (or editing) a module, function or class, **please** make sure the documentation stays up-to-date!
157-
For more information, take a look at [documentation instructions](./instructions/generating_documentation.md).
198+
## Documentation
158199

200+
When adding (or editing) a module, function or class, **please** make
201+
sure the documentation stays up-to-date! For more information, take a
202+
look at [documentation
203+
instructions](./instructions/generating_documentation.md).
159204

160205
## Creating a PR
161206

@@ -171,22 +216,29 @@ If you act according to the workflow stated in this document, these PR checks
171216
should always pass since you have already run pytest through before committing :)
172217
The purpose of this automatic workflow is to double check that nothing gets broken by merge.
173218

174-
However, **IF** you make changes to the dependencies of the repository (i.e. edit
175-
pyproject.toml file), you need to update requirements.txt file in order to the
176-
workflow tests to stay up-to-date. You can do this by running the following command
219+
However, **IF** you make changes to the dependencies of the repository (i.e.
220+
edit pyproject.toml file), you need to update `poetry.lock` and
221+
`environment.yaml` files in order to the workflow tests to stay up-to-date. You
222+
can update the `poetry.lock` file by running the following commands:
177223

178-
```console
179-
poetry export --without-hashes --format=requirements.txt > requirements.txt
224+
```bash
225+
# Not required if you added a package with poetry add command
226+
poetry lock --no-update
180227
```
181228

182-
and committing the new version of the particular file into your feature
183-
branch. Please note that this file is only used for GitHub workflows, otherwise
184-
we utilize poetry for dependency handling.
185-
229+
and committing the new version of the particular file into your feature branch.
230+
Dependencies in `environment.yaml` need to be kept up to date manually by
231+
including the same package, which was added to `pyproject.toml`, in
232+
`environment.yaml`. Please note that this file is only used for GitHub
233+
workflows, otherwise we utilize poetry for dependency handling.
186234

187235
## Recent changes
236+
188237
Some changes have been made to the style guide:
189-
- Use `numbers.Number` as the type when both floats and integers are accepted by functions:
238+
239+
- Use `numbers.Number` as the type when both floats and integers are
240+
accepted by functions:
241+
190242
```python
191243
from numbers import Number
192244

@@ -196,7 +248,11 @@ def func(int_or_float: Number):
196248
```python
197249
raise InvalidParameterValueException(f"Window size is too small: {height}, {width}.")
198250
```
199-
- Use beartype's decorator for automatic function argument type checking and import types from `beartype.typing` if a warning is raised by beartype on imports from `typing`:
251+
252+
- Use beartype's decorator for automatic function argument type
253+
checking and import types from `beartype.typing` if a warning is
254+
raised by beartype on imports from `typing`:
255+
200256
```python
201257
from beartype import beartype
202258
from beartype.typing import Sequence
@@ -229,14 +285,23 @@ def my_function(parameter_1: float, parameter_2: bool, parameter_seq: Sequence):
229285
```
230286

231287
## Developer's checklist
288+
232289
Here are some things to remember while implementing a new tool:
233290

234-
- Create an issue **before or when you start** developing a functionality
235-
- Adhere to the style guide
236-
- Look at existing implementations and copy the form
237-
- Enable pre-commit and fix style/other issues according to the error messages
238-
- Remember to use typing hints
239-
- Write tests for your functions
240-
- Add a .md file for you functionality
241-
- If you think the tool you are developing could use a separate general utility function, make an issue about this need before starting to develop it on your own. Also check if a utility function exists already
242-
- Remember to implement only the minimum what is required for the tool! With data functions, you can usually assume file reading/writing, nodata handling and other such processes are done before/after executing your tool
291+
- Create an issue **before or when you start** developing a
292+
functionality
293+
- Adhere to the style guide
294+
- Look at existing implementations and copy the form
295+
- Enable pre-commit and fix style/other issues according to the
296+
error messages
297+
- Remember to use typing hints
298+
- Write tests for your functions
299+
- Add a .md file for you functionality
300+
- If you think the tool you are developing could use a separate
301+
general utility function, make an issue about this need before
302+
starting to develop it on your own. Also check if a utility function
303+
exists already
304+
- Remember to implement only the minimum what is required for the
305+
tool! With data functions, you can usually assume file
306+
reading/writing, nodata handling and other such processes are done
307+
before/after executing your tool

0 commit comments

Comments
 (0)