Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 030ef66

Browse filesBrowse files
committed
Add link to numpydoc
1 parent 4e8d02b commit 030ef66
Copy full SHA for 030ef66

File tree

Expand file treeCollapse file tree

1 file changed

+60
-73
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+60
-73
lines changed

‎doc/devel/documenting_mpl.rst

Copy file name to clipboardExpand all lines: doc/devel/documenting_mpl.rst
+60-73Lines changed: 60 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,47 @@ calls in `matplotlib.patches`.
177177
Formatting
178178
==========
179179

180+
All new or edited docstrings should conform to the numpydoc guidelines. These
181+
split the docstring down into a number of sections - see
182+
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt for more
183+
details and a guide to the way docstrings should be written. A simple example
184+
docstring looks like:
185+
.. code-block:: python
186+
187+
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
188+
label='', **kwargs):
189+
"""
190+
Plot horizontal lines at each `y` from `xmin` to `xmax`.
191+
192+
Parameters
193+
----------
194+
y : scalar or sequence of scalar
195+
y-indexes where to plot the lines.
196+
197+
xmin, xmax : scalar or 1D array_like
198+
Respective beginning and end of each line. If scalars are
199+
provided, all lines will have same length.
200+
201+
colors : array_like of colors, optional, default: 'k'
202+
203+
linestyles : ['solid' | 'dashed' | 'dashdot' | 'dotted'], optional
204+
205+
label : string, optional, default: ''
206+
207+
Returns
208+
-------
209+
lines : `~matplotlib.collections.LineCollection`
210+
211+
Other Parameters
212+
----------------
213+
**kwargs : `~matplotlib.collections.LineCollection` properties.
214+
215+
See also
216+
--------
217+
vlines : vertical lines
218+
axhline: horizontal line across the axes
219+
"""
220+
180221
The Sphinx website contains plenty of documentation_ concerning ReST markup and
181222
working with Sphinx in general. Here are a few additional things to keep in mind:
182223

@@ -185,9 +226,11 @@ working with Sphinx in general. Here are a few additional things to keep in mind
185226
markup`_. For example, when referring to external files, the
186227
``:file:`` directive should be used.
187228

188-
* Function arguments and keywords should be referred to using the
189-
``*emphasis*`` role. This will keep Matplotlib's documentation consistent
190-
with Python's documentation:
229+
Function arguments
230+
------------------
231+
Function arguments and keywords should be referred to using the
232+
``*emphasis*`` role. This will keep Matplotlib's documentation consistent
233+
with Python's documentation:
191234

192235
.. code-block:: rst
193236
@@ -206,8 +249,10 @@ working with Sphinx in general. Here are a few additional things to keep in mind
206249
207250
Please do not describe ``argument`` like this.
208251
209-
* Mathematical expressions can be rendered as png images in html, and in the
210-
usual way by LaTeX. For example,
252+
Maths
253+
-----
254+
Mathematical expressions can be rendered as png images in html, and in the
255+
usual way by LaTeX. For example,
211256

212257
.. code-block:: rst
213258
@@ -223,8 +268,10 @@ working with Sphinx in general. Here are a few additional things to keep in mind
223268
224269
yields :math:`\int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}}`.
225270

226-
* Interactive IPython sessions can be illustrated in the documentation using
227-
the following directive:
271+
IPython code
272+
-----------
273+
Interactive IPython sessions can be illustrated in the documentation using
274+
the following directive:
228275

229276
.. code-block:: rst
230277
@@ -238,84 +285,24 @@ working with Sphinx in general. Here are a few additional things to keep in mind
238285
239286
In [69]: lines = plot([1,2,3])
240287
241-
* Footnotes [#]_ can be added using ``[#]_``, followed later by:
288+
Footnotes
289+
---------
290+
Footnotes [#]_ can be added using ``[#]_``, followed later by:
242291

243292
.. code-block:: rst
244293
245294
.. rubric:: Footnotes
246295
247296
.. [#]
248297
249-
which yields
298+
which yields
250299

251300
.. rubric:: Footnotes
252301

253302
.. [#] For example.
254303
255-
* Use the *note* and *warning* directives, sparingly, to draw attention to
256-
important comments:
257-
258-
.. code-block:: rst
259-
260-
.. note::
261-
Here is a note.
262-
263-
.. warning::
264-
Here is a warning.
265-
266-
yields:
267-
268-
.. note::
269-
Here is a note.
270-
271-
.. warning::
272-
Here is a warning.
273-
274-
* Use the *deprecated* directive when appropriate:
275-
276-
.. code-block:: rst
277-
278-
.. deprecated:: 0.98
279-
This feature is obsolete, use something else.
280-
281-
yields:
282-
283-
.. deprecated:: 0.98
284-
This feature is obsolete, use something else.
285-
286-
* Use the *versionadded* and *versionchanged* directives, which have similar
287-
syntax to the *deprecated* role:
288-
289-
.. code-block:: rst
290-
291-
.. versionadded:: 0.98
292-
The transforms have been completely revamped.
293-
294-
.. versionadded:: 0.98
295-
The transforms have been completely revamped.
296-
297-
* Use the *seealso* directive, for example:
298-
299-
.. code-block:: rst
300-
301-
.. seealso::
302-
303-
Using ReST :ref:`emacs-helpers`:
304-
One example
305-
306-
A bit about :ref:`referring-to-mpl-docs`:
307-
One more
308-
309-
yields:
310-
311-
.. seealso::
312-
313-
Using ResT :ref:`emacs-helpers`:
314-
One example
315-
316-
A bit about :ref:`referring-to-mpl-docs`:
317-
One more
318-
304+
Other
305+
-----
319306
* Please keep the :ref:`glossary` in mind when writing documentation. You can
320307
create a references to a term in the glossary with the ``:term:`` role.
321308

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.