Skip to content

FIX handling of parameter names ending '_' #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ def _str_extended_summary(self):
return self['Extended Summary'] + ['']

def _str_returns(self, name='Returns'):
if self.use_blockquotes:
typed_fmt = '**%s** : %s'
untyped_fmt = '**%s**'
else:
typed_fmt = '%s : %s'
untyped_fmt = '%s'
typed_fmt = '**%s** : %s'
untyped_fmt = '**%s**'

out = []
if self[name]:
Expand Down Expand Up @@ -127,7 +123,10 @@ def _process_param(self, param, desc, fake_autosummary):
relies on Sphinx's plugin mechanism.
"""
param = param.strip()
display_param = ('**%s**' if self.use_blockquotes else '%s') % param
# XXX: If changing the following, please check the rendering when param
# ends with '_', e.g. 'word_'
# See https://github.com/numpy/numpydoc/pull/144
display_param = '**%s**' % param

if not fake_autosummary:
return display_param, desc
Expand Down
40 changes: 20 additions & 20 deletions numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,51 +484,51 @@ def test_sphinx_str():

:Parameters:

mean : (N,) ndarray
**mean** : (N,) ndarray
Mean of the N-dimensional distribution.

.. math::

(1+2+3)/3

cov : (N, N) ndarray
**cov** : (N, N) ndarray
Covariance matrix of the distribution.

shape : tuple of ints
**shape** : tuple of ints
Given a shape of, for example, (m,n,k), m*n*k samples are
generated, and packed in an m-by-n-by-k arrangement. Because
each sample is N-dimensional, the output shape is (m,n,k,N).

:Returns:

out : ndarray
**out** : ndarray
The drawn samples, arranged according to `shape`. If the
shape given is (m,n,...), then the shape of `out` is
(m,n,...,N).

In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
value drawn from the distribution.

list of str
**list of str**
This is not a real return value. It exists to test
anonymous return values.

no_description
**no_description**
..

:Other Parameters:

spam : parrot
**spam** : parrot
A parrot off its mortal coil.

:Raises:

RuntimeError
**RuntimeError**
Some error

:Warns:

RuntimeWarning
**RuntimeWarning**
Some warning

.. warning::
Expand Down Expand Up @@ -596,13 +596,13 @@ def test_sphinx_yields_str():

:Yields:

a : int
**a** : int
The number of apples.

b : int
**b** : int
The number of bananas.

int
**int**
The number of unknowns.
""")

Expand Down Expand Up @@ -1129,10 +1129,10 @@ def no_period(self):

:Parameters:

f : callable ``f(t, y, *f_args)``
**f** : callable ``f(t, y, *f_args)``
Aaa.

jac : callable ``jac(t, y, *jac_args)``
**jac** : callable ``jac(t, y, *jac_args)``
Bbb.

.. rubric:: Examples
Expand All @@ -1141,10 +1141,10 @@ def no_period(self):

:Attributes:

t : float
**t** : float
Current time.

y : ndarray
**y** : ndarray
Current variable values.

* hello
Expand All @@ -1153,10 +1153,10 @@ def no_period(self):
:obj:`an_attribute <an_attribute>` : float
Test attribute

no_docstring : str
**no_docstring** : str
But a description

no_docstring2 : str
**no_docstring2** : str
..

:obj:`multiline_sentence <multiline_sentence>`
Expand Down Expand Up @@ -1190,10 +1190,10 @@ def test_templated_sections():

:Parameters:

f : callable ``f(t, y, *f_args)``
**f** : callable ``f(t, y, *f_args)``
Aaa.

jac : callable ``jac(t, y, *jac_args)``
**jac** : callable ``jac(t, y, *jac_args)``
Bbb.

""")
Expand Down