Skip to content

Commit f85ad48

Browse files
authored
Merge pull request #963 from PowerGridModel/feature/minor-format-docs4
Add markdownlint formatting checks
2 parents 39675f4 + 417c457 commit f85ad48

File tree

39 files changed

+221
-116
lines changed

39 files changed

+221
-116
lines changed

.github/workflows/check-code-quality.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ jobs:
6161
sudo apt-get update && sudo apt-get install -y clang-format-18
6262
find . -regex '.*\.\(h\|c\|cpp\|hpp\|cc\|cxx\)' -exec clang-format-18 -style=file -i {} \;
6363
64+
- name: Install and run markdownlint
65+
run: |
66+
npm install -g markdownlint-cli
67+
echo "Running markdownlint"
68+
markdownlint --fix .
69+
6470
- name: If needed raise error
6571
run: |
6672

.markdownlint.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
# MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md001.md
6+
MD001: false
7+
8+
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md013.md
9+
MD013: false
10+
# # Number of characters
11+
# line_length: 80
12+
# # Number of characters for headings
13+
# heading_line_length: 80
14+
# # Number of characters for code blocks
15+
# code_block_line_length: 80
16+
# # Include code blocks
17+
# code_blocks: true
18+
# # Include tables
19+
# tables: true
20+
# # Include headings
21+
# headings: true
22+
# # Strict length checking
23+
# strict: false
24+
# # Stern length checking
25+
# stern: false
26+
27+
# MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md024.md
28+
MD024: false
29+
30+
# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md033.md
31+
MD033: false
32+
33+
# MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md040.md
34+
MD040: false
35+
36+
# MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md041.md
37+
MD041: false
38+
39+
# MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md042.md
40+
MD042: false
41+
42+
# MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md045.md
43+
MD045: false
44+
45+
# MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md051.md
46+
MD051: false
47+
48+
# MD056/table-column-count : Table column counts should match : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md056.md
49+
MD056: false

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ repos:
4141
hooks:
4242
- id: clang-format
4343
types_or: [ c++, c ]
44+
- repo: https://github.com/igorshubovych/markdownlint-cli
45+
rev: v0.44.0
46+
hooks:
47+
- id: markdownlint
48+
args: ["--fix"]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ To install the library from source, refer to the [Build Guide](https://power-gri
6868

6969
## Examples
7070

71-
Please refer to [Examples](https://github.com/PowerGridModel/power-grid-model-workshop/tree/main/examples) for more detailed examples for power flow and state estimation.
71+
Please refer to [Examples](https://github.com/PowerGridModel/power-grid-model-workshop/tree/main/examples) for more detailed examples for power flow and state estimation.
7272
Notebooks for validating the input data and exporting input/output data are also included.
7373

7474
## License
@@ -77,14 +77,14 @@ This project is licensed under the Mozilla Public License, version 2.0 - see [LI
7777

7878
## Licenses third-party libraries
7979

80-
This project includes third-party libraries,
80+
This project includes third-party libraries,
8181
which are licensed under their own respective Open-Source licenses.
82-
SPDX-License-Identifier headers are used to show which license is applicable.
82+
SPDX-License-Identifier headers are used to show which license is applicable.
8383
The concerning license files can be found in the [LICENSES](https://github.com/PowerGridModel/power-grid-model/tree/main/LICENSES) directory.
8484

8585
## Contributing
8686

87-
Please read [CODE_OF_CONDUCT](https://github.com/PowerGridModel/.github/blob/main/CODE_OF_CONDUCT.md), [CONTRIBUTING](https://github.com/PowerGridModel/.github/blob/main/CONTRIBUTING.md), [PROJECT GOVERNANCE](https://github.com/PowerGridModel/.github/blob/main/GOVERNANCE.md) and [RELEASE](https://github.com/PowerGridModel/.github/blob/main/RELEASE.md) for details on the process
87+
Please read [CODE_OF_CONDUCT](https://github.com/PowerGridModel/.github/blob/main/CODE_OF_CONDUCT.md), [CONTRIBUTING](https://github.com/PowerGridModel/.github/blob/main/CONTRIBUTING.md), [PROJECT GOVERNANCE](https://github.com/PowerGridModel/.github/blob/main/GOVERNANCE.md) and [RELEASE](https://github.com/PowerGridModel/.github/blob/main/RELEASE.md) for details on the process
8888
for submitting pull requests to us.
8989

9090
Visit [Contribute](https://github.com/PowerGridModel/power-grid-model/contribute) for a list of good first issues in this repo.

docs/advanced_documentation/c-api.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ SPDX-License-Identifier: MPL-2.0
77
# Use Power Grid Model through C API
88

99
While many users use Python API for Power Grid Model.
10-
This library also provides a C API.
11-
The main use case of C API is to integrate Power Grid Model into a non-Python application/library, namely, C, C++, JAVA, C#, etc.
10+
This library also provides a C API.
11+
The main use case of C API is to integrate Power Grid Model into a non-Python application/library, namely, C, C++, JAVA, C#, etc.
1212

13-
The C API consists of some
13+
The C API consists of some
1414
{{ "[header files]({}/power_grid_model_c/power_grid_model_c/include)".format(gh_link_head_blob) }}
15-
and a dynamic library (`.so` or `.dll`) built by a
15+
and a dynamic library (`.so` or `.dll`) built by a
1616
{{ "[cmake project]({}/power_grid_model_c/power_grid_model_c/CMakeLists.txt)".format(gh_link_head_blob) }}.
1717
Please refer to the [Build Guide](./build-guide.md) about how to build the library.
1818

1919
You can refer to the [C API Reference](../api_reference/power-grid-model-c-api-reference.rst)
20-
for a detailed documentation of the API.
21-
Please also have a look at an
20+
for a detailed documentation of the API.
21+
Please also have a look at an
2222
{{ "[example]({}/power_grid_model_c_example/main.c)".format(gh_link_head_blob) }}
2323
of C program to use this C API.
2424

@@ -37,7 +37,7 @@ and making it available to their binaries, e.g. by adding its location to `PATH`
3737

3838
## Opaque struct/pointer
3939

40-
As a common C API practice, we use [opaque struct/pointer](https://en.wikipedia.org/wiki/Opaque_pointer) in the API.
40+
As a common C API practice, we use [opaque struct/pointer](https://en.wikipedia.org/wiki/Opaque_pointer) in the API.
4141
The user creates the object by `PGM_create_*` function and release the object by `PGM_destroy_*` function.
4242
In other function calls, the user provide the relevant opaque pointer as the argument.
4343
The real memory layout of the object is unknown to the user.
@@ -50,21 +50,21 @@ Moreover, we might want to also retrieve some meta information from the calculat
5050
The C API uses a handle opaque object `PGM_Handle` to store all these kinds of error messages and information.
5151
You need to pass a handle pointer to most of the functions in the C API.
5252

53-
For example, after calling `PGM_create_model`, you can use `PGM_error_code` and `PGM_error_message`
53+
For example, after calling `PGM_create_model`, you can use `PGM_error_code` and `PGM_error_message`
5454
to check if there is error during the creation and the error message.
5555

5656
If you are calling the C API in multiple threads, each thread should have its own handle object created by `PGM_create_handle`.
5757

5858
## Calculation options
5959

60-
To execute a power grid calculation you need to specify many options,
60+
To execute a power grid calculation you need to specify many options,
6161
e.g., maximum number of iterations, error tolerance, etc.
6262
We could have declared all the calculation options as individual arguments in the `PGM_calculate` function.
63-
However, due to the lack of default argument in C,
63+
However, due to the lack of default argument in C,
6464
this would mean that the C API has a breaking change everytime we add a new option,
6565
which happends very often.
6666

67-
To solve this issue, we use another opaque object `PGM_Options`. The user creates an object with default options by `PGM_create_options`. You can then specify individual options by `PGM_set_*`.
67+
To solve this issue, we use another opaque object `PGM_Options`. The user creates an object with default options by `PGM_create_options`. You can then specify individual options by `PGM_set_*`.
6868
In the `PGM_calculate` function you need to pass a pointer to `PGM_Options`.
6969
In this way, we can ensure the API backwards compatibility.
7070
If we add a new option, it will get a default value in the `PGM_create_options` function.
@@ -77,7 +77,7 @@ For compatibility reasons, that format is dictated by the C API using the `PGM_m
7777

7878
We define the following concepts in the data hierarchy:
7979

80-
* Dataset: a collection of data buffers for a given purpose.
80+
* Dataset: a collection of data buffers for a given purpose.
8181
At this moment, we have four dataset types: `input`, `update`, `sym_output`, `asym_output`.
8282
* Component: a data buffer with the representation of all attributes of a physical grid component in our [data model](../user_manual/components.md), e.g., `node`.
8383
* Attribute: a property of given component. For example, `u_rated` attribute of `node` is the rated voltage of the node.
@@ -126,7 +126,7 @@ Data buffers are almost always allocated and freed in the heap. We provide two w
126126

127127
* You can use the function `PGM_create_buffer` and `PGM_destroy_buffer` to create and destroy buffer.
128128
In this way, the library is handling the memory (de-)allocation.
129-
* You can call some memory (de-)allocation function in your own code according to your platform,
129+
* You can call some memory (de-)allocation function in your own code according to your platform,
130130
e.g., `aligned_alloc` and `free`.
131131
You need to first call `PGM_meta_*` functions to retrieve the size and alignment of a component.
132132

@@ -141,10 +141,10 @@ Once you have the data buffer, you need to set or get attributes. We provide two
141141

142142
* You can use the function `PGM_buffer_set_value` and `PGM_buffer_get_value` to get and set values.
143143
* You can do pointer cast directly on the buffer pointer, by shifting the pointer to proper offset
144-
and cast it to a certain value type.
144+
and cast it to a certain value type.
145145
You need to first call `PGM_meta_*` functions to retrieve the correct offset.
146146

147-
Pointer cast is generally more efficient and flexible because you are not calling into the
147+
Pointer cast is generally more efficient and flexible because you are not calling into the
148148
dynamic library everytime. But it requires the user to retrieve the offset information first.
149149
Using the buffer helper function is more convenient but with some overhead.
150150

@@ -153,7 +153,7 @@ Using the buffer helper function is more convenient but with some overhead.
153153
In the C API we have a function `PGM_buffer_set_nan` which sets all the attributes in a buffer to `NaN`.
154154
In the calculation core, if an optional attribute is `NaN`, it will use the default value.
155155

156-
If you just want to set some attributes and keep everything else as `NaN`,
156+
If you just want to set some attributes and keep everything else as `NaN`,
157157
calling `PGM_buffer_set_nan` before you set attribute is convenient.
158158
This is useful especially in `update` dataset because you do not always update all the mutable attributes.
159159

docs/advanced_documentation/native-data-interface.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ and predefines all the corresponding `numpy.dtype`.
170170
The detailed explanation of all attributes of each component is given in
171171
[Graph Data model](../user_manual/data-model.md#attributes-of-components).
172172

173-
174173
One can import the `power_grid_meta_data` to get all the predefined `numpy.dtype` and create relevant arrays.
175174
The code below creates an array which is compatible with transformer input dataset.
176175

docs/api_reference/python-api-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SPDX-License-Identifier: MPL-2.0
88

99
This is the Python API reference for the `power-grid-model` library.
1010
Due to the nature of how Python module works, we cannnot hide the implementation detail completely from the user.
11-
As a general rule, any Python modules/functions/classes which are not documented in this API documentation,
11+
As a general rule, any Python modules/functions/classes which are not documented in this API documentation,
1212
are internal implementations.
1313
**The user should not use any of them. We do not guarantee the stability or even the existence of those modules.**
1414

docs/contribution/folder-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ The repository folder structure is as follows. The `docs` and `scripts` folders
2121
- `benchmark_cpp` contains a benchmark test case generator in C++.
2222
- `package_tests` contains an integration test CMake project that tests whether the C API package is correctly installed.
2323
- `unit` folder contains tests for the python code.
24-
- `data` contains validation test cases designed for every component and algorithm. Some sample network types are also included.
24+
- `data` contains validation test cases designed for every component and algorithm. Some sample network types are also included.
2525
The validation is either against popular power system analysis software or hand calculation.

docs/quickstart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ node['u_rated'] = [10.5e3, 10.5e3]
5757
The code above generates a node input array with two nodes,
5858
and assigns the attributes of the nodes to the array.
5959
Similarly, we can create input arrays for line, load, and generation.
60-
A dictionary of such arrays is used for `input_data` and `update_data`.
60+
A dictionary of such arrays is used for `input_data` and `update_data`.
6161

6262
```python
6363
# line
@@ -112,8 +112,8 @@ model = PowerGridModel(input_data, system_frequency=50.0)
112112

113113
## Power Flow Calculation
114114

115-
To run calculations, use the object methods {py:class}`power_grid_model.PowerGridModel.calculate_power_flow`
116-
or {py:class}`power_grid_model.PowerGridModel.calculate_state_estimation` functions.
115+
To run calculations, use the object methods {py:class}`power_grid_model.PowerGridModel.calculate_power_flow`
116+
or {py:class}`power_grid_model.PowerGridModel.calculate_state_estimation` functions.
117117
Refer [Calculations](user_manual/calculations) for more details on the many optional arguments.
118118

119119
```python

docs/user_manual/calculations.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ We provide the control logic used for tap changing. For simplicity, we demonstra
652652
- Exploit the neighbourhood of all transformers (see {hoverxreftooltip}`user_manual/calculations:Initialization and exploitation of regulated transformers`)
653653
- Re-run the iteration in the above if any of the tap positions changed by the exploitation.
654654

655-
In the case where the control side of the regulator and the tap side of the transformer are at the same side, the control logic of taps will be reverted (see `user_manual/calculations:Initialization and exploitation of regulated transformers`).
655+
In the case where the control side of the regulator and the tap side of the transformer are at the same side, the control logic of taps will be reverted (see `user_manual/calculations:Initialization and exploitation of regulated transformers`).
656656
The exploitation of the neighbourhood ensures that the actual optimum is not accidentally missed due to feedback mechanisms in the grid.
657657

658658
```{note}
@@ -688,7 +688,6 @@ Internally, to achieve an optimal regulated tap position, the control algorithm
688688
| regulator control side != transformer tap side | `tap_max` | `tap_min` | step up | step down |
689689
| regulator control side == transformer tap side | `tap_min` | `tap_max` | step down | step up |
690690

691-
692691
##### Search methods used for tap changing optimization
693692

694693
Given the discrete nature of the finite tap ranges, we use the following search methods to find the next tap position along the exploitation direction.

0 commit comments

Comments
 (0)