Skip to content

Commit 8fd1afb

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

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

pandas/guide/_sources/pandas_docstring.rst.txt

+9-2
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@ 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: To display only the last component of the linked class, method or
115+
function, prefix it with ``~``. For example, ``:class:`~pandas.Series``` will
116+
link to ``pandas.Series`` but only display the last part, ``Series`` as the
117+
link text. See `Sphinx cross-referencing syntax
118+
<http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-syntax>`_
119+
for details.
120+
114121
**Good:**
115122

116123
.. code-block:: python
@@ -259,7 +266,7 @@ After the title, each parameter in the signature must be documented, including
259266
The parameters are defined by their name, followed by a space, a colon, another
260267
space, and the type (or types). Note that the space between the name and the
261268
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
269+
be defined for all other parameters. After the parameter definition, it is
263270
required to have a line with the parameter description, which is indented, and
264271
can have multiple lines. The description must start with a capital letter, and
265272
finish with a dot.

pandas/guide/pandas_docstring.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,15 @@ <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+
<p>Note: To display only the last component of the linked class, method or
128+
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> will
129+
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> as the
130+
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>
131+
for details.</p>
127132
<p><strong>Good:</strong></p>
128133
<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>
129134
<span class="sd">&quot;&quot;&quot;</span>

0 commit comments

Comments
 (0)