Imported Upstream version 1.41.0
[platform/upstream/nghttp2.git] / doc / sources / contribute.rst
1 Contribution Guidelines
2 =======================
3
4 [This text was composed based on 1.2. License section of curl/libcurl
5 project.]
6
7 When contributing with code, you agree to put your changes and new
8 code under the same license nghttp2 is already using unless stated and
9 agreed otherwise.
10
11 When changing existing source code, you do not alter the copyright of
12 the original file(s).  The copyright will still be owned by the
13 original creator(s) or those who have been assigned copyright by the
14 original author(s).
15
16 By submitting a patch to the nghttp2 project, you are assumed to have
17 the right to the code and to be allowed by your employer or whatever
18 to hand over that patch/code to us.  We will credit you for your
19 changes as far as possible, to give credit but also to keep a trace
20 back to who made what changes.  Please always provide us with your
21 full real name when contributing!
22
23 Coding style
24 ------------
25
26 We use clang-format to format source code consistently.  The
27 clang-format configuration file .clang-format is located at the root
28 directory.  Since clang-format produces slightly different results
29 between versions, we currently use clang-format-9.
30
31 To detect any violation to the coding style, we recommend to setup git
32 pre-commit hook to check coding style of the changes you introduced.
33 The pre-commit file is located at the root directory.  Copy it under
34 .git/hooks and make sure that it is executable.  The pre-commit script
35 uses clang-format-diff.py to detect any style errors.  If it is not in
36 your PATH or it exists under different name (e.g., clang-format-diff-9
37 in debian), either add it to PATH variable or add git option
38 ``clangformatdiff.binary`` to point to the script.
39
40 For emacs users, integrating clang-format to emacs is very easy.
41 clang-format.el should come with clang distribution.  If it is not
42 found, download it from `here
43 <https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format.el>`_.
44 And add these lines to your .emacs file:
45
46 .. code-block:: lisp
47
48     ;; From
49     ;; https://code.google.com/p/chromium/wiki/Emacs#Use_Google's_C++_style!
50     (load "/<path/to>/clang-format.el")
51     (add-hook 'c-mode-common-hook
52          (function (lambda () (local-set-key (kbd "TAB")
53                                              'clang-format-region))))
54
55 You can find other editor integration in
56 http://clang.llvm.org/docs/ClangFormat.html.