|
1 | 1 | # -*- encoding:utf-8 -*-
|
2 | 2 | import pytest
|
3 |
| -from numpydoc.xref import make_xref |
4 |
| - |
5 |
| -xref_aliases = { |
6 |
| - # python |
7 |
| - 'sequence': ':term:`python:sequence`', |
8 |
| - 'iterable': ':term:`python:iterable`', |
9 |
| - 'string': 'str', |
10 |
| - # numpy |
11 |
| - 'array': 'numpy.ndarray', |
12 |
| - 'dtype': 'numpy.dtype', |
13 |
| - 'ndarray': 'numpy.ndarray', |
14 |
| - 'matrix': 'numpy.matrix', |
15 |
| - 'array-like': ':term:`numpy:array_like`', |
16 |
| - 'array_like': ':term:`numpy:array_like`', |
17 |
| -} |
| 3 | +from numpydoc.xref import make_xref, DEFAULT_LINKS |
| 4 | + |
| 5 | +# Use the default numpydoc link mapping |
| 6 | +xref_aliases = DEFAULT_LINKS |
| 7 | + |
18 | 8 |
|
19 | 9 | # Comes mainly from numpy
|
20 | 10 | data = r"""
|
21 | 11 | (...) array_like, float, optional
|
22 |
| -(...) :term:`numpy:array_like`, :obj:`float`, optional |
| 12 | +(...) :term:`numpy:array_like`, :class:`python:float`, optional |
23 | 13 |
|
24 | 14 | (2,) ndarray
|
25 | 15 | (2,) :obj:`ndarray <numpy.ndarray>`
|
|
31 | 21 | (..., :obj:`M`, :obj:`N`) :term:`numpy:array_like`
|
32 | 22 |
|
33 | 23 | (float, float), optional
|
34 |
| -(:obj:`float`, :obj:`float`), optional |
| 24 | +(:class:`python:float`, :class:`python:float`), optional |
35 | 25 |
|
36 | 26 | 1-D array or sequence
|
37 | 27 | 1-D :obj:`array <numpy.ndarray>` or :term:`python:sequence`
|
38 | 28 |
|
39 | 29 | array of str or unicode-like
|
40 |
| -:obj:`array <numpy.ndarray>` of :obj:`str` or unicode-like |
| 30 | +:obj:`array <numpy.ndarray>` of :class:`python:str` or unicode-like |
41 | 31 |
|
42 | 32 | array_like of float
|
43 |
| -:term:`numpy:array_like` of :obj:`float` |
| 33 | +:term:`numpy:array_like` of :class:`python:float` |
44 | 34 |
|
45 | 35 | bool or callable
|
46 |
| -:obj:`bool` or :obj:`callable` |
| 36 | +:ref:`bool <python:bltin-boolean-values>` or :func:`python:callable` |
47 | 37 |
|
48 | 38 | int in [0, 255]
|
49 |
| -:obj:`int` in [0, 255] |
| 39 | +:class:`python:int` in [0, 255] |
50 | 40 |
|
51 | 41 | int or None, optional
|
52 |
| -:obj:`int` or :obj:`None`, optional |
| 42 | +:class:`python:int` or :data:`python:None`, optional |
53 | 43 |
|
54 | 44 | list of str or array_like
|
55 |
| -:obj:`list` of :obj:`str` or :term:`numpy:array_like` |
| 45 | +:class:`python:list` of :class:`python:str` or :term:`numpy:array_like` |
56 | 46 |
|
57 | 47 | sequence of array_like
|
58 | 48 | :term:`python:sequence` of :term:`numpy:array_like`
|
59 | 49 |
|
60 | 50 | str or pathlib.Path
|
61 |
| -:obj:`str` or :obj:`pathlib.Path` |
| 51 | +:class:`python:str` or :obj:`pathlib.Path` |
62 | 52 |
|
63 | 53 | {'', string}, optional
|
64 |
| -{'', :obj:`string <str>`}, optional |
| 54 | +{'', :class:`python:str`}, optional |
65 | 55 |
|
66 | 56 | {'C', 'F', 'A', or 'K'}, optional
|
67 | 57 | {'C', 'F', 'A', or 'K'}, optional
|
|
70 | 60 | {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
|
71 | 61 |
|
72 | 62 | {False, True, 'greedy', 'optimal'}
|
73 |
| -{:obj:`False`, :obj:`True`, 'greedy', 'optimal'} |
| 63 | +{:data:`python:False`, :data:`python:True`, 'greedy', 'optimal'} |
74 | 64 |
|
75 | 65 | {{'begin', 1}, {'end', 0}}, {string, int}
|
76 |
| -{{'begin', 1}, {'end', 0}}, {:obj:`string <str>`, :obj:`int`} |
| 66 | +{{'begin', 1}, {'end', 0}}, {:class:`python:str`, :class:`python:int`} |
77 | 67 |
|
78 | 68 | callable f'(x,*args)
|
79 |
| -:obj:`callable` f'(x,*args) |
| 69 | +:func:`python:callable` f'(x,*args) |
80 | 70 |
|
81 | 71 | callable ``fhess(x, *args)``, optional
|
82 |
| -:obj:`callable` ``fhess(x, *args)``, optional |
| 72 | +:func:`python:callable` ``fhess(x, *args)``, optional |
83 | 73 |
|
84 | 74 | spmatrix (format: ``csr``, ``bsr``, ``dia`` or coo``)
|
85 | 75 | :obj:`spmatrix` (format: ``csr``, ``bsr``, ``dia`` or coo``)
|
|
88 | 78 | :ref:`strftime <strftime-strptime-behavior>`
|
89 | 79 |
|
90 | 80 | callable or :ref:`strftime <strftime-strptime-behavior>`
|
91 |
| -:obj:`callable` or :ref:`strftime <strftime-strptime-behavior>` |
| 81 | +:func:`python:callable` or :ref:`strftime <strftime-strptime-behavior>` |
92 | 82 |
|
93 | 83 | callable or :ref:`strftime behavior <strftime-strptime-behavior>`
|
94 |
| -:obj:`callable` or :ref:`strftime behavior <strftime-strptime-behavior>` |
| 84 | +:func:`python:callable` or :ref:`strftime behavior <strftime-strptime-behavior>` |
95 | 85 |
|
96 | 86 | list(int)
|
97 |
| -:obj:`list`\(:obj:`int`) |
| 87 | +:class:`python:list`\(:class:`python:int`) |
98 | 88 |
|
99 | 89 | list[int]
|
100 |
| -:obj:`list`\[:obj:`int`] |
| 90 | +:class:`python:list`\[:class:`python:int`] |
101 | 91 |
|
102 | 92 | dict(str, int)
|
103 |
| -:obj:`dict`\(:obj:`str`, :obj:`int`) |
| 93 | +:class:`python:dict`\(:class:`python:str`, :class:`python:int`) |
104 | 94 |
|
105 | 95 | dict[str, int]
|
106 |
| -:obj:`dict`\[:obj:`str`, :obj:`int`] |
| 96 | +:class:`python:dict`\[:class:`python:str`, :class:`python:int`] |
107 | 97 |
|
108 | 98 | tuple(float, float)
|
109 |
| -:obj:`tuple`\(:obj:`float`, :obj:`float`) |
| 99 | +:class:`python:tuple`\(:class:`python:float`, :class:`python:float`) |
110 | 100 |
|
111 | 101 | dict[tuple(str, str), int]
|
112 |
| -:obj:`dict`\[:obj:`tuple`\(:obj:`str`, :obj:`str`), :obj:`int`] |
| 102 | +:class:`python:dict`\[:class:`python:tuple`\(:class:`python:str`, :class:`python:str`), :class:`python:int`] |
113 | 103 | """ # noqa: E501
|
114 | 104 |
|
115 | 105 | xref_ignore = {'or', 'in', 'of', 'default', 'optional'}
|
|
0 commit comments