Warning, /graphics/kipi-plugins/HACKING is written in an unsupported language. File is not indexed.
0001 This file's purpose is to guide contributors and developers to help on the 0002 this project. 0003 0004 ======================================================================== 0005 10 golden rules for starting with open source 0006 ======================================================================== 0007 0008 Before to contribute, please take a look to this link: 0009 0010 http://schlitt.info/applications/blog/index.php?/archives/541-10-golden-rules-for-starting-with-open-source.html 0011 0012 ======================================================================== 0013 Source code formatting: 0014 ======================================================================== 0015 0016 Adhere to this style guide strictly while adding new code or 0017 working on existing code. 0018 0019 ------------------------------------------------------------------------- 0020 * Indentation length 0021 ------------------------------------------------------------------------- 0022 0023 Indent with 4 spaces exactly. 0024 0025 for eg: 0026 0027 void function() 0028 { 0029 ....int a; // 4 spaces from beginning 0030 ....for (int i=0; i<10; i++) // 4 spaces from beginning 0031 ....{ // 4 spaces from beginning 0032 ........a = i; // 4 spaces from previous indent block 0033 0034 Emacs by default will indent to 4 spaces 0035 vim users add this to you .vimrc 0036 set tabstop=4 0037 0038 ------------------------------------------------------------------------- 0039 * Tabs vs Spaces 0040 ------------------------------------------------------------------------- 0041 0042 Absolutely no tabs. Use a sensible editor which will convert tabs to spaces. 0043 This will reduce unnecessary changes in your cvs commits. 0044 0045 Emacs by default will convert tab to spaces. 0046 For vim users, add this to your .vimrc 0047 set expandtab 0048 0049 ------------------------------------------------------------------------- 0050 * Line length 0051 ------------------------------------------------------------------------- 0052 0053 Line length should never exceed 80 chars (unless really necessary - these 0054 cases are rare). Having long lines greatly reduces readability of code. 0055 0056 ------------------------------------------------------------------------- 0057 * Bracketing 0058 ------------------------------------------------------------------------- 0059 0060 In almost all cases, {} brackets should start on a newline and should be 0061 aligned with previous line (follow the indentation spaces). for eg. 0062 0063 class A 0064 { //new line 0065 ... 0066 0067 for (int i=0; i<10; i++) 0068 { //new line 0069 0070 if (a == foobar) 0071 { //new line 0072 ... 0073 } 0074 else 0075 { // new line 0076 .. 0077 } 0078 0079 ------------------------------------------------------------------------- 0080 * Positioning of Access modifiers 0081 ------------------------------------------------------------------------- 0082 0083 public, private, protected, public slots, ... should be aligned to the 0084 beginning of the line with no margin 0085 0086 class A 0087 { 0088 public: // aligned to left 0089 ... 0090 private Q_SLOTS: // aligned to left 0091 0092 0093 Follow a consistent order in defining these attributes. The recommended 0094 order is public, protected (functions), private (functions), 0095 signals, public slots, protected slots, private slots, private (variables) 0096 0097 ======================================================================== 0098 Class, file and Variable names: 0099 ======================================================================== 0100 0101 ------------------------------------------------------------------------- 0102 * Class and filenames 0103 ------------------------------------------------------------------------- 0104 0105 - filenames should always be in lower-case 0106 - class names should match the filenames. Capitalize the first letter and 0107 other letters logically to improve readability 0108 0109 ------------------------------------------------------------------------- 0110 * Protected Member variables 0111 ------------------------------------------------------------------------- 0112 0113 - protected member variable names should always be of the form m_varName. 0114 - Capitalize logically so that it becomes easy to read it. Do not capitalize 0115 the first letter after _ (Use m_varName not m_VarName) 0116 - variable names should be indicative of their functionality and also of 0117 the type they belong too if they are instances of qt widgets. 0118 for eg, QCheckBox* m_autoRotateCheckBox; 0119 0120 ------------------------------------------------------------------------- 0121 * Non-Member variables 0122 ------------------------------------------------------------------------- 0123 0124 - non-member variables should follow the same naming convention as the member 0125 variables, except for the leading m_ 0126 0127 ------------------------------------------------------------------------- 0128 * Private Member variables 0129 ------------------------------------------------------------------------- 0130 0131 - private member variables must be stored in a d private container to reduce 0132 compilation time and improve binary compatibility between components. 0133 See more information how to use a 'd' private class at this url: 0134 0135 http://developer.kde.org/policies/librarypolicy.html 0136 0137 ======================================================================== 0138 Comments and Whitespace 0139 ======================================================================== 0140 0141 Use whitespaces liberally to improve readability. Add blank lines between logical 0142 sections of the code. 0143 0144 Comment as much as possible. Position comments at the beginning of the 0145 section/line you want to comment, NEVER at the end of the line 0146 0147 // put your comments here 0148 a = (b == foobar) ? 1 : -1; 0149 0150 a = (b == foobar) ? 1 : -1; // you are asking for trouble by putting comments here 0151 0152 0153 ======================================================================== 0154 Header files 0155 ======================================================================== 0156 0157 - Add copyright to top of every file. Use the same header than others source code. 0158 - Double inclusion protection defines are all upper case letters and are 0159 composed of the classname and a H suffix separated by underscore 0160 0161 #ifndef ANOTHERNICECLASS_H 0162 #define ANOTHERNICECLASS_H 0163 0164 class AnotherNiceClass 0165 { 0166 ... 0167 } 0168 0169 #endif 0170 0171 - Use forward declarations as much as possible. 0172 0173 class QFileInfo; 0174 0175 class A 0176 { 0177 ....QFileInfo* m_fileInfo; 0178 0179 ======================================================================== 0180 General recommendations 0181 ======================================================================== 0182 0183 Please take a look into KDE contrib page tips before to write code/patches for 0184 this project : http://techbase.kde.org/Contribute 0185 0186 Use the same .cpp/.h header than the rest of the project. 0187 0188 Use a decent editor which does auto-indentation/syntax-highlighting for you. 0189 I personally use Emacs (Renchi) or Kdevelop (Gilles). 0190 There are excellent initializer scripts in the kdesdk 0191 package for xemacs and vim which can substantially increase your productivity. 0192 0193 Just to give a taste of what i can do with emacs (and kdesdk): 0194 0195 * automatically insert copyright (and ifdefs) in new files. 0196 * insertion of class function definitions for declared class 0197 functions in header with one keystroke 0198 * switch between header and declaration files with one keystroke 0199 * go to corresponding definition/declaration with one keystroke 0200 * tab completion of variable/function names already declared. 0201 0202 ======================================================================== 0203 GDB Backtrace 0204 ======================================================================== 0205 0206 If you found a context to crash, you can provide a backtrace using GDB debugger. 0207 All need to be compiled with all debug info else the backtrace will not suitable. 0208 There is a configure option for that: 0209 0210 # make -f Makefile.cvs 0211 # ./configure --enable-debug=full 0212 # make 0213 # su 0214 # make install. 0215 0216 To make a backtrace with GDB use following command: 0217 0218 # gdb 0219 > run 0220 > ... 0221 > _crash here_ 0222 > ... 0223 > bt 0224 > _the backtrace is here_ 0225 > quit 0226 0227 Post this backtrace at the right place (KDE Bugzilla or developement mailing list) for investigations by developers. 0228 0229 For windows users take a look on this tutorial: 0230 0231 http://techbase.kde.org/Development/Tutorials/Debugging/Debugging_on_MS_Windows 0232 0233 ======================================================================== 0234 Memory leak 0235 ======================================================================== 0236 0237 To check any memory leak problem, valgrind is your friend (http://valgrind.org) 0238 Try this command line to use with valgrind : 0239 0240 valgrind --tool=memcheck --leak-check=full --error-limit=no 0241 0242 ======================================================================== 0243 Profiling with cachegrind 0244 ======================================================================== 0245 0246 Valgrind also includes a tool to find out in which parts of your code time is spent. 0247 0248 valgrind --tool=callgrind 0249 0250 Profiling can be disabled at startup to limit the output to the code you are interested in. 0251 Start with 0252 0253 valgrind --tool=callgrind --instr-atstart=no 0254 0255 and prepare the situation you want to profile. Then, in another console, start profiling with 0256 "callgrind_control -i on" and, after the situation has passed, request a profile dump with 0257 "callgrind_control -d". 0258 The resulting callgrind.out files need to be viewed with the kcachegrind program, e.g.: 0259 0260 kcachegrind callgrind.out.16693.1 0261 0262 ================================================================================= 0263 API Documentation Validation, User Documentation Validation, Source Code Checking 0264 ================================================================================= 0265 0266 The following site check on a daily basis for the a.m. errors: 0267 www.englishbreakfastnetwork.org/krazy/ 0268 0269 It can be very useful, in particular before major releases. 0270 Don't trust it blindly! Sometimes they propose too advanced modifications that are no compatible with the prevailant include files. 0271 0272 ======================================================================== 0273 Usability issues 0274 ======================================================================== 0275 0276 OpenUsability project has define default menu structure and keyboard shortcuts: 0277 0278 http://wiki.openusability.org/guidelines/index.php/Appendices:Keyboard_Shortcuts 0279 0280 ======================================================================== 0281 Generate API documentation 0282 ======================================================================== 0283 0284 To generate API documentation, you need to install: 0285 0286 - Doxygen program (http://www.doxygen.org). 0287 - Dot program (http://www.graphviz.org) 0288 0289 Go to 'project' sub-folder and just run doxygen binary program. A new subfolder 0290 named 'api' will be create. Warning, this can take a while. 0291 0292 ======================================================================== 0293 Speed up the code-compile-test cycle 0294 ======================================================================== 0295 0296 Assuming you have setup your environment in ~/.bashrc as is suggested for KDE4 development, 0297 you can add something like this to your ~/.bashrc: 0298 0299 function _start { 0300 LD_LIBRARY_PATH=${KDE_BUILD}/extragear/graphics/lib:${LD_LIBRARY_PATH} ${KDE_BUILD}/extragear/graphics/// 0301 } 0302 0303 function _start_gdb { 0304 LD_LIBRARY_PATH=${KDE_BUILD}/extragear/graphics/lib:${LD_LIBRARY_PATH} gdb ${KDE_BUILD}/extragear/graphics/// 0305 } 0306 0307 This allows you to run after compiling without the need of a "make install", even 0308 if you changed code in the libraries.