|
1 | 1 | # -*- encoding:utf-8 -*-
|
2 | 2 | from __future__ import division, absolute_import, print_function
|
3 | 3 |
|
4 |
| -from numpydoc.xref import make_xref_param_type |
| 4 | +from numpydoc.xref import make_xref |
5 | 5 |
|
6 | 6 | xref_aliases = {
|
7 | 7 | # python
|
|
20 | 20 | # Comes mainly from numpy
|
21 | 21 | data = r"""
|
22 | 22 | (...) array_like, float, optional
|
23 |
| -(...) :term:`numpy:array_like`, :xref_param_type:`float`, optional |
| 23 | +(...) :term:`numpy:array_like`, :obj:`float`, optional |
24 | 24 |
|
25 | 25 | (2,) ndarray
|
26 |
| -(2,) :xref_param_type:`ndarray <numpy.ndarray>` |
| 26 | +(2,) :obj:`ndarray <numpy.ndarray>` |
27 | 27 |
|
28 | 28 | (...,M,N) array_like
|
29 | 29 | (...,M,N) :term:`numpy:array_like`
|
30 | 30 |
|
31 | 31 | (..., M, N) array_like
|
32 |
| -(..., :xref_param_type:`M`, :xref_param_type:`N`) :term:`numpy:array_like` |
| 32 | +(..., :obj:`M`, :obj:`N`) :term:`numpy:array_like` |
33 | 33 |
|
34 | 34 | (float, float), optional
|
35 |
| -(:xref_param_type:`float`, :xref_param_type:`float`), optional |
| 35 | +(:obj:`float`, :obj:`float`), optional |
36 | 36 |
|
37 | 37 | 1-D array or sequence
|
38 |
| -1-D :xref_param_type:`array <numpy.ndarray>` or :term:`python:sequence` |
| 38 | +1-D :obj:`array <numpy.ndarray>` or :term:`python:sequence` |
39 | 39 |
|
40 | 40 | array of str or unicode-like
|
41 |
| -:xref_param_type:`array <numpy.ndarray>` of :xref_param_type:`str` or unicode-like |
| 41 | +:obj:`array <numpy.ndarray>` of :obj:`str` or unicode-like |
42 | 42 |
|
43 | 43 | array_like of float
|
44 |
| -:term:`numpy:array_like` of :xref_param_type:`float` |
| 44 | +:term:`numpy:array_like` of :obj:`float` |
45 | 45 |
|
46 | 46 | bool or callable
|
47 |
| -:xref_param_type:`bool` or :xref_param_type:`callable` |
| 47 | +:obj:`bool` or :obj:`callable` |
48 | 48 |
|
49 | 49 | int in [0, 255]
|
50 |
| -:xref_param_type:`int` in [0, 255] |
| 50 | +:obj:`int` in [0, 255] |
51 | 51 |
|
52 | 52 | int or None, optional
|
53 |
| -:xref_param_type:`int` or :xref_param_type:`None`, optional |
| 53 | +:obj:`int` or :obj:`None`, optional |
54 | 54 |
|
55 | 55 | list of str or array_like
|
56 |
| -:xref_param_type:`list` of :xref_param_type:`str` or :term:`numpy:array_like` |
| 56 | +:obj:`list` of :obj:`str` or :term:`numpy:array_like` |
57 | 57 |
|
58 | 58 | sequence of array_like
|
59 | 59 | :term:`python:sequence` of :term:`numpy:array_like`
|
60 | 60 |
|
61 | 61 | str or pathlib.Path
|
62 |
| -:xref_param_type:`str` or :xref_param_type:`pathlib.Path` |
| 62 | +:obj:`str` or :obj:`pathlib.Path` |
63 | 63 |
|
64 | 64 | {'', string}, optional
|
65 |
| -{'', :xref_param_type:`string <str>`}, optional |
| 65 | +{'', :obj:`string <str>`}, optional |
66 | 66 |
|
67 | 67 | {'C', 'F', 'A', or 'K'}, optional
|
68 | 68 | {'C', 'F', 'A', or 'K'}, optional
|
|
71 | 71 | {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
|
72 | 72 |
|
73 | 73 | {False, True, 'greedy', 'optimal'}
|
74 |
| -{:xref_param_type:`False`, :xref_param_type:`True`, 'greedy', 'optimal'} |
| 74 | +{:obj:`False`, :obj:`True`, 'greedy', 'optimal'} |
75 | 75 |
|
76 | 76 | {{'begin', 1}, {'end', 0}}, {string, int}
|
77 |
| -{{'begin', 1}, {'end', 0}}, {:xref_param_type:`string <str>`, :xref_param_type:`int`} |
| 77 | +{{'begin', 1}, {'end', 0}}, {:obj:`string <str>`, :obj:`int`} |
78 | 78 |
|
79 | 79 | callable f'(x,*args)
|
80 |
| -:xref_param_type:`callable` f'(x,*args) |
| 80 | +:obj:`callable` f'(x,*args) |
81 | 81 |
|
82 | 82 | callable ``fhess(x, *args)``, optional
|
83 |
| -:xref_param_type:`callable` ``fhess(x, *args)``, optional |
| 83 | +:obj:`callable` ``fhess(x, *args)``, optional |
84 | 84 |
|
85 | 85 | spmatrix (format: ``csr``, ``bsr``, ``dia`` or coo``)
|
86 |
| -:xref_param_type:`spmatrix` (format: ``csr``, ``bsr``, ``dia`` or coo``) |
| 86 | +:obj:`spmatrix` (format: ``csr``, ``bsr``, ``dia`` or coo``) |
87 | 87 |
|
88 | 88 | :ref:`strftime <strftime-strptime-behavior>`
|
89 | 89 | :ref:`strftime <strftime-strptime-behavior>`
|
90 | 90 |
|
91 | 91 | callable or :ref:`strftime <strftime-strptime-behavior>`
|
92 |
| -:xref_param_type:`callable` or :ref:`strftime <strftime-strptime-behavior>` |
| 92 | +:obj:`callable` or :ref:`strftime <strftime-strptime-behavior>` |
93 | 93 |
|
94 | 94 | callable or :ref:`strftime behavior <strftime-strptime-behavior>`
|
95 |
| -:xref_param_type:`callable` or :ref:`strftime behavior <strftime-strptime-behavior>` |
| 95 | +:obj:`callable` or :ref:`strftime behavior <strftime-strptime-behavior>` |
96 | 96 |
|
97 | 97 | list(int)
|
98 |
| -:xref_param_type:`list`\(:xref_param_type:`int`) |
| 98 | +:obj:`list`\(:obj:`int`) |
99 | 99 |
|
100 | 100 | list[int]
|
101 |
| -:xref_param_type:`list`\[:xref_param_type:`int`] |
| 101 | +:obj:`list`\[:obj:`int`] |
102 | 102 |
|
103 | 103 | dict(str, int)
|
104 |
| -:xref_param_type:`dict`\(:xref_param_type:`str`, :xref_param_type:`int`) |
| 104 | +:obj:`dict`\(:obj:`str`, :obj:`int`) |
105 | 105 |
|
106 | 106 | dict[str, int]
|
107 |
| -:xref_param_type:`dict`\[:xref_param_type:`str`, :xref_param_type:`int`] |
| 107 | +:obj:`dict`\[:obj:`str`, :obj:`int`] |
108 | 108 |
|
109 | 109 | tuple(float, float)
|
110 |
| -:xref_param_type:`tuple`\(:xref_param_type:`float`, :xref_param_type:`float`) |
| 110 | +:obj:`tuple`\(:obj:`float`, :obj:`float`) |
111 | 111 |
|
112 | 112 | dict[tuple(str, str), int]
|
113 |
| -:xref_param_type:`dict`\[:xref_param_type:`tuple`\(:xref_param_type:`str`, :xref_param_type:`str`), :xref_param_type:`int`] |
| 113 | +:obj:`dict`\[:obj:`tuple`\(:obj:`str`, :obj:`str`), :obj:`int`] |
114 | 114 | """ # noqa: E501
|
115 | 115 |
|
116 | 116 | xref_ignore = {'or', 'in', 'of', 'default', 'optional'}
|
117 | 117 |
|
118 | 118 |
|
119 |
| -def test_make_xref_param_type(): |
| 119 | +def test_make_xref(): |
120 | 120 | for s in data.strip().split('\n\n'):
|
121 | 121 | param_type, expected_result = s.split('\n')
|
122 |
| - result = make_xref_param_type( |
| 122 | + result = make_xref( |
123 | 123 | param_type,
|
124 | 124 | xref_aliases,
|
125 | 125 | xref_ignore
|
|
0 commit comments