Skip to content

Commit d7a2bdc

Browse files
authored
Merge pull request #144 from jnothman/bold
FIX handling of parameter names ending '_'
2 parents fb6afac + a4d94cd commit d7a2bdc

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

numpydoc/docscrape_sphinx.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ def _str_extended_summary(self):
6767
return self['Extended Summary'] + ['']
6868

6969
def _str_returns(self, name='Returns'):
70-
if self.use_blockquotes:
71-
typed_fmt = '**%s** : %s'
72-
untyped_fmt = '**%s**'
73-
else:
74-
typed_fmt = '%s : %s'
75-
untyped_fmt = '%s'
70+
typed_fmt = '**%s** : %s'
71+
untyped_fmt = '**%s**'
7672

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

132131
if not fake_autosummary:
133132
return display_param, desc

numpydoc/tests/test_docscrape.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -484,51 +484,51 @@ def test_sphinx_str():
484484
485485
:Parameters:
486486
487-
mean : (N,) ndarray
487+
**mean** : (N,) ndarray
488488
Mean of the N-dimensional distribution.
489489
490490
.. math::
491491
492492
(1+2+3)/3
493493
494-
cov : (N, N) ndarray
494+
**cov** : (N, N) ndarray
495495
Covariance matrix of the distribution.
496496
497-
shape : tuple of ints
497+
**shape** : tuple of ints
498498
Given a shape of, for example, (m,n,k), m*n*k samples are
499499
generated, and packed in an m-by-n-by-k arrangement. Because
500500
each sample is N-dimensional, the output shape is (m,n,k,N).
501501
502502
:Returns:
503503
504-
out : ndarray
504+
**out** : ndarray
505505
The drawn samples, arranged according to `shape`. If the
506506
shape given is (m,n,...), then the shape of `out` is
507507
(m,n,...,N).
508508
509509
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
510510
value drawn from the distribution.
511511
512-
list of str
512+
**list of str**
513513
This is not a real return value. It exists to test
514514
anonymous return values.
515515
516-
no_description
516+
**no_description**
517517
..
518518
519519
:Other Parameters:
520520
521-
spam : parrot
521+
**spam** : parrot
522522
A parrot off its mortal coil.
523523
524524
:Raises:
525525
526-
RuntimeError
526+
**RuntimeError**
527527
Some error
528528
529529
:Warns:
530530
531-
RuntimeWarning
531+
**RuntimeWarning**
532532
Some warning
533533
534534
.. warning::
@@ -596,13 +596,13 @@ def test_sphinx_yields_str():
596596
597597
:Yields:
598598
599-
a : int
599+
**a** : int
600600
The number of apples.
601601
602-
b : int
602+
**b** : int
603603
The number of bananas.
604604
605-
int
605+
**int**
606606
The number of unknowns.
607607
""")
608608

@@ -1129,10 +1129,10 @@ def no_period(self):
11291129
11301130
:Parameters:
11311131
1132-
f : callable ``f(t, y, *f_args)``
1132+
**f** : callable ``f(t, y, *f_args)``
11331133
Aaa.
11341134
1135-
jac : callable ``jac(t, y, *jac_args)``
1135+
**jac** : callable ``jac(t, y, *jac_args)``
11361136
Bbb.
11371137
11381138
.. rubric:: Examples
@@ -1141,10 +1141,10 @@ def no_period(self):
11411141
11421142
:Attributes:
11431143
1144-
t : float
1144+
**t** : float
11451145
Current time.
11461146
1147-
y : ndarray
1147+
**y** : ndarray
11481148
Current variable values.
11491149
11501150
* hello
@@ -1153,10 +1153,10 @@ def no_period(self):
11531153
:obj:`an_attribute <an_attribute>` : float
11541154
Test attribute
11551155
1156-
no_docstring : str
1156+
**no_docstring** : str
11571157
But a description
11581158
1159-
no_docstring2 : str
1159+
**no_docstring2** : str
11601160
..
11611161
11621162
:obj:`multiline_sentence <multiline_sentence>`
@@ -1190,10 +1190,10 @@ def test_templated_sections():
11901190
11911191
:Parameters:
11921192
1193-
f : callable ``f(t, y, *f_args)``
1193+
**f** : callable ``f(t, y, *f_args)``
11941194
Aaa.
11951195
1196-
jac : callable ``jac(t, y, *jac_args)``
1196+
**jac** : callable ``jac(t, y, *jac_args)``
11971197
Bbb.
11981198
11991199
""")

0 commit comments

Comments
 (0)