@@ -103,7 +103,9 @@ def _ParseIndexPage(index_page_html):
103
103
# This accidentally accepts begin/end despite the (iterator) caption: the
104
104
# (since C++11) note is first. They are good symbols, so the bug is unfixed.
105
105
caption = symbol_href .next_sibling
106
- variant = isinstance (caption , NavigableString ) and "(" in caption
106
+ variant = None
107
+ if isinstance (caption , NavigableString ) and "(" in caption :
108
+ variant = caption .text .strip (" ()" )
107
109
symbol_tt = symbol_href .find ("tt" )
108
110
if symbol_tt :
109
111
symbols .append ((symbol_tt .text .rstrip ("<>()" ), # strip any trailing <>()
@@ -116,7 +118,7 @@ def _ReadSymbolPage(path, name):
116
118
return _ParseSymbolPage (f .read (), name )
117
119
118
120
119
- def _GetSymbols (pool , root_dir , index_page_name , namespace ):
121
+ def _GetSymbols (pool , root_dir , index_page_name , namespace , variants_to_accept ):
120
122
"""Get all symbols listed in the index page. All symbols should be in the
121
123
given namespace.
122
124
@@ -135,7 +137,9 @@ def _GetSymbols(pool, root_dir, index_page_name, namespace):
135
137
for symbol_name , symbol_page_path , variant in _ParseIndexPage (f .read ()):
136
138
# Variant symbols (e.g. the std::locale version of isalpha) add ambiguity.
137
139
# FIXME: use these as a fallback rather than ignoring entirely.
138
- if variant :
140
+ variants_for_symbol = variants_to_accept .get (
141
+ (namespace or "" ) + symbol_name , ())
142
+ if variant and variant not in variants_for_symbol :
139
143
continue
140
144
path = os .path .join (root_dir , symbol_page_path )
141
145
results .append ((symbol_name ,
@@ -158,14 +162,22 @@ def GetSymbols(parse_pages):
158
162
Args:
159
163
parse_pages: a list of tuples (page_root_dir, index_page_name, namespace)
160
164
"""
165
+ # By default we prefer the non-variant versions, as they're more common. But
166
+ # there are some symbols, whose variant is more common. This list describes
167
+ # those symbols.
168
+ variants_to_accept = {
169
+ # std::remove<> has variant algorithm.
170
+ "std::remove" : ("algorithm" ),
171
+ }
161
172
symbols = []
162
173
# Run many workers to process individual symbol pages under the symbol index.
163
174
# Don't allow workers to capture Ctrl-C.
164
175
pool = multiprocessing .Pool (
165
176
initializer = lambda : signal .signal (signal .SIGINT , signal .SIG_IGN ))
166
177
try :
167
178
for root_dir , page_name , namespace in parse_pages :
168
- symbols .extend (_GetSymbols (pool , root_dir , page_name , namespace ))
179
+ symbols .extend (_GetSymbols (pool , root_dir , page_name , namespace ,
180
+ variants_to_accept ))
169
181
finally :
170
182
pool .terminate ()
171
183
pool .join ()
0 commit comments