Jump to: navigation, search

Information about the group Translation of the wiki page Policies/Kdelibs Coding Style.
Policies/Kdelibs Coding StyleCurrent message text
...ding Style/Page display title/ruPolicies/Kdelibs Coding Style
...licies/Kdelibs Coding Style/1/ruThis document describes the recommended coding style for kdelibs. Nobody is forced to use this style, but to have consistent formatting of the source code files it is recommended to make use of it.
...licies/Kdelibs Coding Style/2/ru'''In short: Kdelibs coding style follows the [ Qt 4 coding style], with one main difference: using curly braces even when the body of a conditional statement contains only one line.'''
...licies/Kdelibs Coding Style/3/ru== Отступы ==
* Не используем табуляцию
* Один отступ — 4 пробела
...licies/Kdelibs Coding Style/4/ru== Объявление переменных ==
* Каждая переменная должна быть объявлена на отдельной строке,
* Каждое новое слово в имени переменной должно начинаться с заглавной буквы (так называемый стиль camelCase),
* Избегаем использования аббревиатур,
* Используем говорящие имена для переменных. Не используем слишком короткие имена, за исключением:
** Однобуквенных имён переменных, которые используются как счётчики или временные переменные, когда назначение этих переменных очевидно,
* Имена переменных и функций начинаются со строчной буквы
...licies/Kdelibs Coding Style/5/ruПример:
...licies/Kdelibs Coding Style/6/ru// неправильно
...licies/Kdelibs Coding Style/7/ru// правильно
...licies/Kdelibs Coding Style/8/ru== Whitespace ==
* Use blank lines to group statements
* Use only one empty line
* Use one space after each keyword
* For pointers or references, use a single space before '*' or '&', but not after
* No space after a cast
...licies/Kdelibs Coding Style/9/ruПример:
...icies/Kdelibs Coding Style/10/ru// неправильно
...icies/Kdelibs Coding Style/11/ru// правильно
...icies/Kdelibs Coding Style/12/ru== Braces ==
As a base rule, the left curly brace goes on the same line as the start of the statement.
...icies/Kdelibs Coding Style/13/ruПример:
...icies/Kdelibs Coding Style/14/ru// неправильно
...icies/Kdelibs Coding Style/15/ru// правильно
...icies/Kdelibs Coding Style/16/ruException: Function implementations, class, struct and namespace declarations always have the opening brace on the start of a line.
...icies/Kdelibs Coding Style/17/ruПример:
...icies/Kdelibs Coding Style/18/ruUse curly braces even when the body of a conditional statement contains only one line.
...icies/Kdelibs Coding Style/19/ruПример:
...icies/Kdelibs Coding Style/20/ru// неправильно
...icies/Kdelibs Coding Style/21/ru// правильно
...icies/Kdelibs Coding Style/22/ru== Switch statements ==
Case labels are on the same column as the switch
...icies/Kdelibs Coding Style/23/ruПример:
...icies/Kdelibs Coding Style/24/ru== Line breaks ==
Try to keep lines shorter than 100 characters, inserting line breaks as necessary.
...icies/Kdelibs Coding Style/25/ru== Qt Includes ==
* If you add #includes for Qt classes, use both the module and class name.  This allows library code to be used by applications without excessive compiler include paths.
...icies/Kdelibs Coding Style/26/ruПример:
...icies/Kdelibs Coding Style/27/ru// неправильно
...icies/Kdelibs Coding Style/28/ru// правильно
...icies/Kdelibs Coding Style/29/ru== Artistic Style (astyle) automatic code formatting ==
You can use [ astyle] (>=1.23) to format code or to test if you have followed this document. Run the following command:
...icies/Kdelibs Coding Style/30/ruWith astyle (>=2.01) you need to run the following command:
...icies/Kdelibs Coding Style/31/ruYou can find a shell script to run this command in:
...icies/Kdelibs Coding Style/40/ru* [ kde-dev-scripts/astyle-kdelibs] (POSIX)
* [ kde-dev-scripts/astyle-kdelibs.bat] (Windows)
...icies/Kdelibs Coding Style/32/ru== Emacs and Vim scripts ==
The [ kde-dev-scripts] directory in the kdesdk module contains, among other useful things, some useful additions to the Emacs and Vim text editors that make it easier to edit KDE code with them.
=== Emacs ===
The [ kde-emacs] directory contains a set of key bindings, macros and general useful code. It is compatible with both GNU Emacs and XEmacs.
...icies/Kdelibs Coding Style/33/ruTo start using kde-emacs, add the following to your .emacs:
...icies/Kdelibs Coding Style/34/ruMany settings can be changed by editing the "kde-emacs" group via <tt>M-x customize-group</tt>.
...icies/Kdelibs Coding Style/35/ruFor more information, including what the key bindings are and what additional settings you could add to your .emacs, please check <tt>kde-emacs.el</tt> itself.
...icies/Kdelibs Coding Style/36/ru=== Vim ===
You can find a vim script in [ kde-devel-vim.vim] that helps you to keep the coding style correct. In addition to defaulting to the kdelibs coding style it will automatically use the correct style for Solid and kdepim code. If you want to add rules for other projects feel free to add them in the SetCodingStyle function.
...icies/Kdelibs Coding Style/37/ruTo use the script, include it in your {{path|~/.vimrc}} like this:
...icies/Kdelibs Coding Style/38/ruDocument started by Urs Wolfer. Some parts of this document have been adopted from the Qt Coding Style document posted by Zack Rusin on kde-core-devel.
...icies/Kdelibs Coding Style/39/ru[[Category:Policies]] [[Category:C++]]
NavigationShowing 41 messages.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal