@@ -175,8 +175,9 @@ respective types.
175175 y
176176 Description of parameter `y` (with type not specified).
177177
178- Enclose variables in single backticks. The colon must be preceded
179- by a space, or omitted if the type is absent.
178+ The colon must be preceded by a space, or omitted if the type is absent.
179+ When referring to a parameter anywhere within the docstring, enclose its
180+ name in single backticks.
180181
181182For the parameter types, be as precise as possible. Below are a
182183few examples of parameters and their types.
@@ -224,11 +225,11 @@ description, they can be combined::
224225 Input arrays, description of `x1`, `x2`.
225226
226227When documenting variable length positional, or keyword arguments, leave the
227- leading star(s) in front of the name::
228+ leading star(s) in front of the name and do not specify a type ::
228229
229- *args : tuple
230+ *args
230231 Additional arguments should be passed as keyword arguments
231- **kwargs : dict, optional
232+ **kwargs
232233 Extra arguments to `metric`: refer to each metric documentation for a
233234 list of all possible arguments.
234235
@@ -549,23 +550,29 @@ not explicitly imported, `.. plot::` can be used directly if
549550Documenting classes
550551-------------------
551552
553+ .. _classdoc :
554+
552555Class docstring
553556```````````````
554557Use the same sections as outlined above (all except :ref: `Returns <returns >`
555558are applicable). The constructor (``__init__ ``) should also be documented
556559here, the :ref: `Parameters <params >` section of the docstring details the
557- constructor's parameters.
560+ constructor's parameters. While repetition is unnecessary, a docstring for
561+ the class constructor (``__init__ ``) can, optionally, be added to provide
562+ detailed initialization documentation.
558563
559564An **Attributes ** section, located below the :ref: `Parameters <params >`
560565section, may be used to describe non-method attributes of the class::
561566
562567 Attributes
563568 ----------
564569 x : float
565- The X coordinate .
570+ Description of attribute `x` .
566571 y : float
567- The Y coordinate .
572+ Description of attribute `y` .
568573
574+ When referring to an attribute anywhere within the docstring, enclose its
575+ name in single backticks.
569576Attributes that are properties and have their own docstrings can be
570577simply listed by name::
571578
@@ -606,6 +613,8 @@ becomes useful to have an additional **Methods** section:
606613
607614 """
608615
616+ When referring to a method anywhere within the docstring, enclose its
617+ name in single backticks.
609618If it is necessary to explain a private method (use with care!), it can
610619be referred to in the :ref: `Extended Summary <extended_summary >` or the
611620:ref: `Notes <notes >` section.
@@ -690,11 +699,11 @@ belong in docstrings.
690699Other points to keep in mind
691700----------------------------
692701* Equations : as discussed in the :ref: `Notes <notes >` section above, LaTeX
693- formatting should be kept to a minimum. Often it's possible to show equations as
694- Python code or pseudo-code instead, which is much more readable in a
695- terminal. For inline display use double backticks (like `` y = np.sin(x) ``).
696- For display with blank lines above and below, use a double colon and indent
697- the code, like::
702+ formatting should be kept to a minimum. Often it's possible to show
703+ equations as Python code or pseudo-code instead, which is much more readable
704+ in a terminal. For inline display of code, use double backticks
705+ like `` ``y = np.sin(x)`` ``. For display with blank lines above and below,
706+ use a double colon and indent the code, like::
698707
699708 end of previous sentence::
700709
@@ -717,9 +726,13 @@ Other points to keep in mind
717726 (i.e. scalar types, sequence types), those arguments can be documented
718727 with type `array_like `.
719728
720- * Links : If you need to include hyperlinks in your docstring, note that
721- some docstring sections are not parsed as standard reST, and in these
722- sections, numpydoc may become confused by hyperlink targets such as::
729+ * Links : Depending on project settings, hyperlinks to documentation of
730+ modules, classes, functions, methods, and attributes should automatically
731+ be created if a recognized name is included within single backticks (e.g.
732+ ```numpy` `` renders as :any: `numpy `). If you need to include other
733+ hyperlinks, note that some docstring sections are not parsed as standard
734+ reST, and in these sections, numpydoc may become confused by hyperlink
735+ targets such as::
723736
724737 .. _Example: http://www.example.com
725738
@@ -729,17 +742,31 @@ Other points to keep in mind
729742
730743 `Example <http://www.example.com>`_
731744
732-
733745Common reST concepts
734746--------------------
735747For paragraphs, indentation is significant and indicates indentation in the
736748output. New paragraphs are marked with a blank line.
737749
738- Use ``*italics* ``, ``**bold** `` and ````monospace`` `` if needed in any
739- explanations
740- (but not for variable names and doctest code or multi-line code).
741- Variable, module, function, and class names should be written between
742- single back-ticks (```numpy` ``).
750+ Use ``*italics* ``, ``**bold** `` if needed in any explanations.
751+
752+ Use of backticks in reST is a common point of confusion because it is different
753+ from markdown. In most flavors of markdown, single backticks are used for
754+ monospaced font; in reST, *double * backticks are for ``monospaced font ``,
755+ whereas the behavior of single backticks is defined by the default role. This
756+ leads to the following style recommendations:
757+
758+ - Module, class, function, method, and attribute names should render as
759+ hyperlinks in monospaced font (e.g. :any: `numpy `); depending on project
760+ settings, this may be accomplished simply be enclosing them in single
761+ backticks. If the hyperlink does not render as intended, explicitly
762+ include the appropriate role and/or namespace.
763+ - This guide continues to recommended that parameter names be enclosed within
764+ single backticks. Currently, this may cause parameter names to render
765+ improperly and cause warnings, but numpydoc will soon release a feature
766+ that causes them to render as monospaced hyperlinks to the parameter
767+ documentation.
768+ - All other text that is intended to render in ``monospaced `` font should be
769+ enclosed within ````double backticks`` ``.
743770
744771A more extensive example of reST markup can be found in `this example
745772document <http://docutils.sourceforge.net/docs/user/rst/demo.txt> `_;
0 commit comments