Skip to content

Commit e10c7bc

Browse files
committed
docs: updating design and contributors guide
1 parent 59e4f7c commit e10c7bc

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

docs/source/getting_started/contributors_guide.rst

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,48 @@ For changes to ``./docs``::
5050
Building the docs the first time takes a little while. After this, you will see a build directory. From here you can preview the generated HTML
5151
in your browser.
5252

53+
Linting and code format
54+
~~~~~~~~~~~~~~~~~~~~~~~
55+
56+
We use both black and ruff to format and lint the code.
57+
The code will automatically be formatted by black after being committed, alternatively run black on any changed files.
58+
59+
A linting check is done with ruff, please ensure that this passes prior to creating a pull request.
60+
To check the code with ruff run the following command in the root directory of the repository::
61+
62+
ruff LoopStructural
63+
64+
The configuration parameters for ruff and black are stored in the pyproject.toml file.
65+
66+
Coding Guidelines
67+
~~~~~~~~~~~~~~~~~
68+
- Reduce Duplicated Code: Strive to avoid duplication by modularizing code and promoting code reuse where appropriate.
69+
- Document code: Use numpy style docstrings and ensure that any new features are added into the documentation
70+
- Type hints: Use appropriate type hints for any function arguments and returns
71+
- Avoid python loops: Avoid using pure python loops - where possible used vectorized functions in numpy, geopandas, scipy
72+
- Use Object-Oriented Data Structures: Utilize object-oriented programming principles to structure data and functionality in a cohesive manner.
73+
- Use British English Spelling: Adhere to British English spelling conventions throughout the codebase and documentation.
74+
- Use Conventional Commits: Follow the Conventional Commits specification for clear and structured commit messages.
75+
- Ensure Tests Pass: Before submitting any changes, ensure that all tests pass locally.
76+
- Write Tests for New Code: Include tests for any new functionality or code additions to maintain code quality and prevent regressions.
77+
- Minimize External Dependencies: Aim to minimize reliance on external libraries and frameworks to keep the project lightweight.
78+
- Make External Dependencies Optional: When external dependencies are necessary, make them optional where feasible to increase flexibility and ease of installation.
79+
5380
Commit messages
5481
---------------
5582
A changelog is automatically generated from the commit message, the following keywords are identified in the commit log.
5683

57-
* add - defining a new feature that is added to LoopStructural
58-
* fix - a bugfix
59-
* change - any changes to features
84+
.. code-block::
85+
<type>[optional scope]: <description>
86+
87+
[optional body]
88+
89+
[optional footer(s)]
90+
91+
92+
* feat: - defining a new feature that is added to LoopStructural
93+
* fix: - a bugfix
94+
* BREAKING CHANGE: - any changes to features
6095
* remove - removing features or code from LoopStructural
6196
* merge
6297
* doc - changes to documentation

docs/source/getting_started/loopstructural_design.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@ The main modules for the library are:
4949
2. modelling
5050
3. visualisation
5151
4. utils
52+
5. datasets
53+
54+
5255

5356
**Coding paradigm** LoopStructural is written in an object oriented paradigm.
5457
The four pillars of object oriented coding should be adhered to:
5558

5659
* **Encapsulation**: Attributes in python are designed to be accessible both within the class and from outside of the class. In LoopStructural, the where an attribute of a class should be private the ``@property`` decorator should be used.
5760
* **Inheritance**: Classes should inheret attributes and methods from parent classes.
5861
* **Polymorphism**: Child classes, where a method is different from a parent class should override methods from parent classes.
62+
* **Abstraction**: Classes should be designed to be abstract and avoid containing implementation details.
63+
64+
**ABC** LoopStructural uses abstract base classes to define the interface for different classes.
5965

6066
**Dependency management** The library is written in python and is dependent on numpy, scipy. Care should be taken to avoid incorporating of uncessary dependencies. For dependencies that are not part of the standard scientific python toolkit (numfocus projects) the dependencies should be optional and not be required.
6167

@@ -65,6 +71,8 @@ The four pillars of object oriented coding should be adhered to:
6571
There should be unit tests for all classes and methods.
6672
Integration tests should be included to test the interaction between classes.
6773

74+
**Commits** Commits should be made using the conventional commit style.
75+
6876
**CI/CD** The code is automatically versioned using release-please.
6977
When creating a commit use the conventional commit style e.g. ``fix: bug fix``, ``feat: new feature``, ``chore: code change``.
7078
A new patch pull request will be created when a bug fix is applied and passes the tests.
@@ -120,6 +128,7 @@ A visualisation module can be implemented by simply subclassing the **BaseModelP
120128
---------
121129

122130
The utils module is a container for utility functions that are used throughout the library.
131+
Where possible util functions should be stored in separate files that are imported in the `__init__.py` file.
123132

124133

125134

@@ -138,6 +147,7 @@ A fixture is a function that can be called by a test for a range of predefined p
138147
For example a fixture to generate different discrete interpolators would be
139148

140149
.. code-block::
150+
141151
from LoopStructural.interpolators import FiniteDifferenceInterpolator as FDI, \
142152
PiecewiseLinearInterpolator as PLI
143153
from LoopStructural.interpolators import StructuredGrid, TetMesh
@@ -165,7 +175,7 @@ For example a fixture to generate different discrete interpolators would be
165175
166176
This fixture can then be called by any test in the testing suite:
167177

168-
.. code-block:
178+
.. code-block::
169179
170180
from LoopStructural.interpolators import GeologicalInterpolator
171181

0 commit comments

Comments
 (0)