##// END OF EJS Templates
Add slightly more detailed guidelines about docstrings....
Fernando Perez -
Show More
@@ -4,6 +4,14 b''
4 Documenting IPython
4 Documenting IPython
5 =====================
5 =====================
6
6
7 When contributing code to IPython, you should strive for clarity and
8 consistency, without falling prey to a style straitjacket. Basically,
9 'document everything, try to be consistent, do what makes sense.'
10
11 By and large we follow existing Python practices in major projects like Python
12 itself or NumPy, this document provides some additional detail for IPython.
13
14
7 Standalone documentation
15 Standalone documentation
8 ========================
16 ========================
9
17
@@ -83,9 +91,35 b' The NumPy documentation guidelines [NumPyDocGuide]_ contain detailed'
83 information on this standard, and for a quick overview, the NumPy example
91 information on this standard, and for a quick overview, the NumPy example
84 docstring [NumPyExampleDocstring]_ is a useful read.
92 docstring [NumPyExampleDocstring]_ is a useful read.
85
93
86 In the past IPython used epydoc so currently many docstrings still use epydoc
94
87 conventions. We will update them as we go, but all new code should be
95 For user-facing APIs, we try to be fairly strict about following the above
88 documented using the NumPy standard.
96 standards (even though they mean more verbose and detailed docstrings).
97 Wherever you can reasonably expect people to do introspection with::
98
99 In [1]: some_function?
100
101 the docstring should follow the NumPy style and be fairly detailed.
102
103 For purely internal methods that are only likely to be read by others extending
104 IPython itself we are a bit more relaxed, especially for small/short methods
105 and functions whose intent is reasonably obvious. We still expect docstrings
106 to be written, but they can be simpler. For very short functions with a
107 single-line docstring you can use something like::
108
109 def add(a, b):
110 """The sum of two numbers.
111 """
112 code
113
114 and for longer multiline strings::
115
116 def add(a, b):
117 """The sum of two numbers.
118
119 Here is the rest of the docs.
120 """
121 code
122
89
123
90 Here are two additional PEPs of interest regarding documentation of code.
124 Here are two additional PEPs of interest regarding documentation of code.
91 While both of these were rejected, the ideas therein form much of the basis of
125 While both of these were rejected, the ideas therein form much of the basis of
@@ -94,6 +128,11 b' docutils (the machinery to process reStructuredText):'
94 * `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_
128 * `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_
95 * `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_
129 * `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_
96
130
131 .. note::
132
133 In the past IPython used epydoc so currently many docstrings still use
134 epydoc conventions. We will update them as we go, but all new code should
135 be documented using the NumPy standard.
97
136
98 .. [reStructuredText] reStructuredText. http://docutils.sourceforge.net/rst.html
137 .. [reStructuredText] reStructuredText. http://docutils.sourceforge.net/rst.html
99 .. [Sphinx] Sphinx. http://sphinx.pocoo.org/
138 .. [Sphinx] Sphinx. http://sphinx.pocoo.org/
General Comments 0
You need to be logged in to leave comments. Login now