Skip to content

Commit 05edd08

Browse files
authored
Merge pull request #1012 from PowerGridModel/feature/markdown-sentences-new-line
Documentation: markdown sentences new line
2 parents 7c91859 + 9766c9f commit 05edd08

File tree

20 files changed

+693
-330
lines changed

20 files changed

+693
-330
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
- id: clang-format
3636
types_or: [ c++, c ]
3737
- repo: https://github.com/igorshubovych/markdownlint-cli
38-
rev: v0.44.0
38+
rev: v0.45.0
3939
hooks:
4040
- id: markdownlint
4141
args: ["--fix"]

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@
3333
"projectKey": "PowerGridModel_power-grid-model"
3434
},
3535
"C_Cpp.formatting": "clangFormat",
36-
"C_Cpp.clang_format_fallbackStyle": "LLVM"
36+
"C_Cpp.clang_format_fallbackStyle": "LLVM",
37+
"[markdown]": {
38+
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint",
39+
"editor.rulers": [
40+
120
41+
]
42+
}
3743
}

docs/advanced_documentation/build-guide.md

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ SPDX-License-Identifier: MPL-2.0
66

77
# Build Guide
88

9-
This document explains how you can build this library from source, including some examples of build environment. In this
9+
This document explains how you can build this library from source, including some examples of build environment.
10+
In this
1011
repository there are three builds:
1112

