Commit a54d6538f990f3a0dfe38173e2172cacd4fea6a6
1 parent
430c2b2c
Initial document layout for coding conventions.
Showing
7 changed files
with
128 additions
and
6 deletions
doc/source/_templates/index.html
| ... | ... | @@ -52,6 +52,7 @@ and next steps, and advance with the coding of the software. {%endtrans%}</p> |
| 52 | 52 | <li><a class="smalllink" href="{{ pathto("reference_manual/index") }}">{%trans%}Reference Manual{%endtrans%}</a></li> |
| 53 | 53 | <li><a class="smalllink" href="{{ pathto("faq") }}">{%trans%}Frequently asked questions{%endtrans%}</a></li> |
| 54 | 54 | <li><a class="smalllink" href="{{ pathto("issues") }}">{%trans%}Known issues{%endtrans%}</a></li> |
| 55 | +<li><a class="smalllink" href="{{ pathto("coding/index") }}">{%trans%}Coding conventions{%endtrans%}</a></li> | |
| 55 | 56 | <li><a class="smalllink" href="doxygen/index.html">{%trans%}Source code documentation (Doxygen){%endtrans%}</a></li> |
| 56 | 57 | </ul> |
| 57 | 58 | ... | ... |
doc/source/coding/cpp.rst
0 → 100644
| 1 | +C++ coding rules | |
| 2 | +================ | |
| 3 | + | |
| 4 | +All ctools C++ code must be compatible with ISO standard C++98. Do not | |
| 5 | +use C++11 features (see `here <http://en.wikipedia.org/wiki/C%2B%2B#Standardization>`__ | |
| 6 | +if you don't know what C++98 and C++11 is and note that C++03 is just | |
| 7 | +a minor correction of C++98). | |
| 8 | + | |
| 9 | +The reason for this restriction is that C++ compilers / standard libraries | |
| 10 | +such as `gcc <http://gcc.gnu.org>`_ / `libstdc++ <http://gcc.gnu.org/libstdc++/>`_ | |
| 11 | +or `clang <http://clang.llvm.org>`_ / `libc++ <http://libcxx.llvm.org>`_ | |
| 12 | +only finished implementing C++11 in 2013 and using C++11 features in | |
| 13 | +ctools would make it impossible to use the code on many systems. | |
| 14 | + | |
| 15 | + | |
| 16 | +Code lay-out | |
| 17 | +^^^^^^^^^^^^ | |
| 18 | + | |
| 19 | +String quotes | |
| 20 | +^^^^^^^^^^^^^ | |
| 21 | + | |
| 22 | +Whitespace in Expressions and Statements | |
| 23 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 24 | + | |
| 25 | +Comments | |
| 26 | +^^^^^^^^ | |
| 27 | + | |
| 28 | +Naming Conventions | |
| 29 | +^^^^^^^^^^^^^^^^^^ | |
| 30 | + | |
| 31 | +Programming Recommendations | |
| 32 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 33 | + | ... | ... |
doc/source/coding/general.rst
0 → 100644
| 1 | +General rules | |
| 2 | +============= | |
| 3 | + | |
| 4 | +Code lay-out | |
| 5 | +^^^^^^^^^^^^ | |
| 6 | + | |
| 7 | +- Use 4 spaces per indentation level | |
| 8 | + | |
| 9 | +- Do not use tabs | |
| 10 | + | |
| 11 | +- Do not exceed a line length of 80 characters (a few more characters | |
| 12 | + are acceptable in exceptional cases) | |
| 13 | + | |
| 14 | +- Put a blank line at the end of each file (this is required by some | |
| 15 | + compilers) | |
| 16 | + | |
| 17 | +- Align successive similar lines on common elements. Here an example | |
| 18 | + illustrating the alignment on the ``=`` symbol: | |
| 19 | + | |
| 20 | + .. code-block:: python | |
| 21 | + | |
| 22 | + max = par.max | |
| 23 | + prompt = par.prompt | |
| 24 | + sum += par.sum | |
| 25 | + | |
| 26 | +- Each function or method must terminate with a single return statement | |
| 27 | + that is placed at the end | ... | ... |
doc/source/coding/index.rst
0 → 100644
doc/source/coding/introduction.rst
0 → 100644
| 1 | +Introduction | |
| 2 | +============ | |
| 3 | + | |
| 4 | +This document gives the coding conventions for the ctools software | |
| 5 | +package. | |
| 6 | + | |
| 7 | +The coding conventions shall be followed by all developers who intend | |
| 8 | +to commit code to ctools. | |
| 9 | + | |
| 10 | +Respecting uniform and coherent coding conventions is crucial for | |
| 11 | +software development. They improve code readability, ease code | |
| 12 | +development and maintenance, ensure code portability, and provide | |
| 13 | +standards for the user interface. | |
| 14 | + | |
| 15 | +The coding conventions for ctools were inspired by a large survey of | |
| 16 | +existing C++ coding rules and the Style Guide for Python Code (PEP-0008), | |
| 17 | +combined with the experience of the leading code developers. Obviously, | |
| 18 | +there is no single best way to code in Python and C++, and the adopted | |
| 19 | +conventions may not meet your style of coding. The ctools coding rules | |
| 20 | +should nevertheless be respected, and if violated, you should have good | |
| 21 | +reasons for that. | ... | ... |
doc/source/coding/python.rst
0 → 100644
| 1 | +Python coding rules | |
| 2 | +=================== | |
| 3 | + | |
| 4 | +The Python coding rules have been inspired from the Style Guide for | |
| 5 | +Python Code `PEP 0008 <http://www.python.org/dev/peps/pep-0008/>`_. | |
| 6 | +You can check whether you code complies to these rules using the | |
| 7 | +`pep8 tool <https://github.com/jcrocholl/pep8>`_ that you should run | |
| 8 | +on your Python code before committing. | |
| 9 | + | |
| 10 | +All ctools code must be compatible with Python 2.3 or higher, and | |
| 11 | +Python 3.0 and higher. No Python modules that are not available in | |
| 12 | +these Python version shall be used. | |
| 13 | + | |
| 14 | + | |
| 15 | +Code lay-out | |
| 16 | +^^^^^^^^^^^^ | |
| 17 | + | |
| 18 | +String quotes | |
| 19 | +^^^^^^^^^^^^^ | |
| 20 | + | |
| 21 | +Whitespace in Expressions and Statements | |
| 22 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 23 | + | |
| 24 | +Comments | |
| 25 | +^^^^^^^^ | |
| 26 | + | |
| 27 | +Naming Conventions | |
| 28 | +^^^^^^^^^^^^^^^^^^ | |
| 29 | + | |
| 30 | +Programming Recommendations | |
| 31 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 32 | + | |
| 33 | + | ... | ... |
doc/source/contents.rst
| 1 | -.. ctools documentation master file, created by | |
| 2 | - sphinx-quickstart on Sat Apr 13 16:41:07 2013. | |
| 3 | - You can adapt this file completely to your liking, but it should at least | |
| 4 | - contain the root `toctree` directive. | |
| 5 | - | |
| 6 | 1 | Documentation |
| 7 | 2 | ============= |
| 8 | 3 | |
| ... | ... | @@ -16,4 +11,5 @@ Documentation |
| 16 | 11 | faq |
| 17 | 12 | issues |
| 18 | 13 | develop |
| 19 | - help | |
| 20 | 14 | \ No newline at end of file |
| 15 | + coding/index | |
| 16 | + help | ... | ... |