Skip to content

Commit

Permalink
docs(migrate): code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Sep 7, 2023
1 parent 49168a0 commit 24a9363
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
16 changes: 11 additions & 5 deletions doc/CODE_STYLE.md → ...content/docs/en/explanation/code_style.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Code Style Guide
---
title: C++ Code Style Guide
---

All of the C++ code in the project is styled, you should run any changes you make through astyle
before pushing a pull request.
Expand All @@ -8,22 +10,26 @@ they disagree and require annotation.

Blocks of code can be passed through astyle to ensure that their formatting is correct:

astyle --style=1tbs --attach-inlines --indent=spaces=4 --align-pointer=name --max-code-length=100 --break-after-logical --indent-classes --indent-preprocessor --indent-switches --indent-col1-comments --min-conditional-indent=0 --pad-oper --unpad-paren --pad-paren-in --add-brackets --convert-tabs
```sh
astyle --style=1tbs --attach-inlines --indent=spaces=4 --align-pointer=name --max-code-length=100 --break-after-logical --indent-classes --indent-preprocessor --indent-switches --indent-col1-comments --min-conditional-indent=0 --pad-oper --unpad-paren --pad-paren-in --add-brackets --convert-tabs
```

These options are mirrored in `.astylerc`, `doc/CODE_STYLE.txt` and
`msvc-full-features/AStyleExtension-Cataclysm-BN.cfg`

For example, from `vi`, set marks a and b around the block, then:

:'a,'b ! astyle --style=1tbs --attach-inlines --indent=spaces=4 --align-pointer=name --max-code-length=100 --break-after-logical --indent-classes --indent-preprocessor --indent-switches --indent-col1-comments --min-conditional-indent=0 --pad-oper --unpad-paren --pad-paren-in --add-brackets --convert-tabs
```sh
:'a,'b ! astyle --style=1tbs --attach-inlines --indent=spaces=4 --align-pointer=name --max-code-length=100 --break-after-logical --indent-classes --indent-preprocessor --indent-switches --indent-col1-comments --min-conditional-indent=0 --pad-oper --unpad-paren --pad-paren-in --add-brackets --convert-tabs
```

See [DEVELOPER_TOOLING.md](DEVELOPER_TOOLING.md) for other environments.
See [DEVELOPER_TOOLING.md](../../../../../../doc/DEVELOPER_TOOLING.md) for other environments.

## Code Example

Here's an example that illustrates the most common points of style:

```c++
```cpp
int foo( int arg1, int *arg2 )
{
if( arg1 < 5 ) {
Expand Down
17 changes: 15 additions & 2 deletions doc/JSON_STYLE.md → ...content/docs/en/explanation/json_style.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# JSON Style Guide
---
title: JSON Style Guide
sidebar:
badge:
text: Unstable
variant: caution
---

Like in `doc/CODE_STYLE.md`, the JSON styling policy is to update JSON as it is added or edited, and
:::caution

[A PR may change current JSON style](https://github.com/cataclysmbnteam/Cataclysm-BN/pull/3118) in favor of better tooling.

:::


Like in [C++ Code Style](./code_style), the JSON styling policy is to update JSON as it is added or edited, and
in relatively small chunks otherwise in order to prevent undue disruption to development.

We haven't been able to find a decent JSON styling tool, so we wrote our own. It lives in
Expand Down

0 comments on commit 24a9363

Please sign in to comment.