{"id":13649462,"url":"https://github.com/PickNikRobotics/roscpp_code_format","last_synced_at":"2025-04-22T14:31:41.265Z","repository":{"id":41581914,"uuid":"47465208","full_name":"PickNikRobotics/roscpp_code_format","owner":"PickNikRobotics","description":"Auto formatting script for ROS C++ Style Guidelines","archived":false,"fork":false,"pushed_at":"2024-10-01T13:03:59.000Z","size":16,"stargazers_count":232,"open_issues_count":2,"forks_count":84,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-10T12:24:32.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PickNikRobotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-05T17:21:01.000Z","updated_at":"2025-03-13T18:17:37.000Z","dependencies_parsed_at":"2022-09-15T16:20:21.753Z","dependency_job_id":null,"html_url":"https://github.com/PickNikRobotics/roscpp_code_format","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickNikRobotics%2Froscpp_code_format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickNikRobotics%2Froscpp_code_format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickNikRobotics%2Froscpp_code_format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickNikRobotics%2Froscpp_code_format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PickNikRobotics","download_url":"https://codeload.github.com/PickNikRobotics/roscpp_code_format/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250259010,"owners_count":21401022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T02:00:17.082Z","updated_at":"2025-04-22T14:31:36.249Z","avatar_url":"https://github.com/PickNikRobotics.png","language":null,"funding_links":[],"categories":["Development Tools"],"sub_categories":[],"readme":"# ROSCpp Code Format\n\nWhy waste your valuable development time formatting code manually when we are trying to build amazing robots?\n\nThe repo contains an auto formatting script for the [ROS C++ Style Guidelines](http://wiki.ros.org/CppStyleGuide).\n\nUpdated June 2020 to support Ubuntu 18.04 / ROS Melodic.\n\n## Setup\n\n * Install **clang_format**:\n\n   ``sudo apt-get install -y clang-format-3.9``\n\n * Then symlink or copy in the root of your catkin workspace the file ``.clang-format``, located in this repo. You can save this file from [this link](https://raw.githubusercontent.com/davetcoleman/roscpp_code_format/master/.clang-format). For example, place it on your computer here:\n\n   ``~/catkin_ws/.clang-format``\n\n * If you are interested in improving this configuration file, we recommend you checkout the git repo and symlink, e.g.:\n\n   ``ln -s ~/roscpp_code_format/.clang-format ~/catkin_ws/.clang-format``\n\n * Now any file inside your catkin workspace will be formatted with the ROS style guidelines described in this config file\n\n## Usage\n\nYou can run **clang_format** in several ways:\n\n### Command Line\n\nFormat single file:\n\n    clang-format-3.9 -i -style=file MY_ROS_NODE.cpp\n\nFormat entire directory recursively including subfolders:\n\n    find . -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs clang-format-3.9 -i -style=file $1\n\n### Emacs Editor Configuration\n\nIn your ``~/.emacs`` config file, add the following:\n\nFormat your source code if its in some directory such as the ``catkin_ws`` (feel free to change keywords catkin_ws):\n\n```\n(defun run-ros-clang-format ()\n  \"Runs clang-format on cpp,h files in catkin_ws/ and reverts buffer.\"\n  (interactive)\n  (and\n   (string-match \"/catkin_ws/.*\\\\.\\\\(h\\\\|cpp\\\\)$\" buffer-file-name)\n   (save-some-buffers 'no-confirm)\n   (shell-command (concat \"clang-format-3.9 -style=file -i \" buffer-file-name))\n   (message (concat \"Saved and ran clang-format on \" buffer-file-name))\n   (revert-buffer t t t)\n))\n```\n\nSet a keyboard shortcut to run, such as F12\n\n    (global-set-key [f12] 'run-ros-clang-format)\n\n### Atom Editor Configuration\n\nInstall the [clang-format](https://atom.io/packages/clang-format) package via the Atom package manager or ``apm install clang-format``.\n\nIn the package settings set ``clang-format-3.9`` as your executable and point 'Style' to your ``.clang_format`` file.\n\n### Usage with Qt\n\nTo set up Qt Creator to use this clang formatting follow the instructions [here](http://doc.qt.io/qtcreator/creator-beautifier.html).\n\nOn the **Clang Format** Panel change the **Clang Format command** to 'clang-format-4.0'. After this, choose **Use predefined style: File**, and then create a soft link on the root of your files workspace (where all your code is) pointing to this file and with the same name (.clang-format).\n\nIt is recomended to deactivate the **Enable auto format on file save** option and create a [keyboard shortcut](http://doc.qt.io/qtcreator/creator-keyboard-shortcuts.html)\n\n### Usage with Sublime\n\nInstallation Package Control in Sublime:\n\nhttps://packagecontrol.io/installation\n\nConfiguration Clang format in Sublime:\n\nhttps://github.com/rosshemsley/SublimeClangFormat/blob/master/README.md\n\n### Usage with Visual Studio Code\n\nInstall the [C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).\n\nPut the ``.clang-format`` file in your workspace.\n\nSelect ``Format Document`` in the right-click context menu, or use the shortcut ``Ctrl+Shift+I``.\n\nThis explanation and more [here](https://code.visualstudio.com/docs/languages/cpp#_code-formatting).\n\n## Exceptions to clang-format\n\nOccationally the auto formatting used by clang-format might not make sense e.g. for lists of items that are easier to read on separate lines. It can be overwritten with the commands:\n\n```\n// clang-format off\n... some untouched code\n// clang-format on\n```\n\nUse this sparingly though.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPickNikRobotics%2Froscpp_code_format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPickNikRobotics%2Froscpp_code_format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPickNikRobotics%2Froscpp_code_format/lists"}