Commit 2b81bfad872d3c1f621bb01fea14ba93a6ed43ae

Authored by Jürgen Knödlseder
2 parents 1f4ac933 a8093c0a

Merge branch '1742-coding-conventions' into integration

# Conflicts:
#	cscripts/cscaldb.py
cscripts/cscaldb.py
1 1 #! /usr/bin/env python
2 2 # ==========================================================================
3   -# This script dumps all available calibrations into the console.
  3 +# Show the content of the ctools calibration database
4 4 #
5 5 # Copyright (C) 2014-2016 Juergen Knoedlseder
6 6 #
... ... @@ -32,19 +32,30 @@ class cscaldb(ctools.cscript):
32 32 """
33 33 Shows the content of the ctools calibration database.
34 34  
35   - If the "debug" parameter is set to "yes" the calibration database
36   - is shown in the console, otherwise the content is only written
37   - into the "cscaldb.log" log file.
  35 + The ``cscaldb`` script writes the content of the calibration database
  36 + into the ``cscaldb.log`` log file. If the ``debug`` parameter is set
  37 + to ``yes`` the calibration database is also logged in the console.
38 38 """
39 39  
40 40 # Constructor
41 41 def __init__(self, *argv):
42 42 """
43 43 Constructor.
  44 +
  45 + Parameters
  46 + ----------
  47 + argv : list of str
  48 + List of IRAF command line parameter strings of the form
  49 + ``parameter=3``.
  50 +
  51 + Raises
  52 + ------
  53 + TypeError
  54 + An invalid number of command line arguments was provided.
44 55 """
45 56 # Set name
46   - self._name = "cscaldb"
47   - self._version = "1.1.0"
  57 + self._name = 'cscaldb'
  58 + self._version = '1.1.0'
48 59  
49 60 # Initialise application by calling the appropriate class
50 61 # constructor.
... ... @@ -55,33 +66,26 @@ class cscaldb(ctools.cscript):
55 66  
56 67  
57 68 # Private methods
  69 + #
  70 + # Query all user parameters
58 71 def _get_parameters(self):
59   - """
60   - Get parameters from parfile.
61   - """
  72 +
62 73 # Write input parameters into logger
63 74 if self._logTerse():
64 75 self._log_parameters()
65   - self._log("\n")
  76 + self._log('\n')
66 77  
67 78 # Return
68 79 return
69 80  
  81 + # Extract mission names from a calibration database
70 82 def _get_missions(self, caldb):
71   - """
72   - Extract mission names from a calibration database.
73   -
74   - Args:
75   - caldb: Calibration database.
76 83  
77   - Returns:
78   - A list of mission names.
79   - """
80 84 # Initialise mission list
81 85 missions = []
82 86  
83 87 # Extract missions
84   - paths = glob.glob(caldb.rootdir()+"/data/*")
  88 + paths = glob.glob(caldb.rootdir()+'/data/*')
85 89 paths.sort()
86 90 for path in paths:
87 91 missions.append(os.path.basename(path))
... ... @@ -92,22 +96,14 @@ class cscaldb(ctools.cscript):
92 96 # Return missions
93 97 return missions
94 98  
  99 + # Extract instrument names from a calibration database
95 100 def _get_instruments(self, caldb, mission):
96   - """
97   - Extract instrument names from a calibration database.
98   -
99   - Args:
100   - caldb: Calibration database.
101   - mission: Mission name.
102 101  
103   - Returns:
104   - A list of instrument names.
105   - """
106 102 # Initialise instrument list
107 103 instruments = []
108 104  
109 105 # Extract instruments
110   - paths = glob.glob(caldb.rootdir()+"/data/"+mission+"/*")
  106 + paths = glob.glob(caldb.rootdir()+'/data/'+mission+'/*')
111 107 paths.sort()
112 108 for path in paths:
113 109 instruments.append(os.path.basename(path))
... ... @@ -118,17 +114,10 @@ class cscaldb(ctools.cscript):
118 114 # Return instruments
119 115 return instruments
120 116  
  117 + # Extract response names from a calibrations FITS table and return them
  118 + # in form of a list
