From aded66ea1a8f384a2f39b6cd0463b8e990e2a8e0 Mon Sep 17 00:00:00 2001 From: Divyanshu Madan Date: Thu, 2 Apr 2020 14:53:51 +0530 Subject: [PATCH 1/4] add clang-format info --- doc/advanced/content/pcl_style_guide.rst | 65 +++++++----------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/doc/advanced/content/pcl_style_guide.rst b/doc/advanced/content/pcl_style_guide.rst index 325fe48a34e..f40de943c26 100644 --- a/doc/advanced/content/pcl_style_guide.rst +++ b/doc/advanced/content/pcl_style_guide.rst @@ -317,64 +317,35 @@ indentation level of the class body and members affected by these qualifiers are 2.6. Automatic code formatting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following set of rules can be automatically used by various different IDEs, -editors, etc. +We currently use clang-format as the tool for auto-formatting our C++ code. The style files which were previously distributed should now be considered deprecated. -2.6.1. Emacs -"""""""""""" +The style rules mentioned in this document are enforced via `PCL's .clang-format file +`_. -You can use the following `PCL C/C++ style file -`_, -download it to some known location and then: +For the integration of clang-format with various text editors and IDE's, refer `this +`_. -* open .emacs -* add the following before any C/C++ custom hooks +Details about the style options used can be found `here +`_. -:: +2.6.1. Script usage +""""""""""""""""""" - (load-file "/location/to/pcl-c-style.el") - (add-hook 'c-mode-common-hook 'pcl-set-c-style) +PCL also has a supporting `format script +`_, +which will run the clang-format on the whitelisted directories. -2.6.2. Uncrustify -""""""""""""""""" +Sample command line usage from the PCL source directory: -You can find a semi-finished config for `Uncrustify `_ `here -`_ +.. code-block:: shell -2.6.3 Eclipse -""""""""""""" + $ sh ./.dev/format.sh `which clang-format` ./ -| You can find a PCL code style file for Eclipse `on GitHub `_. -| To add the new formatting style go to: Windows > Preferences > C/C++ > Code Style > Formatter +You can also perform the same task by using make: -| To format portion of codes, select the code and press Ctrl + Shift + F. -| If you want to format the whole code in your project go to the tree and right click on the project: Source > Format. +.. code-block:: shell -Note that the Eclipse formatter style is configured to wrap all arguments in a function, feel free to re-arange the arguments if you feel the need; for example, -this improves readability: - -.. code-block:: cpp - - int - displayPoint (float x, float y, float z, - float r, float g, float b - ); - -This eclipse formatter fails to add a space before brackets when using PCL macros: - -.. code-block:: cpp - - PCL_ERROR("Text\n"); - -should be - -.. code-block:: cpp - - PCL_ERROR ("Text\n"); - -.. note:: - - This style sheet is not perfect, please mention errors on the user mailing list and feel free to patch! + $ make format 3. Structuring ============== From b295b105a401f11e4585cc63ee79f4701427efe0 Mon Sep 17 00:00:00 2001 From: Divyanshu Madan <43905892+divmadan@users.noreply.github.com> Date: Thu, 2 Apr 2020 15:25:44 +0530 Subject: [PATCH 2/4] sergio's suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Sérgio Agostinho --- doc/advanced/content/pcl_style_guide.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/advanced/content/pcl_style_guide.rst b/doc/advanced/content/pcl_style_guide.rst index f40de943c26..f119df683f2 100644 --- a/doc/advanced/content/pcl_style_guide.rst +++ b/doc/advanced/content/pcl_style_guide.rst @@ -322,7 +322,7 @@ We currently use clang-format as the tool for auto-formatting our C++ code. The The style rules mentioned in this document are enforced via `PCL's .clang-format file `_. -For the integration of clang-format with various text editors and IDE's, refer `this +For the integration of clang-format with various text editors and IDE's, refer to this `page `_. Details about the style options used can be found `here @@ -380,4 +380,3 @@ For the compute, filter, segment, etc. type methods the following rules apply: * The output arguments are preferably non-pointer type, regardless of data size. * The output arguments will always be passed by reference. - From 56b228fa83d01a4a49e6e98be9c414beca484406 Mon Sep 17 00:00:00 2001 From: Divyanshu Madan Date: Thu, 2 Apr 2020 15:43:04 +0530 Subject: [PATCH 3/4] remove script usage --- doc/advanced/content/pcl_style_guide.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/doc/advanced/content/pcl_style_guide.rst b/doc/advanced/content/pcl_style_guide.rst index f119df683f2..4976602d0ca 100644 --- a/doc/advanced/content/pcl_style_guide.rst +++ b/doc/advanced/content/pcl_style_guide.rst @@ -331,22 +331,15 @@ Details about the style options used can be found `here 2.6.1. Script usage """"""""""""""""""" -PCL also has a supporting `format script -`_, -which will run the clang-format on the whitelisted directories. +PCL also has a supporting format script which runs the clang-format on the whitelisted directories. -Sample command line usage from the PCL source directory: - -.. code-block:: shell - - $ sh ./.dev/format.sh `which clang-format` ./ - -You can also perform the same task by using make: +Command line usage: .. code-block:: shell $ make format + 3. Structuring ============== From 79ca0487f4f813cfba5abe350dee9902b23cd92f Mon Sep 17 00:00:00 2001 From: Divyanshu Madan Date: Thu, 2 Apr 2020 18:54:52 +0530 Subject: [PATCH 4/4] remove script, add build --- doc/advanced/content/pcl_style_guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/advanced/content/pcl_style_guide.rst b/doc/advanced/content/pcl_style_guide.rst index 4976602d0ca..33c7397f8cc 100644 --- a/doc/advanced/content/pcl_style_guide.rst +++ b/doc/advanced/content/pcl_style_guide.rst @@ -331,7 +331,7 @@ Details about the style options used can be found `here 2.6.1. Script usage """"""""""""""""""" -PCL also has a supporting format script which runs the clang-format on the whitelisted directories. +PCL also creates a build target 'format' to format the whitelisted directories using clang-format. Command line usage: