94
94
}
95
95
96
96
97
- def make_xref (param_type , xref_aliases , xref_ignore , wrap_unknown = True ):
97
+ def make_xref (param_type , xref_aliases , xref_ignore ):
98
98
"""Parse and apply appropriate sphinx role(s) to `param_type`.
99
99
100
100
The :obj: role is the default.
@@ -106,27 +106,36 @@ def make_xref(param_type, xref_aliases, xref_ignore, wrap_unknown=True):
106
106
xref_aliases : dict
107
107
Mapping used to resolve common abbreviations and aliases
108
108
to fully qualified names that can be cross-referenced.
109
- xref_ignore : set
110
- Words not to cross-reference.
111
- wrap_unknown : bool, default=True
112
- Toggle whether to wrap unrecognized terms in the default :obj: role,
113
- default is `True`. Unrecognized terms include those that are in
114
- neither `xref_aliases` nor `xref_ignore` and are not already wrapped
115
- in an rST role.
109
+ xref_ignore : set or "all"
110
+ A set containing words not to cross-reference. Instead of a set, the
111
+ string 'all' can be given to ignore all unrecognized terms.
112
+ Unrecognized terms include those that are not in `xref_aliases` and
113
+ are not already wrapped in a reST role.
116
114
117
115
Returns
118
116
-------
119
117
out : str
120
118
Text with fully-qualified names and terms that may be wrapped in a
121
119
``:obj:`` role.
122
120
"""
121
+ ignore_set = xref_ignore
122
+ wrap_unknown = True
123
+ if isinstance (xref_ignore , str ):
124
+ if xref_ignore .lower () == "all" :
125
+ wrap_unknown = False
126
+ ignore_set = set ()
127
+ else :
128
+ raise TypeError (
129
+ "xref_ignore must be a set or 'all', got {}" .format (xref_ignore )
130
+ )
131
+
123
132
if param_type in xref_aliases :
124
133
link , title = xref_aliases [param_type ], param_type
125
134
param_type = link
126
135
else :
127
136
link = title = param_type
128
137
129
- if QUALIFIED_NAME_RE .match (link ) and link not in xref_ignore :
138
+ if QUALIFIED_NAME_RE .match (link ) and link not in ignore_set :
130
139
if link != title :
131
140
return ':obj:`%s <%s>`' % (title , link )
132
141
if wrap_unknown :
@@ -147,9 +156,7 @@ def _split_and_apply_re(s, pattern):
147
156
if pattern .match (tok ):
148
157
results .append (tok )
149
158
else :
150
- res = make_xref (
151
- tok , xref_aliases , xref_ignore , wrap_unknown
152
- )
159
+ res = make_xref (tok , xref_aliases , xref_ignore )
153
160
# Opening brackets immediately after a role is
154
161
# bad markup. Detect that and add backslash.
155
162
# :role:`type`( to :role:`type`\(
0 commit comments