121 119 def _get_response_names(self, calibrations):
122   - """
123   - Extract response names from a calibrations FITS table and return
124   - them in form of a list.
125   -
126   - Args:
127   - calibrations: FITS table containing the calibrations.
128 120  
129   - Returns:
130   - A list of response names.
131   - """
132 121 # Initialise response name list
133 122 names = []
134 123  
... ... @@ -139,9 +128,9 @@ class cscaldb(ctools.cscript):
139 128 for row in range(nrows):
140 129 for col in range(ncols):
141 130 cal = calibrations.string(row, col)
142   - istart = cal.find("NAME(")
  131 + istart = cal.find('NAME(')
143 132 if istart != -1:
144   - istop = cal.find(")")
  133 + istop = cal.find(')')
145 134 name = cal[5:istop]
146 135 if names.count(name) == 0:
147 136 names.append(name)
... ... @@ -175,13 +164,13 @@ class cscaldb(ctools.cscript):
175 164 for mission in missions:
176 165  
177 166 # Skip all non-CTA instruments
178   - if mission != "cta":
  167 + if mission != 'cta':
179 168 continue
180 169  
181 170 # Write mission into logger
182 171 if self._logTerse():
183   - self._log("\n")
184   - self._log.header1("Mission: "+mission)
  172 + self._log('\n')
  173 + self._log.header1('Mission: '+mission)
185 174  
186 175 # Extract instruments
187 176 instruments = self._get_instruments(caldb, mission)
... ... @@ -191,15 +180,15 @@ class cscaldb(ctools.cscript):
191 180  
192 181 # Write mission into logger
193 182 if self._logTerse():
194   - self._log.header3("Response functions in database \""+
195   - instrument+"\"")
  183 + self._log.header3('Response functions in database "'+
  184 + instrument+'"')
196 185  
197 186 # Open calibration index file and retrieve calibrations
198   - filename = "/data/"+mission+"/"+instrument+"/caldb.indx"
  187 + filename = '/data/'+mission+'/'+instrument+'/caldb.indx'
199 188 cifname = caldb.rootdir() + filename
200 189 fits = gammalib.GFits(cifname)
201   - cif = fits["CIF"]
202   - caltable = cif["CAL_CBD"]
  190 + cif = fits['CIF']
  191 + caltable = cif['CAL_CBD']
203 192  
204 193 # Extract response names
205 194 names = self._get_response_names(caltable)
... ... @@ -207,8 +196,18 @@ class cscaldb(ctools.cscript):
207 196 # Print response name
208 197 if self._logTerse():
209 198 for name in names:
210   - self._log(name+"\n")
211   - self._log("\n")
  199 + self._log(name+'\n')
  200 + self._log('\n')
  201 +
  202 + # Return
  203 + return
  204 +
  205 + def execute(self):
  206 + """
  207 + Execute the script.
  208 + """
  209 + # Run the script
  210 + self.run()
