Skip to content

Commit 2c76aad

Browse files
committed
Only use ~ in ref to class to hide prefix
1 parent 1bfe28b commit 2c76aad

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

pandas/guide/_sources/pandas_docstring.rst.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,18 @@ backticks. It is considered inline code:
107107
- The name of a parameter
108108
- Python code, a module, function, built-in, type, literal... (e.g. ``os``,
109109
``list``, ``numpy.abs``, ``datetime.date``, ``True``)
110-
- A pandas class (in the form ``:class:`~pandas.Series```)
110+
- A pandas class (in the form ``:class:`pandas.Series```)
111111
- A pandas method (in the form ``:meth:`pandas.Series.sum```)
112112
- A pandas function (in the form ``:func:`pandas.to_datetime```)
113113

114+
.. note::
115+
To display only the last component of the linked class, method or
116+
function, prefix it with ``~``. For example, ``:class:`~pandas.Series```
117+
will link to ``pandas.Series`` but only display the last part, ``Series``
118+
as the link text. See `Sphinx cross-referencing syntax
119+
<http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-syntax>`_
120+
for details.
121+
114122
**Good:**
115123

116124
.. code-block:: python
@@ -259,7 +267,7 @@ After the title, each parameter in the signature must be documented, including
259267
The parameters are defined by their name, followed by a space, a colon, another
260268
space, and the type (or types). Note that the space between the name and the
261269
colon is important. Types are not defined for `*args` and `**kwargs`, but must
262-
be defined for all other parameters. After the parameter definition, it is
270+
be defined for all other parameters. After the parameter definition, it is
263271
required to have a line with the parameter description, which is indented, and
264272
can have multiple lines. The description must start with a capital letter, and
265273
finish with a dot.

pandas/guide/pandas_docstring.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,18 @@ <h2>About docstrings and standards<a class="headerlink" href="#about-docstrings-
120120
<li>The name of a parameter</li>
121121
<li>Python code, a module, function, built-in, type, literal… (e.g. <code class="docutils literal notranslate"><span class="pre">os</span></code>,
122122
<code class="docutils literal notranslate"><span class="pre">list</span></code>, <code class="docutils literal notranslate"><span class="pre">numpy.abs</span></code>, <code class="docutils literal notranslate"><span class="pre">datetime.date</span></code>, <code class="docutils literal notranslate"><span class="pre">True</span></code>)</li>
123-
<li>A pandas class (in the form <code class="docutils literal notranslate"><span class="pre">:class:`~pandas.Series`</span></code>)</li>
123+
<li>A pandas class (in the form <code class="docutils literal notranslate"><span class="pre">:class:`pandas.Series`</span></code>)</li>
124124
<li>A pandas method (in the form <code class="docutils literal notranslate"><span class="pre">:meth:`pandas.Series.sum`</span></code>)</li>
125125
<li>A pandas function (in the form <code class="docutils literal notranslate"><span class="pre">:func:`pandas.to_datetime`</span></code>)</li>
126126
</ul>
127+
<div class="admonition note">
128+
<p class="first admonition-title">Note</p>
129+
<p class="last">To display only the last component of the linked class, method or
130+
function, prefix it with <code class="docutils literal notranslate"><span class="pre">~</span></code>. For example, <code class="docutils literal notranslate"><span class="pre">:class:`~pandas.Series`</span></code>
131+
will link to <code class="docutils literal notranslate"><span class="pre">pandas.Series</span></code> but only display the last part, <code class="docutils literal notranslate"><span class="pre">Series</span></code>
132+
as the link text. See <a class="reference external" href="http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-syntax">Sphinx cross-referencing syntax</a>
133+
for details.</p>
134+
</div>
127135
<p><strong>Good:</strong></p>
128136
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">add_values</span><span class="p">(</span><span class="n">arr</span><span class="p">):</span>
129137
<span class="sd">&quot;&quot;&quot;</span>

0 commit comments

Comments
 (0)