@@ -17,6 +17,7 @@ If you are instead interested in usage documentation, please refer to the
1717- [ Notes on Code Style] ( #notes-on-code-style )
1818- [ Project Structure and CMake] ( #project-structure-and-cmake )
1919- [ Documenting Code] ( #documenting-code )
20+ - [ Testing Code] ( #testing-code )
2021
2122## Found a Bug?
2223
@@ -40,10 +41,18 @@ resources to help you get started with open source contributions:
4041- [ Basic explanation of Git submodules] ( https://gist.github.com/gitaarik/8735255 )
4142by [ ** @gitaarik ** ] ( https://github.com/gitaarik )
4243
44+ ### Git Branches
45+
46+ Our repositories use the following approach to organize and keep track of branches.
47+ The ` main ` branch typically represents the most recently released version of the software.
48+ The ` dev ` branch stages changes before they are merged into ` main ` and a new release is created.
49+ New features or bug fixes should be developed on individual "feature branches" with descriptive names.
50+ When complete, features branches should merge into ` dev ` .
51+
4352### Git Submodules
4453
45- Software in the ITS Propagation Library is implemented primarily in C++. Each
46- piece of software has a primary repository which contains the base C++ implementation,
54+ Software in the ITS Propagation Library is implemented primarily in C++. Each piece
55+ of software has a primary repository which contains the base C++ implementation,
4756test data and resources, and common files used by the multi-language wrappers.
4857Interfaces for additional programming languages are provided in separate repositories,
4958which are linked to the primary repository as [ Git submodules] ( https://gist.github.com/gitaarik/8735255 ) .
@@ -69,17 +78,22 @@ or [using the command line](https://docs.github.com/en/github/getting-started-wi
6978incrementally to your fork. See the sections below for details about unit tests,
7079code style, and documentation.
7180
72- 1 . When you're done making changes, create a pull request, also known as a PR.
73- In your PR, please include a meaningful description of the changes you've made.
74- If your PR solves an issue,
81+ 1 . When you're done making changes, create a pull request (PR). In your PR, please include
82+ a meaningful description of the changes you've made. If your PR solves an issue,
7583[ link to it] ( https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue ) !
76- Once you submit your PR, a maintainer will review your changes. We may ask questions
77- or request additional changes which must be addressed before the PR can be merged.
7884
79- When your PR is approved and merged, your changes will be a part of the main
80- branch of the repository. A new release may or may not be immediately created,
81- depending on the changes made. If a new release is not immediately made, your
82- changes will be packaged into the next release.
85+ Once you submit your PR, a maintainer will review your changes to determine
86+ whether or not they should be merged. We may ask questions or request additional
87+ changes which must be addressed. For example, we may request changes so that the code
88+ meets structure, formatting, accuracy, or testing requirements.
89+
90+ If your PR is approved and merged, your changes will be a part of the ` dev `
91+ branch of the repository, where they will stay until a new release is made. At that
92+ point, ` dev ` will merge into ` main ` and a new release will be created. The maintainers
93+ of a repository hold the authority on when a new release should be created. For example,
94+ important bug fixes may take higher priority, while small improvements may stay on ` dev `
95+ for a while. Rest assured, even if a new release is not immediately made, your approved
96+ changes will be always packaged into the next release.
8397
8498## Notes on Code Style
8599
@@ -104,7 +118,9 @@ It is recommended to use this tool to autoformat Python code when checked in.
104118Software in the ITS Propagation Library is primarily implemented in C++, then
105119wrapped with interfaces exposing the C++ library to users of other languages. The
106120primary repository for each software package uses [ CMake] ( https://cmake.org/ ) to
107- handle cross-platform C++ build configuration, C++ unit tests, and generation of
121+ handle cross-platform C++ build configuration, C++ unit tests (with
122+ [ GoogleTest] ( https://github.com/google/googletest ) and
123+ [ CTest] ( https://cmake.org/cmake/help/latest/manual/ctest.1.html ) ), and generation of
108124API documentation (with [ Doxygen] ( https://www.doxygen.nl/ ) ). Many IDEs support CMake
109125integration in some form or fashion, and it is recommended that you familiarize yourself
110126with any such functionality of your chosen IDE.
@@ -113,8 +129,16 @@ This section shows a typical project structure for a primary (i.e., non-wrapper)
113129repository. For details about wrapper repositories, refer to their own README files.
114130
115131``` bash
132+ app/ # The command-line driver which can run the library
133+ data/ # Example input and output files for use with the driver
134+ include/ # Headers used by the command-line driver
135+ src/ # Source code for the command-line driver
136+ tests/ # Header and source files for testing the command-line driver
137+ CMakeLists.txt # Configuration for the command-line driver and its tests
138+ README.md # Usage information for the command-line driver
116139docs/
117140 CMakeLists.txt # Doxygen configuration
141+ ... # Static files (images, HTML, CS, Markdown) used by Doxygen
118142extern/
119143 ... # External Git submodules/dependencies
120144include/
@@ -128,7 +152,7 @@ tests/
128152 < TestDataFiles> .csv # Testing data goes here. Does not have to be CSV.
129153 < TestFiles> .cpp # Unit tests, usually one test file per source file.
130154 < TestFiles> .h # Any headers used by tests go here as well.
131- CMakeLists.txt # CTest+GTest config. Must add names of test files here.
155+ CMakeLists.txt # CTest+GTest config. Files containing tests must be included here.
132156wrap/
133157 dotnet/ # C#/.NET wrapper submodule. Should contain CMakeLists.txt
134158 matlab/ # MATLAB wrapper submodule. Should contain CMakeLists.txt
@@ -138,34 +162,62 @@ CMakePresets.json # Presets for CMake, e.g. "release", "debug", etc.
138162...
139163```
140164
165+ ### CMake Options and CMake Presets
166+
141167As you can see, multiple ` CMakeLists.txt ` files exist within the project. Each
142168one contains configurations relevant to the directory where it is stored. For
143- example, the ` tests/CMakeLists.txt ` file configures unit tests using CMake.
144-
145- When modifying or extending this software, ensure that unit tests are added to
146- cover your new code. In general, each C++ file in ` src/ ` has a corresponding C++
147- file in ` tests/ ` which implements unit tests. If you've added a new file in ` tests/ ` ,
148- make sure to add that file to the executable in ` tests/CMakeLists.txt ` .
149-
150- To compile the software, from the cloned repository, run:
169+ example, the ` tests/CMakeLists.txt ` file configures unit tests using CMake. The
170+ top-level ` CMakeLists.txt ` stores the primary project configuration and includes
171+ the lower-level configurations based on the preset or specified CMake options.
172+
173+ The following CMake options are used for top-level project configuration:
174+
175+ | Option | Default | Definition |
176+ | --------------------| ---------| ------------------------------------------|
177+ | ` BUILD_DOCS ` | ` ON ` | Generate documentation site with Doxygen |
178+ | ` BUILD_DRIVER ` | ` ON ` | Build the command-line driver executable |
179+ | ` RUN_DRIVER_TESTS ` | ` ON ` | Test the command-line driver executable |
180+ | ` DOCS_ONLY ` | ` OFF ` | Skip all steps _ except_ generating the documentation site |
181+ | ` RUN_TESTS ` | ` ON ` | Run unit tests for the main library |
182+ | ` COPY_TO_WRAPPERS ` | ` ON ` | Copy the compiled shared library into wrapper submodules |
183+
184+ [ CMake Presets] ( https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html ) are
185+ provided to support common build configurations. These are specified in the
186+ ` CMakePresets.json ` file. The ` release ` preset will compile the library and driver
187+ with optimizations, build the documentation site, and run all unit tests. The ` debug ` preset
188+ will skip building the documentation site, driver, and driver tests, which can be useful for
189+ rapid development and testing. Additionally, the Debug configuration will attempt to pass
190+ debug flags to the compiler. Finally, the "docsOnly" preset skips all steps except for
191+ generating the Doxygen documentation site.
192+
193+ | Option | ` release ` preset | ` debug ` preset | ` docsOnly ` preset |
194+ | --------------------| ------------------| ----------------| -------------------|
195+ | ` DOCS_ONLY ` | ` OFF ` | ` OFF ` | ` ON ` |
196+ | ` RUN_TESTS ` | ` ON ` | ` ON ` | ` OFF ` |
197+ | ` CMAKE_BUILD_TYPE ` | ` Release ` | ` Debug ` | not set |
198+ | ` BUILD_DOCS ` | ` ON ` | ` OFF ` | ` ON ` |
199+ | ` BUILD_DRIVER ` | ` ON ` | ` OFF ` | ` OFF ` |
200+ | ` RUN_DRIVER_TESTS ` | ` ON ` | ` OFF ` | ` OFF ` |
201+
202+ Below are some examples of how CMake can be called to compile this software.
151203
152204``` bash
153- cmake -S . -B build
154- cmake --build build
155- ```
205+ # Configure and compile in release configuration
206+ cmake --preset release
207+ cmake --build --preset release
156208
157- After compiling the library, you can run unit tests as follows. First, change your
158- working directory to the ` build ` directory, then run:
209+ # Use the release configuration but don't build Doxygen docs
210+ cmake --preset release -DBUILD_DOCS=OFF
211+ cmake --build --preset release
159212
160- ``` bash
161- ctest
162- ```
213+ # Configure and compile in debug configuration
214+ cmake --preset debug
215+ cmake --build --preset debug
163216
164- The included ` CMakePresets.json ` provides presets for common CMake configurations.
165- The "Release" configurations will compile the software with optimizations, build
166- documentation, and configure unit tests. The "Debug" configurations will skip building
167- the documentation, which is useful for rapid development and testing. Additionally,
168- the Debug configuration will attempt to pass debug flags to the compiler.
217+ # Use the release configuration but don't run driver tests
218+ cmake --preset release -DRUN_DRIVER_TESTS=OFF
219+ cmake --build --preset release
220+ ```
169221
170222### Supported Platforms and Build Options
171223
@@ -187,7 +239,8 @@ build and deploy the documentation using GitHub Pages. This action will ensure
187239that any new code has been accompanied by Doxygen-formatted documentation. Code
188240will not be merged until and unless it is completely documented using Doxygen,
189241and the GitHub action successfully generates the documentation site. Below is an
190- example showing the expected documentation formats.
242+ example showing the expected documentation formats. Except for inline documentation,
243+ use the JavaDoc banner style [ described by Doxygen] ( https://www.doxygen.nl/manual/docblocks.html )
191244
192245``` cpp
193246constexpr double = PI 3.1415 ; /* *< Inline format, e.g. for constants */
@@ -197,7 +250,8 @@ constexpr double = PI 3.1415; /**< Inline format, e.g. for constants */
197250 *
198251 * This is an optional, longer description of the function. It can include
199252 * LaTeX formatting, for example: this function doubles its input @f$ x @f$ and
200- * returns a value @f$ y @f$ with @f$ y = 2x @f$.
253+ * returns a value @f$ y @f$ with @f$ y = 2x @f$. This whole documentation block
254+ * is using the JavaDoc banner style!
201255 *
202256 * @param[in] x The input and its expected units
203257 * @return The result @f$ y = 2x @f$
@@ -208,6 +262,20 @@ double doubleTheInput(double x)
208262}
209263```
210264
265+ ### Doxygen for C++ Libraries
266+
267+ The base C++ libraries include Doxygen configurations which generate static
268+ websites from code comments. These documentation sites are published as developer
269+ reference documentation using GitHub Pages. When building the Doxygen site locally,
270+ The site is generated in `docs/html/` and the main page can be accessed at `docs/html/index.html`.
271+ When new releases are made, GitHub Actions workflows are triggered which build and deploy
272+ the Doxygen site to GitHub Pages.
273+
274+ ### MATLAB Wrappers
275+
276+ Most code in the MATLAB wrapper is actually written in C. In these files, the same
277+ documentation style as noted above for C++ should be used.
278+
211279### Python Wrappers
212280
213281The Python wrapper code is documented in the [Sphinx](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html)
@@ -236,8 +304,9 @@ def double_the_input(x: float) -> float:
236304
237305### C#/.NET Wrappers
238306
239- In C#/.NET, documentation comments are written in XML format and are used to
240- generate documentation through tools like Visual Studio. Use ` <summary> ` tags to
307+ In C#/.NET, documentation comments are written in
308+ [ XML format] ( https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/documentation-comments )
309+ and are used to generate documentation through tools like Visual Studio. Use ` <summary> ` tags to
241310provide brief descriptions of classes, constants, functions, etc. Functions should
242311include ` <param> ` and ` <returns> ` elements for all inputs and outputs. An example
243312of this documentation style is shown below.
@@ -265,3 +334,17 @@ public class CalculationUtils
265334 }
266335}
267336```
337+
338+ ## Testing Code
339+
340+ When modifying or extending this software, ensure that unit tests are added to
341+ cover your new code. In general, each C++ file in ` src/ ` has a corresponding C++
342+ file in ` tests/ ` which implements unit tests. If you've added a new file in ` tests/ ` ,
343+ make sure to add that file to the executable in ` tests/CMakeLists.txt ` .
344+
345+ After compiling the library, you can run unit tests as follows. First, change your
346+ working directory to the ` build ` directory, then run:
347+
348+ ``` bash
349+ ctest
350+ ```
0 commit comments