1
1
# -*- encoding:utf-8 -*-
2
2
from __future__ import division , absolute_import , print_function
3
3
4
+ from collections import namedtuple
4
5
import re
5
6
import sys
6
7
import textwrap
7
8
import warnings
8
9
9
10
import jinja2
10
11
12
+ from numpydoc .numpydoc import update_config
11
13
from numpydoc .docscrape import (
12
14
NumpyDocString ,
13
15
FunctionDoc ,
@@ -382,11 +384,11 @@ def _strip_blank_lines(s):
382
384
return s
383
385
384
386
385
- def line_by_line_compare (a , b ):
387
+ def line_by_line_compare (a , b , n_lines = None ):
386
388
a = textwrap .dedent (a )
387
389
b = textwrap .dedent (b )
388
- a = [l .rstrip () for l in _strip_blank_lines (a ).split ('\n ' )]
389
- b = [l .rstrip () for l in _strip_blank_lines (b ).split ('\n ' )]
390
+ a = [l .rstrip () for l in _strip_blank_lines (a ).split ('\n ' )][: n_lines ]
391
+ b = [l .rstrip () for l in _strip_blank_lines (b ).split ('\n ' )][: n_lines ]
390
392
assert len (a ) == len (b )
391
393
for ii , (aa , bb ) in enumerate (zip (a , b )):
392
394
assert aa == bb
@@ -518,8 +520,7 @@ def test_yield_str():
518
520
The number of bananas.
519
521
int
520
522
The number of unknowns.
521
-
522
- .. index:: """ )
523
+ """ )
523
524
524
525
525
526
def test_receives_str ():
@@ -537,8 +538,7 @@ def test_receives_str():
537
538
The number of bananas.
538
539
c : int
539
540
The number of oranges.
540
-
541
- .. index:: """ )
541
+ """ )
542
542
543
543
544
544
def test_no_index_in_str ():
@@ -1200,8 +1200,6 @@ def test_class_members_doc():
1200
1200
b
1201
1201
c
1202
1202
1203
- .. index::
1204
-
1205
1203
""" )
1206
1204
1207
1205
@@ -1422,7 +1420,7 @@ def test_autoclass():
1422
1420
.. rubric:: Methods
1423
1421
1424
1422
1425
- ''' )
1423
+ ''' , 5 )
1426
1424
1427
1425
1428
1426
xref_doc_txt = """
@@ -1442,7 +1440,7 @@ def test_autoclass():
1442
1440
List of integers
1443
1441
p4 : :class:`pandas.DataFrame`
1444
1442
A dataframe
1445
- p5 : sequence of int
1443
+ p5 : sequence of ` int`
1446
1444
A sequence
1447
1445
1448
1446
Returns
@@ -1458,37 +1456,39 @@ def test_autoclass():
1458
1456
1459
1457
:Parameters:
1460
1458
1461
- **p1** : :xref_param_type:` int`
1459
+ **p1** : :class:`python: int`
1462
1460
Integer value
1463
1461
1464
- **p2** : :xref_param_type:` float`, optional
1462
+ **p2** : :class:`python: float`, optional
1465
1463
Integer value
1466
1464
1467
1465
:Returns:
1468
1466
1469
- **out** : :xref_param_type :`array <numpy.ndarray>`
1467
+ **out** : :obj :`array <numpy.ndarray>`
1470
1468
Numerical return value
1471
1469
1472
1470
1473
1471
:Other Parameters:
1474
1472
1475
- **p3** : :xref_param_type:` list`\[:xref_param_type:` int`]
1473
+ **p3** : :class:`python: list`\[:class:`python: int`]
1476
1474
List of integers
1477
1475
1478
1476
**p4** : :class:`pandas.DataFrame`
1479
1477
A dataframe
1480
1478
1481
- **p5** : :term :`python:sequence` of :xref_param_type: `int`
1479
+ **p5** : :obj :`python:sequence` of `int`
1482
1480
A sequence
1483
1481
"""
1484
1482
1485
1483
1486
1484
def test_xref ():
1487
1485
xref_aliases = {
1488
- 'sequence' : ':term:`python:sequence`' ,
1489
- 'iterable' : ':term:`python:iterable`' ,
1490
- 'array' : 'numpy.ndarray' ,
1486
+ 'sequence' : ':obj:`python:sequence`' ,
1491
1487
}
1488
+ config = namedtuple ('numpydoc_xref_aliases' ,
1489
+ 'numpydoc_xref_aliases' )(xref_aliases )
1490
+ app = namedtuple ('config' , 'config' )(config )
1491
+ update_config (app )
1492
1492
1493
1493
xref_ignore = {'of' , 'default' , 'optional' }
1494
1494
0 commit comments