From 1cf1f2e6de8d1a4fe7c1febacb3fc5046b70a54b Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Thu, 15 Oct 2020 11:37:01 +0200 Subject: [PATCH] [web] Added page on code formatting. --- .../development-workflows/code-format.md | 36 +++++++++++++++++++ .../development-workflows/code-reviews.md | 2 +- .../continuous-integration.md | 2 +- .../development-workflows/development-ides.md | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 web/content/docs/devguide/development-workflows/code-format.md diff --git a/web/content/docs/devguide/development-workflows/code-format.md b/web/content/docs/devguide/development-workflows/code-format.md new file mode 100644 index 00000000000..ac4de63afed --- /dev/null +++ b/web/content/docs/devguide/development-workflows/code-format.md @@ -0,0 +1,36 @@ ++++ +date = "2018-02-26T11:00:13+01:00" +title = "Code style and formatting" +author = "Lars Bilke" +weight = 1012 + +[menu] + [menu.devguide] + parent = "development-workflows" ++++ + +We aim for a consistent and readable coding style. You do not need to worry about styling if you use the right tools we present in the following. + +## C++ + +Use [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html). Can be added to be automatically run on save in your editor / IDE: + +- [Vim](https://github.com/rhysd/vim-clang-format) +- [Visual Studio](https://devblogs.microsoft.com/cppblog/clangformat-support-in-visual-studio-2017-15-7-preview-1/) +- [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format) + +Current style is defined in [.clang-format](https://gitlab.opengeosys.org/ogs/ogs/-/blob/master/.clang-format). + +## Python + +Use [`black`](https://black.readthedocs.io/en/stable/). Can be added to be automatically run on save in your editor / IDE: + +- [Vim](https://black.readthedocs.io/en/stable/editor_integration.html#vim) +- [PyCharm](https://black.readthedocs.io/en/stable/editor_integration.html#pycharm-intellij-idea) +- [Visual Studio Code](https://code.visualstudio.com/docs/python/editing#_formatting) + +`black` is also run by our `pre-commit`-hooks. To run manually: + +```bash +pre-commit run black --all-files +``` diff --git a/web/content/docs/devguide/development-workflows/code-reviews.md b/web/content/docs/devguide/development-workflows/code-reviews.md index fe4a05ba2d5..50d1f450ea9 100644 --- a/web/content/docs/devguide/development-workflows/code-reviews.md +++ b/web/content/docs/devguide/development-workflows/code-reviews.md @@ -2,7 +2,7 @@ date = "2018-02-26T11:00:13+01:00" title = "Code Reviews" author = "Lars Bilke" -weight = 1012 +weight = 1014 [menu] [menu.devguide] diff --git a/web/content/docs/devguide/development-workflows/continuous-integration.md b/web/content/docs/devguide/development-workflows/continuous-integration.md index 23685ef2f79..c632c6b7afb 100644 --- a/web/content/docs/devguide/development-workflows/continuous-integration.md +++ b/web/content/docs/devguide/development-workflows/continuous-integration.md @@ -2,7 +2,7 @@ date = "2018-02-26T11:00:13+01:00" title = "Continuous Integration" author = "Lars Bilke" -weight = 1013 +weight = 1016 [menu] [menu.devguide] diff --git a/web/content/docs/devguide/development-workflows/development-ides.md b/web/content/docs/devguide/development-workflows/development-ides.md index f9538c68be3..e3cd06bb94c 100644 --- a/web/content/docs/devguide/development-workflows/development-ides.md +++ b/web/content/docs/devguide/development-workflows/development-ides.md @@ -2,7 +2,7 @@ date = "2018-02-26T11:00:13+01:00" title = "Development IDEs" author = "Marc Walther" -weight = 1014 +weight = 1013 [menu] [menu.devguide] -- GitLab