1213
* A `power-grid-model` [pip](https://pypi.org/project/power-grid-model/) Python package with C++ extension as the calculation core.
@@ -22,22 +23,27 @@ repository there are three builds:
2223

2324
## Build Requirements
2425

25-
To build the library from source, you need to first prepare the compiler toolchains and the build dependencies. In this
26-
section a list of general requirements are given. After this section there are examples of setup in Linux (Ubuntu 22.04),
26+
To build the library from source, you need to first prepare the compiler toolchains and the build dependencies.
27+
In this
28+
section a list of general requirements are given.
29+
After this section there are examples of setup in Linux (Ubuntu 22.04),
2730
Windows 10, and macOS (Big Sur).
2831

2932
### Architecture Support
3033

31-
This library is written and tested on `x86_64` and `arm64` architecture. Building the library in `IA-32` might be working, but is
34+
This library is written and tested on `x86_64` and `arm64` architecture.
35+
Building the library in `IA-32` might be working, but is
3236
not tested.
3337

3438
The source code is written with the mindset of ISO standard C++ only, i.e. avoid compiler-extension or platform-specific
35-
features as much as possible. In this way the effort to port the library to other platform/architecture might be
39+
features as much as possible.
40+
In this way the effort to port the library to other platform/architecture might be
3641
minimum.
3742

3843
### Compiler Support
3944

40-
You need a C++ compiler with C++20 support. Below is a list of tested compilers:
45+
You need a C++ compiler with C++20 support.
46+
Below is a list of tested compilers:
4147

4248
#### Linux
4349

@@ -110,7 +116,8 @@ Then you can run the tests.
110116
pytest
111117
```
112118

113-
A basic `self_test` function is provided to check if the installation was successful and ensures there are no build errors, segmentation violations, undefined symbols, etc. It performs multiple C API calls, runs through the main data flow, and verifies the integrity of serialization and deserialization.
119+
A basic `self_test` function is provided to check if the installation was successful and ensures there are no build errors, segmentation violations, undefined symbols, etc.
120+
It performs multiple C API calls, runs through the main data flow, and verifies the integrity of serialization and deserialization.
114121

115122
```python
116123
from power_grid_model.utils import self_test
@@ -151,7 +158,8 @@ cmake --install build/ --config Release --prefix install/
151158
### Developer build
152159

153160
If you opt for a developer build of Power Grid Model,
154-
you can use the pre-defined CMake presets to enable developer build, including all the tests, warnings, examples, and benchmark. In the presets the [Ninja](https://ninja-build.org/) generator is used.
161+
you can use the pre-defined CMake presets to enable developer build, including all the tests, warnings, examples, and benchmark.
162+
In the presets the [Ninja](https://ninja-build.org/) generator is used.
155163
In principle, you can use any C++ IDE with cmake and ninja support to develop the C++ project.
156164
It is also possible to use the bare CMake CLI to set up the project.
157165
Supported presets for your development platform can be listed using `cmake --list-presets`.
@@ -165,23 +173,32 @@ In the developer build the following build targets (directories) are enabled:
165173
* `tests/benchmark_cpp`: the C++ benchmark target for performance measure.
166174
* `power_grid_model_c_example`: an example C program to call the dynamic library
167175

168-
On Linux/macOS, the presets will use command `clang`/`clang++` or `gcc`/`g++` to find the relevant `clang` or `gcc` compiler. It is the developer's reponsiblity to properly define symbolic links (which should be discoverable through `PATH` environment variable) of `clang` or `gcc` compiler in your system. If you want to build with `clang-tidy`, you also need to define symbolic link of `clang-tidy` to point to the actual `clang-tidy` executable of your system.
176+
On Linux/macOS, the presets will use command `clang`/`clang++` or `gcc`/`g++` to find the relevant `clang` or `gcc` compiler.
177+
It is the developer's reponsiblity to properly define symbolic links (which should be discoverable through `PATH` environment variable) of `clang` or `gcc` compiler in your system.
178+
If you want to build with `clang-tidy`, you also need to define symbolic link of `clang-tidy` to point to the actual `clang-tidy` executable of your system.
169179

170-
Similar also applies to Windows: the presets will use command `cl.exe` or `clang-cl.exe` to find the compiler. Developer needs to make sure the they are discoverable in `PATH`. For x64 Windows native development using MSVC or Clang CL, please use the `x64 Native Command Prompt`, which uses `vcvarsall.bat` to set up the appropriate build environment.
180+
Similar also applies to Windows: the presets will use command `cl.exe` or `clang-cl.exe` to find the compiler.
181+
Developer needs to make sure the they are discoverable in `PATH`.
182+
For x64 Windows native development using MSVC or Clang CL, please use the `x64 Native Command Prompt`, which uses `vcvarsall.bat` to set up the appropriate build environment.
171183

172184
## Visual Studio Code Support
173185

174-
You can use any IDE to develop this project. As a popular cross-platform IDE, the settings for Visual Studio Code is preconfigured in the folder `.vscode`. You can open the repository folder with VSCode and the configuration will be loaded automatically.
186+
You can use any IDE to develop this project.
187+
As a popular cross-platform IDE, the settings for Visual Studio Code is preconfigured in the folder `.vscode`.
188+
You can open the repository folder with VSCode and the configuration will be loaded automatically.
175189

176190
```{note}
177-
VSCode (as well as some other IDEs) does not set its own build environment itself. For optimal usage, open the folder
178-
using `code <project_dir>` from a terminal that has the environment set up. See above section for tips.
191+
VSCode (as well as some other IDEs) does not set its own build environment itself.
192+
For optimal usage, open the folder
193+
using `code <project_dir>` from a terminal that has the environment set up.
194+
See above section for tips.
179195
```
180196

181197
## Build Script for Linux/macOS
182198

183199
There is a convenient shell script to build the cmake project in Linux or macOS:
184-
{{ "[`build.sh`]({}/build.sh)".format(gh_link_head_blob) }}. You can study the file and write your own build script.
200+
{{ "[`build.sh`]({}/build.sh)".format(gh_link_head_blob) }}.
201+
You can study the file and write your own build script.
185202
The following options are supported in the build script.
186203

187204
```shell
@@ -196,8 +213,8 @@ To list the available presets, run `./build.sh -h`.
196213
197214
## Example Setup for Ubuntu 24.04 (in WSL or physical/virtual machine)
198215
199-
In this section an example is given for setup in Ubuntu 24.04. You can use this example in Windows Subsystem for Linux (
200-
WSL), or in a physical/virtual machine.
216+
In this section an example is given for setup in Ubuntu 24.04.
217+
You can use this example in Windows Subsystem for Linux (WSL), or in a physical/virtual machine.
201218
202219
### Environment variables
203220
@@ -258,7 +275,8 @@ pytest
258275
259276
There is a convenient shell script to build the cmake project: {{ "[`build.sh`]({}/build.sh)".format(gh_link_head_blob) }}.
260277
261-
As an example, go to the root folder of repo. Use the following command to build the project in release mode:
278+
As an example, go to the root folder of repo.
279+
Use the following command to build the project in release mode:
262280
263281
```shell
264282
./build.sh -p <preset>
@@ -296,11 +314,13 @@ Define the following environment variable user-wide:
296314
297315
### Software Toolchains
298316
299-
You need to install the MSVC compiler. You can either install the whole Visual Studio IDE or just the build tools.
317+
You need to install the MSVC compiler.
318+
You can either install the whole Visual Studio IDE or just the build tools.
300319
301320
* [Visual Studio Build Tools](https://aka.ms/vs/17/release/vs_BuildTools.exe) (free)
302321
* Select C++ build tools
303-
* Full [Visual Studio](https://visualstudio.microsoft.com/vs/) (All three versions are suitable. Check the license!)
322+
* Full [Visual Studio](https://visualstudio.microsoft.com/vs/) (All three versions are suitable.
323+
Check the license!)
304324
* Select Desktop Development with C++
305325
* [Optional] Select `C++ Clang tools for Windows`
306326
@@ -310,7 +330,8 @@ Other toolchains:
310330
* [Git](https://git-scm.com/downloads)
311331
312332
```{note}
313-
It is also possible to use any other `conda` provider like [Miniconda](https://docs.conda.io/en/latest/miniconda.html). However, we recommend using [Miniforge](https://github.com/conda-forge/miniforge), because it is published under BSD License and by default does not have any references to commercially licensed software.
333+
It is also possible to use any other `conda` provider like [Miniconda](https://docs.conda.io/en/latest/miniconda.html).
334+
However, we recommend using [Miniforge](https://github.com/conda-forge/miniforge), because it is published under BSD License and by default does not have any references to commercially licensed software.
314335
```
315336
316337
```{note}
@@ -320,7 +341,8 @@ It is possible to enable long paths in Windows by following the steps in the [Mi
320341
321342
### C++ packages
322343
323-
The recommended way to get C++ package is via `conda`. Open a miniconda console.
344+
The recommended way to get C++ package is via `conda`.
345+
Open a miniconda console.
324346
325347
```shell
326348
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest
@@ -359,7 +381,9 @@ It is possible to enable long paths in Windows by following the steps in the [Mi
359381
360382
If you have installed Visual Studio 2019/2022 (not the build tools), you can open the repo folder as a cmake project.
361383
The IDE should be able to automatically detect the Visual Studio cmake configuration file
362-
`CMakePresets.json`. Several configurations are pre-defined. It includes debug and release builds.
384+
`CMakePresets.json`.
385+
Several configurations are pre-defined.
386+
It includes debug and release builds.
363387
364388
* `msvc-debug`, displayed as `Debug (MSVC)`
365389
* `msvc-release`, displayed as `Release (MSVC)`.
@@ -398,8 +422,10 @@ brew install ninja cmake boost eigen nlohmann-json msgpack-cxx doctest
398422
399423
### Build Python Library from Source
400424
401-
It is recommended to create a virtual environment. Clone repository, create and activate virtual environment, and
402-
install the build dependency. go to a root folder you prefer to save the repositories.
425+
It is recommended to create a virtual environment.
426+
Clone repository, create and activate virtual environment, and
427+
install the build dependency.
428+
go to a root folder you prefer to save the repositories.
403429
404430
```shell
405431
git clone https://github.com/PowerGridModel/power-grid-model.git
@@ -421,7 +447,8 @@ There is a convenient shell script to build the cmake project: {{ "[`build.sh`](
421447
422448
**Note: the test coverage option is not supported in macOS.**
423449
424-
As an example, go to the root folder of repo. Use the following command to build the project in release mode:
450+
As an example, go to the root folder of repo.
451+
Use the following command to build the project in release mode:
425452
426453
```shell
427454
./build.sh -p <preset>
@@ -455,17 +482,23 @@ The {{ "[package tests]({}/tests/package_tests)".format(gh_link_head_blob) }} pr
455482
project contained in {{ "[`tests/package_tests`]({}/tests/package_tests)".format(gh_link_head_blob) }}.
456483
457484
This project is designed to test and illustrate finding and linking to the installed package from the Power Grid Model
458-
project. Setup of this project is done the same way as the setup of the main project mentioned in the above, but with
485+
project.
486+
Setup of this project is done the same way as the setup of the main project mentioned in the above, but with
459487
the {{ "[`tests/package_tests`]({}/tests/package_tests)".format(gh_link_head_blob) }} directory as its root folder.
460488
461489
```{note}
462-
This project has the main project as a required dependency. Configuration will fail if the main project has not been
490+
This project has the main project as a required dependency.
491+
Configuration will fail if the main project has not been
463492
built and installed, e.g. using `cmake --build --preset <preset> --target install` for the current preset.
464493
```
465494
466495
## Documentation
467496
468-
The documentation is built in [Sphinx](https://github.com/sphinx-doc/sphinx). It can be built locally in a Python environment. The packages required for building it can be found under the `[doc]` optional dependencies. In addition, the `power-grid-model` Python package needs to be built by following the steps mentioned [above](#build-python-package). After that, the documentation specific packages can be installed via:
497+
The documentation is built in [Sphinx](https://github.com/sphinx-doc/sphinx).
498+
It can be built locally in a Python environment.
499+
The packages required for building it can be found under the `[doc]` optional dependencies.
500+
In addition, the `power-grid-model` Python package needs to be built by following the steps mentioned [above](#build-python-package).
501+
After that, the documentation specific packages can be installed via:
469502
470503
```shell
471504
pip install -e .[doc]
@@ -475,7 +508,8 @@ pip install -e .[doc]
475508
The `pip install .` part of the command installs the complete package from scratch.
476509
```
477510
478-
The C API documentation is generated using [Doxygen](https://www.doxygen.nl). If you do not have Doxygen installed, it can also be temporarily bypassed by commenting out the `breathe` settings in `docs/conf.py`.
511+
The C API documentation is generated using [Doxygen](https://www.doxygen.nl).
512+
If you do not have Doxygen installed, it can also be temporarily bypassed by commenting out the `breathe` settings in `docs/conf.py`.
479513
480514
The documentation can be built with the following commands, resulting in HTML files of the webpages which can be found in `docs/_build/html` directory.
481515

docs/advanced_documentation/c-api.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ In this documentation, the main design choices and concepts of the C API are pre
2626

2727
## Finding and linking the package
2828

29-
The package can be loaded using the Config mode of the `find_package` CMake command. An
29+
The package can be loaded using the Config mode of the `find_package` CMake command.
30+
An
3031
{{ "[example project]({}/tests/package_tests/CMakeLists.txt)".format(gh_link_head_blob) }} is provided by the
3132
{{ "[Git project]({})".format(gh_link_head_tree) }}, which is also used for testing the package.
3233

@@ -64,7 +65,9 @@ However, due to the lack of default argument in C,
6465
this would mean that the C API has a breaking change everytime we add a new option,
6566
which happends very often.
6667

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_*`.
68+
To solve this issue, we use another opaque object `PGM_Options`.
69+
The user creates an object with default options by `PGM_create_options`.
70+
You can then specify individual options by `PGM_set_*`.
6871
In the `PGM_calculate` function you need to pass a pointer to `PGM_Options`.
6972
In this way, we can ensure the API backwards compatibility.
7073
If we add a new option, it will get a default value in the `PGM_create_options` function.
@@ -80,7 +83,8 @@ We define the following concepts in the data hierarchy:
8083
* Dataset: a collection of data buffers for a given purpose.
8184
At this moment, we have four dataset types: `input`, `update`, `sym_output`, `asym_output`.
8285
* 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`.
83-
* Attribute: a property of given component. For example, `u_rated` attribute of `node` is the rated voltage of the node.
86+
* Attribute: a property of given component.
87+
For example, `u_rated` attribute of `node` is the rated voltage of the node.
8488

8589
Additionally, at this time, we distinguish two buffer types: [component buffers](#component-buffers) and [attribute buffers](#attribute-buffers).
8690

@@ -122,7 +126,8 @@ iiiift iiiift iiiift <-- data: 6 bytes per line: 4 bytes for the ID, 1 for
122126

123127
#### Create and destroy buffer
124128

125-
Data buffers are almost always allocated and freed in the heap. We provide two ways of doing so.
129+
Data buffers are almost always allocated and freed in the heap.
130+
We provide two ways of doing so.
126131

127132
* You can use the function `PGM_create_buffer` and `PGM_destroy_buffer` to create and destroy buffer.
128133
In this way, the library is handling the memory (de-)allocation.
@@ -137,15 +142,17 @@ You cannot use `PGM_destroy_buffer` to release a buffer created in your own code
137142

138143
#### Set and get attribute
139144

140-
Once you have the data buffer, you need to set or get attributes. We provide two ways of doing so.
145+
Once you have the data buffer, you need to set or get attributes.
146+
We provide two ways of doing so.
141147

142148
* You can use the function `PGM_buffer_set_value` and `PGM_buffer_get_value` to get and set values.
143149
* You can do pointer cast directly on the buffer pointer, by shifting the pointer to proper offset
144150
and cast it to a certain value type.
145151
You need to first call `PGM_meta_*` functions to retrieve the correct offset.
146152

147153
Pointer cast is generally more efficient and flexible because you are not calling into the
148-
dynamic library everytime. But it requires the user to retrieve the offset information first.
154+
dynamic library everytime.
155+
But it requires the user to retrieve the offset information first.
149156
Using the buffer helper function is more convenient but with some overhead.
150157

151158
#### Set NaN function
@@ -183,7 +190,8 @@ A combination of attribute buffers with the same amount of elements has the powe
183190
The type (implying the size) of each attribute can be found using the `PGM_meta_attribute_ctype`.
184191

185192
Since all attributes consist of primitive types, operations are straightforward.
186-
We therefore do not provide explicit interface functionality to create an attribute buffer. Instead, you should use `PGM_dataset_const_add_buffer` or `PGM_dataset_mutable_add_buffer` with empty data (`NULL`) to set a component buffer for data in columnar-format, and use the functions `PGM_dataset_const_add_attribute_buffer` and `PGM_dataset_mutable_add_attribute_buffer` to add the attribute buffers directly to a dataset.
193+
We therefore do not provide explicit interface functionality to create an attribute buffer.
194+
Instead, you should use `PGM_dataset_const_add_buffer` or `PGM_dataset_mutable_add_buffer` with empty data (`NULL`) to set a component buffer for data in columnar-format, and use the functions `PGM_dataset_const_add_attribute_buffer` and `PGM_dataset_mutable_add_attribute_buffer` to add the attribute buffers directly to a dataset.
187195

188196
## Dataset views
189197

0 commit comments

Comments
 (0)