@@ -40,7 +40,7 @@ def _HasClass(tag, *classes):
40
40
return False
41
41
42
42
43
- def _ParseSymbolPage (symbol_page_html , symbol_name ):
43
+ def _ParseSymbolPage (symbol_page_html , symbol_name , qual_name ):
44
44
"""Parse symbol page and retrieve the include header defined in this page.
45
45
The symbol page provides header for the symbol, specifically in
46
46
"Defined in header <header>" section. An example:
@@ -69,7 +69,9 @@ def _ParseSymbolPage(symbol_page_html, symbol_name):
69
69
was_decl = True
70
70
# Symbols are in the first cell.
71
71
found_symbols = row .find ("td" ).stripped_strings
72
- if not symbol_name in found_symbols :
72
+ if not any (
73
+ sym == symbol_name or sym == qual_name for sym in found_symbols
74
+ ):
73
75
continue
74
76
headers .update (current_headers )
75
77
elif _HasClass (row , "t-dsc-header" ):
@@ -93,19 +95,18 @@ def _ParseSymbolVariant(caption):
93
95
if not (isinstance (caption , NavigableString ) and "(" in caption ):
94
96
return None
95
97
96
- if ')' in caption .text : # (locale), (algorithm), etc.
98
+ if ")" in caption .text : # (locale), (algorithm), etc.
97
99
return caption .text .strip (" ()" )
98
100
99
101
second_part = caption .next_sibling
100
102
if isinstance (second_part , Tag ) and second_part .name == "code" :
101
103
# (<code>std::complex</code>), etc.
102
104
third_part = second_part .next_sibling
103
- if isinstance (third_part , NavigableString ) and third_part .text .startswith (')' ):
105
+ if isinstance (third_part , NavigableString ) and third_part .text .startswith (")" ):
104
106
return second_part .text
105
107
return None
106
108
107
109
108
-
109
110
def _ParseIndexPage (index_page_html ):
110
111
"""Parse index page.
111
112
The index page lists all std symbols and hrefs to their detailed pages
@@ -137,9 +138,9 @@ def _ParseIndexPage(index_page_html):
137
138
return symbols
138
139
139
140
140
- def _ReadSymbolPage (path , name ):
141
+ def _ReadSymbolPage (path , name , qual_name ):
141
142
with open (path ) as f :
142
- return _ParseSymbolPage (f .read (), name )
143
+ return _ParseSymbolPage (f .read (), name , qual_name )
143
144
144
145
145
146
def _GetSymbols (pool , root_dir , index_page_name , namespace , variants_to_accept ):
@@ -161,17 +162,18 @@ def _GetSymbols(pool, root_dir, index_page_name, namespace, variants_to_accept):
161
162
for symbol_name , symbol_page_path , variant in _ParseIndexPage (f .read ()):
162
163
# Variant symbols (e.g. the std::locale version of isalpha) add ambiguity.
163
164
# FIXME: use these as a fallback rather than ignoring entirely.
164
- variants_for_symbol = variants_to_accept .get (
165
- (namespace or "" ) + symbol_name , ()
166
- )
165
+ qualified_symbol_name = (namespace or "" ) + symbol_name
166
+ variants_for_symbol = variants_to_accept .get (qualified_symbol_name , ())
167
167
if variant and variant not in variants_for_symbol :
168
168
continue
169
169
path = os .path .join (root_dir , symbol_page_path )
170
170
if os .path .isfile (path ):
171
171
results .append (
172
172
(
173
173
symbol_name ,
174
- pool .apply_async (_ReadSymbolPage , (path , symbol_name )),
174
+ pool .apply_async (
175
+ _ReadSymbolPage , (path , symbol_name , qualified_symbol_name )
176
+ ),
175
177
)
176
178
)
177
179
else :
0 commit comments