Skip to content

Commit d7c6de5

Browse files
dukebodydatapythonista
authored andcommitted
Only use ~ in ref to class to hide prefix (#78)
1 parent fd7c7c3 commit d7c6de5

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

pandas/guide/_sources/pandas_docstring.rst.txt

Lines changed: 9 additions & 1 deletion
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

pandas/guide/pandas_docstring.html

Lines changed: 9 additions & 1 deletion
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)