212 211  
213 212 # Return
214 213 return
... ...
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 +Dependencies
  17 +^^^^^^^^^^^^
  18 +
  19 +- All ctools code must only depend on the ISO standard C++98 libraries and the
  20 + GammaLib library.
  21 +
  22 +
  23 +Code lay-out
  24 +^^^^^^^^^^^^
  25 +
  26 +- Each function or method starts with a curly bracket in the line following
  27 + the function or method name. The return type is in the same line as the
  28 + function or method name, e.g.:
  29 +
  30 + .. code-block:: cpp
  31 +
  32 + int function(void)
  33 + {
  34 + int i = 0;
  35 + ...
  36 + return i;
  37 + }
  38 +
  39 +- Code blocks should be encompassed in curly brackets, even if the block
  40 + consists only of a single line.
  41 +
  42 +- The opening curly bracket of a block starts in the same line as the
  43 + related statement, e.g.:
  44 +
  45 + .. code-block:: cpp
  46 +
  47 + for (int i = 0; i < 10; ++i) {
  48 + sum += i;
  49 + }
  50 +
  51 +- Separate code elements by spaces, e.g.:
  52 +
  53 + .. code-block:: cpp
  54 +
  55 + Yes: int i = 0;
  56 +
  57 + No: int i=0;
  58 +
  59 +- Align successive class definition on the member function name, e.g.:
  60 +
  61 + .. code-block:: cpp
  62 +
  63 + void log10GeV(const double& eng);
  64 + void log10TeV(const double& eng);
  65 + std::string print(void) const;
  66 +
  67 +
  68 +.. To be written:
  69 +
  70 + String quotes
  71 + ^^^^^^^^^^^^^
  72 +
  73 + Whitespace in Expressions and Statements
  74 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  75 +
  76 + Comments
  77 + ^^^^^^^^
  78 +
  79 +
  80 +Naming Conventions
  81 +^^^^^^^^^^^^^^^^^^
  82 +
  83 +- Prefix data members with ``m_``, e.g.:
  84 +
  85 + .. code-block:: cpp
  86 +
  87 + m_num
  88 + m_response
  89 + m_grid_length
  90 + m_axis_dir_qual
  91 +
  92 +
  93 +Programming Recommendations
  94 +^^^^^^^^^^^^^^^^^^^^^^^^^^^
  95 +
  96 +- Each class shall have the protected methods ``init_members``,
  97 + ``copy_members``, and ``free_members`` to handle initialisation,
  98 + copying, and eventually freeing of allocated memory for data members:
  99 +
  100 + .. code-block:: cpp
  101 +
  102 + // Initialise data members
  103 + void Class::init_members(void)
  104 + {
  105 + m_elements = 10;
  106 + m_array = new double[m_elements];
  107 + for (int i = 0; i < m_elements; ++i) {
  108 + m_array[i] = 0.0;
  109 + }
  110 + ...
  111 + }
  112 +
  113 + // Copy data members
  114 + void Class::copy_members(const &Class class)
  115 + {
  116 + m_elements = class.m_elements;
  117 + m_array = new double[m_elements];
  118 + for (int i = 0; i < m_elements; ++i) {
  119 + m_array[i] = class.m_array[i];
  120 + }
  121 + ...
  122 + }
  123 +
  124 + // Free data members
  125 + void Class::free_members(void)
  126 + {
  127 + if (m_array != NULL) delete [] m_array;
  128 + ...
  129 + }
  130 +
  131 +- Each class shall have at least a void constructor, a copy constructor,
  132 + a destructor and an assignment operator. Additional constructors and
  133 + operators can be implemented as required. The following example shows
  134 + the basic implementation for these 4 methods. Due to the usage of the
  135 + ``init_members``, ``copy_members``, and ``free_members``, most classes
  136 + will have exactly this kind of syntax:
  137 +
  138 + .. code-block:: cpp
  139 +
  140 + // Void constructor
  141 + ctnice::ctnice(void)
  142 + {
  143 + init_members();
  144 + return;
  145 + }
  146 +
  147 + // Copy constructor
  148 + ctnice::ctnice(const ctnice& nice)
  149 + {
  150 + init_members();
  151 + copy_members(nice);
  152 + return;
  153 + }
  154 +
  155 + // Destructor
  156 + ctnice::~ctnice(void)
  157 + {
  158 + free_members();
  159 + return;
  160 + }
  161 +
  162 + // Assignment operator
  163 + ctnice& ctnice::operator=(const ctnice& nice)
  164 + {
  165 + if (this != &nice) {
  166 + free_members();
  167 + init_members();
  168 + copy_members(nice);
  169 + }
  170 + return *this;
  171 + }
  172 +
  173 +- Do not use macros.
  174 +
  175 +- Do not use ``#define`` directives for the declaration of constants. Use
  176 + ``const`` instead.
  177 +
  178 +- Do not use ``std::strncpy``, ``std::memcpy`` or similar as these functions
  179 + are corrupted on some systems.
  180 +
  181 +- If possible, pass arguments by reference.
  182 +
  183 +- Output arguments should be passed as pointers.
  184 +
  185 +- Use C++ (``std::string``) instead of C-style (``char*``) strings.
  186 +
  187 +- Use C++ casts instead of C-style casts.
  188 +
  189 +- Avoid using templates.
  190 +
  191 +- Do not use an integer for a floating point argument (i.e. write 10.0
  192 + instead of 10). Some older compilers give an error when using
  193 + integers in some floating point functions, such as log10().
  194 +
  195 +- Where possible (and appropriate), use ``std::vector`` containers instead
  196 + of allocating memory. In other words: avoid direct memory allocation with
  197 + ``new``.
  198 +
  199 +- Use the ``std::`` namespace prefix where possible; write for example
  200 +
  201 + .. code-block:: cpp
  202 +
  203 + std::sin(angle);
  204 + std::cos(angle);
  205 +
  206 + You may not believe it, but droping the ``std::`` may on some systems
  207 + lead to considerably slower code for trigonometric functions!
  208 +
  209 +- Use ``explicit`` for constructors with single arguments to prevent
  210 + unintended type conversions. The only exception to this rule is the
  211 + copy constructor or type conversion constructors.
  212 +
  213 +- Specify ``void`` for function or method definitions without arguments,
  214 + e.g.:
  215 +
  216 + .. code-block:: cpp
  217 +
  218 + Yes: void function(void)
  219 +
  220 + No: void function()
  221 +
  222 +- Use pre-incrementation in loops (pre-incrementation is faster than
  223 + post-incrementation), e.g.:
  224 +
  225 + .. code-block:: cpp
  226 +
  227 + for (int i = 0; i < 10; ++i) {
  228 + sum += i;
  229 + }
