Skip to content

Commit b5e44b0

Browse files
committed
use makefile and update documentation
1 parent 96a12c5 commit b5e44b0

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

.github/workflows/codechecks.yml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,19 @@
44
name: Codechecks
55
on: [push, pull_request]
66
jobs:
7-
clang-format:
7+
code-format:
88
runs-on: macos-latest
99
steps:
1010
- uses: actions/checkout@v3
1111
- name: Install dependencies
1212
run: |
1313
brew install clang-format
14+
brew install npm
15+
npm init -y
16+
npm install prettier
1417
- name: Run clang-format
1518
run: |
1619
mkdir Release
1720
cd Release
1821
cmake ..
19-
make codecheck
20-
21-
prettier:
22-
runs-on: ubuntu-latest
23-
steps:
24-
- uses: actions/checkout@v3
25-
- name: Set up Node
26-
uses: actions/setup-node@v4
27-
- name: Install Prettier
28-
run: |
29-
brew install npm
30-
npm init -y
31-
npm install prettier
32-
- name: Run Prettier check
33-
run: |
34-
npm run check || (
35-
echo ""
36-
echo "JSON formatting is incorrect."
37-
echo "Run 'npm run format' locally and commit the changes."
38-
exit 1
39-
)
22+
make codecheck

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,12 @@ set(SDIR ${PROJECT_SOURCE_DIR}/src/**/)
256256

257257
# format the code
258258
add_custom_target(codeformat
259+
COMMAND npm run format
259260
COMMAND find ${SDIR}/*.h ${SDIR}/*.cpp | xargs clang-format -style=file:${PROJECT_SOURCE_DIR}/.clang-format -i)
260261

261262
# check code format
262263
add_custom_target(codecheck
264+
COMMAND npm run check
263265
COMMAND find ${SDIR}/*.h ${SDIR}/*.cpp | xargs clang-format -style=file:${PROJECT_SOURCE_DIR}/.clang-format --dry-run --Werror)
264266

265267
set_target_properties(pysvzerod PROPERTIES

docs/pages/developer_guide.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,13 @@ Steps required to visualize a new block with svZeroDSolver Visualization applica
7272

7373
# Code Style
7474

75-
We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
76-
77-
## Formatting {#formatting}
78-
79-
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to automatically
80-
format our code accoring to the [Google Style](https://google.github.io/styleguide/cppguide.html),
81-
as specified in the `.clang-format` file. This increases readability and maintainability of the code
75+
We use automatic code formatting for certain files to increase readability and maintainability of the code
8276
while enabling you to focus on coding.
8377

84-
There are tools for your favorite IDE to automatically format your code. Examples are:
85-
- [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
86-
- [vim](https://github.com/rhysd/vim-clang-format)
87-
- [and many more](https://clang.llvm.org/docs/ClangFormat.html)
78+
## Formatting {#formatting}
79+
The following files are automatically formatted:
80+
- Source code (`.cpp, .h`): [clang-format](https://clang.llvm.org/docs/ClangFormat.html) as specified in `.clang-format` (defaults to [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html))
81+
- Test cases and results (`.json`): [Prettier](https://prettier.io/) as specified in `.prettierrc`
8882

8983
Before formatting the code with clang-format, ensure that you have latest clang-format version by running `clang-format --version`. To upgrade `clang-format` use the following commands
9084
* on MacOS: `brew upgrade clang-format`
@@ -117,6 +111,27 @@ requirements.
117111

118112
On Sherlock at Stanford, clang-format is included in the `llvm` module.
119113

114+
## Visual Studio Code
115+
Install [clang-format](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format) and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). To automatically format your files on save, add to your user settings (on macOS, press `Cmd+Shift+P`, type "Preferences: Open User Settings (JSON)")
116+
```json
117+
"editor.formatOnSave": true,
118+
"[cpp]": {
119+
"editor.defaultFormatter": "xaver.clang-format"
120+
},
121+
"[json]": {
122+
"editor.defaultFormatter": "esbenp.prettier-vscode",
123+
},
124+
"[jsonc]": {
125+
"editor.defaultFormatter": "esbenp.prettier-vscode",
126+
},
127+
```
128+
129+
## Vim
130+
Install [clang-format](https://github.com/rhysd/vim-clang-format) and [Prettier](https://github.com/prettier/vim-prettier).
131+
132+
## Other editors
133+
See [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and [Prettier](https://prettier.io/docs/editors.html).
134+
120135
# Documentation {#documentation}
121136

122137
We use [Doxygen](https://doxygen.nl) to automatically build an html documentation

0 commit comments

Comments
 (0)