... ...
doc/source/coding/general.rst 0 → 100644
  1 +General rules
  2 +=============
  3 +
  4 +The general rules apply to Python and C++ code.
  5 +
  6 +
  7 +Code lay-out
  8 +^^^^^^^^^^^^
  9 +
  10 +- Use 4 spaces per indentation level.
  11 +
  12 +- Do not use tabs.
  13 +
  14 +- Do not exceed a line length of 80 characters (a few more characters
  15 + are acceptable in exceptional cases).
  16 +
  17 +- Put a blank line at the end of each file (this is required by some
  18 + compilers).
  19 +
  20 +- Align successive similar lines on common elements. Here an example
  21 + illustrating the alignment on the ``=`` symbol:
  22 +
  23 + .. code-block:: python
  24 +
  25 + max = par.max
  26 + prompt = par.prompt
  27 + sum += par.sum
  28 +
  29 +- Each function or method must terminate with a single return statement
  30 + that is placed at the end of the function or method.
  31 +
  32 +- Always use English words (class names, method and function names,
  33 + comments, documentation, etc.).
... ...
doc/source/coding/index.rst 0 → 100644
  1 +Coding and Design Conventions
  2 +=============================
  3 +
  4 +.. toctree::
  5 + :maxdepth: 2
  6 +
  7 + introduction
  8 + general
  9 + python
  10 + cpp
  11 +
... ...
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 8 <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 +
  11 +Dependencies
  12 +^^^^^^^^^^^^
  13 +
  14 +- All ctools code must be compatible with Python 2.3 or higher, and
  15 + Python 3.0 and higher.
  16 +
  17 +- ctools should be importable with no dependencies other than the
  18 + `Python Standard Library <https://docs.python.org/release/2.3/lib/lib.html>`_.
  19 +
  20 +
  21 +Code lay-out
  22 +^^^^^^^^^^^^
  23 +
  24 +- Put imports on separate lines, e.g.:
  25 +
  26 + .. code-block:: python
  27 +
  28 + Yes: import os
  29 + import sys
  30 +
  31 + No: import sys, os
  32 +
  33 +- Put imports at the top of the file, just after any module comments
  34 + and docstrings, and before module globals and constants.
  35 +
  36 +- Use absolute imports, e.g.:
  37 +
  38 + .. code-block:: python
  39 +
  40 + import mypkg.sibling
  41 + from mypkg import sibling
  42 + from mypkg.sibling import example
  43 +
  44 +
  45 +String quotes
  46 +^^^^^^^^^^^^^
  47 +
  48 +- Use single quotes for strings so that the string can contain double
  49 + quote characters which avoid backslashes, e.g.:
  50 +
  51 + .. code-block:: python
  52 +
  53 + Yes: print('The Parameter "infile" is missing')
  54 +
  55 + No: print("The Parameter \"infile\" is missing")
  56 +
  57 +
  58 +Whitespace in Expressions and Statements
  59 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  60 +
  61 +- Do not put extraneous whitespace immediately inside parentheses,
  62 + brackets or braces, e.g.:
  63 +
  64 + .. code-block:: python
  65 +
  66 + Yes: spam(ham[1], {eggs: 2})
  67 +
  68 + No: spam( ham[ 1 ], { eggs: 2 } )
  69 +
  70 +- Do not put extraneous whitespace immediately before a comma, semicolon,
  71 + or colon, e.g.:
  72 +
  73 + .. code-block:: python
  74 +
  75 + Yes: if x == 4: print x, y; x, y = y, x
  76 +
  77 + No: if x == 4 : print x , y ; x , y = y , x
  78 +
  79 +- Do not put extraneous whitespace immediately before the open parenthesis
  80 + that starts the argument list of a function call, e.g.:
  81 +
  82 + .. code-block:: python
  83 +
  84 + Yes: spam(1)
  85 +
  86 + No: spam (1)
  87 +
  88 +- Do not put extraneous whitespace immediately before the open parenthesis
  89 + that starts an indexing or slicing, e.g.:
  90 +
  91 + .. code-block:: python
  92 +
  93 + Yes: dct['key'] = lst[index]
  94 +
  95 + No: dct ['key'] = lst [index]
  96 +
  97 +
  98 +Comments
  99 +^^^^^^^^
  100 +
  101 +- Always make a priority of keeping the comments up-to-date when the code
  102 + changes! Comments that contradict the code are worse than no comments.
  103 +
  104 +- Comments should be complete sentences. If a comment is a phrase or
  105 + sentence, its first word should be capitalized, unless it is an identifier
  106 + that begins with a lower case letter (never alter the case of identifiers!).
  107 +
  108 +- If a comment is short, the period at the end can be omitted. Block
  109 + comments generally consist of one or more paragraphs built out of complete
  110 + sentences, and each sentence should end in a period.
  111 +
  112 +- Follow `Strunk & White <https://en.wikipedia.org/wiki/The_Elements_of_Style>`_.
  113 + Make every word tell. Omit needless words. Use active voice. Use parallel
  114 + construction on parallel concepts.
  115 +
  116 +- Block comments generally apply to some (or all) code that follows them,
  117 + and are indented to the same level as that code. Each line of a block
  118 + comment starts with a # and a single space (unless it is indented text
  119 + inside the comment). Paragraphs inside a block comment are separated by
  120 + a line containing a single #, e.g.:
  121 +
  122 + .. code-block:: python
  123 +
  124 + # Compute the energy boundaries.
  125 + #
  126 + # The energy boundaries are computed from the lower and upper energy
  127 + # thresholds that are stored in the effective area components of the
  128 + # response functions.
  129 + ebounds = gammalib.GEbounds()
  130 + ...
  131 +
  132 +- Use inline comments sparingly. Use meaningful variable names instead.
  133 + But sometimes, inline comments can be useful, e.g.:
  134 +
  135 + .. code-block:: python
  136 +
  137 + x = x + 1 # Compensate for border
  138 +
  139 +
  140 +User Documentation
  141 +^^^^^^^^^^^^^^^^^^
  142 +
  143 +- Write documentation strings (a.k.a. docstrings) for all modules, functions,
  144 + classes, and public methods.
  145 + Read `PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ to learn
  146 + about the general Python conventions for writing good documentation
  147 + strings.
  148 +
  149 +- The docstring conventions follow the common standards developed by
  150 + `NumPy <http://www.numpy.org>`_ and `SciPy <http://www.scipy.org>`_
  151 + and that are also adopted by
  152 + `AstroPy <http://docs.astropy.org/en/stable/development/docrules.html>`_.
  153 + This docstring standard uses
  154 + `re-structured text (reST) <http://docutils.sourceforge.net/rst.html>`_
  155 + syntax and is rendered using
  156 + `Sphinx <http://www.sphinx-doc.org/en/stable/>`_.
  157 + While a rich set of markup is available, limit yourself to a very basic
  158 + subset, in order to provide docstrings that are easy to read on text-only
  159 + terminals.
  160 +
  161 +- Format each docstring as follows (sections can be omitted if they do
  162 + not apply, for example you do not need to specify that nothing is
  163 + returned):
  164 +
  165 + .. code-block:: python
  166 +
  167 + """
  168 + Extract calibrations for a mission from a calibration database.
  169 +
  170 + .. note:: Deprecated in ctools 1.1
  171 + The `instrument` string will be removed in ctools 2.0 because
  172 + it's in fact not used by the method.
  173 +
  174 + The method extract calibration names from a calibration database by
  175 + scanning all index files.
  176 +
  177 + Parameters
  178 + ----------
  179 + caldb : `~gammalib.GCaldb`
  180 + Calibration database.
  181 + instrument : str
  182 + Instrument names.
  183 + debug : bool, optional
  184 + Turn on debugging if needed.
  185 +
  186 + Returns
  187 + -------
  188 + missions : list of str
  189 + List of mission names.
  190 +
  191 + Raises
  192 + ------
  193 + ValueError
  194 + If `instrument` is not recognised as among the ones implemented.
  195 +
  196 + See Also
  197 + --------
  198 + irfs : Return all irfs for a given calibration.
  199 +
  200 + Notes
  201 + -----
  202 + See https//my.site.edu for documentation. The method computes
  203 +
  204 + .. math:: X(e^{j\omega } ) = x(n)e^{ - j\omega n}
  205 +
  206 + where the value of :math:`\omega` is larger than 5.
  207 +
  208 + References
  209 + ----------
  210 + .. [1] J. Public, "The art of programming", Computers & Geosciences,
  211 + vol. 22, pp. 585-588, 1996.
  212 +
  213 + Examples
  214 + --------
  215 + >>> calibrations(caldb, "CTA", debug=False)
  216 + ['Prod2', 'Prod3']
  217 + """
  218 +
  219 +- For the parameter types, be as precise as possible. Below are a few examples
  220 + of parameters and their types.
  221 +
  222 + .. code-block:: python
  223 +
  224 + Parameters
  225 + ----------
  226 + filename : str
  227 + copy : bool
  228 + dtype : data-type
  229 + iterable : iterable object
  230 + shape : int or tuple of int
  231 + files : list of str
  232 +
  233 +- For classes, use the same sections as outlined above. The constructor
  234 + (``__init__``) should also be documented here, the Parameters section of
  235 + the docstring details the constructors parameters. An Attributes section,
  236 + located below the Parameters section, may be used to describe class
  237 + variables:
  238 +
  239 + .. code-block:: python
  240 +
  241 + Attributes
  242 + ----------
  243 + x : float
  244 + The X coordinate.
  245 + y : float
  246 + The Y coordinate.
  247 +
  248 +- In general, it is not necessary to list class methods. In some cases,
  249 + however, a class may have many methods, and then it becomes useful to have
  250 + an additional ``Methods`` section:
  251 +
  252 + .. code-block:: python
  253 +
  254 + Methods
  255 + -------
  256 + read(filename)
  257 + Read a table from a file
  258 + sort(column, order='ascending')
  259 + Sort by `column`
  260 +
  261 +
  262 +Naming Conventions
  263 +^^^^^^^^^^^^^^^^^^
  264 +
  265 +- Use short lowercase abbreviate words for cscripts, e.g.:
  266 +
  267 + .. code-block:: python
  268 +
  269 + cspull
  270 + csspec
  271 + cslightcrv
  272 +
  273 +- Use ``lower_case_with_underscores`` for functions, methods, and variables.
  274 +
  275 +- Use ``self`` for the first argument to instance methods, e.g.:
  276 +
  277 + .. code-block:: python
  278 +
  279 + def __init__(self, name):
  280 + self._name = name
  281 +
  282 +- Use one leading underscore for private methods and instance variables,
  283 + e.g.:
  284 +
  285 + .. code-block:: python
  286 +
  287 + self._get_energy_boundaries()
  288 + self._has_ebounds = True
  289 +
  290 +- Always decide whether a class's methods and instance variables
  291 + (collectively: "attributes") should be public or private. If in doubt,
  292 + choose private; it's easier to make it public later than to make
  293 + a public attribute private.
  294 +
  295 +
  296 +.. To be written:
  297 +
  298 + Programming Recommendations
  299 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
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
... ...