@@ -134,8 +134,8 @@ def is_url(str_to_validate: str) -> bool:
134
134
135
135
class SymbolMap :
136
136
"""A SymbolMap maps symbols to Entries."""
137
- def __init__ (self , xml_doc : ET .ElementTree ) -> None :
138
- entries = parse_tag_file (xml_doc )
137
+ def __init__ (self , xml_doc : ET .ElementTree , parse_error_ignore_regexes : Optional [ List [ str ]] = None ) -> None :
138
+ entries = parse_tag_file (xml_doc , parse_error_ignore_regexes )
139
139
140
140
# Sort the entry list for use with bisect
141
141
self ._entries = sorted (entries )
@@ -225,7 +225,7 @@ def __getitem__(self, item: str) -> Entry:
225
225
return self ._disambiguate (symbol , candidates )
226
226
227
227
228
- def parse_tag_file (doc : ET .ElementTree ) -> List [Entry ]:
228
+ def parse_tag_file (doc : ET .ElementTree , parse_error_ignore_regexes : Optional [ List [ str ]] ) -> List [Entry ]:
229
229
"""
230
230
Takes in an XML tree from a Doxygen tag file and returns a list that looks something like:
231
231
@@ -290,7 +290,22 @@ def parse_tag_file(doc: ET.ElementTree) -> List[Entry]:
290
290
entries .append (
291
291
Entry (name = member_symbol , kind = member_kind , file = member_file , arglist = normalised_arglist ))
292
292
except ParseException as e :
293
- print (f'Skipping { member_kind } { member_symbol } { arglist } . Error reported from parser was: { e } ' )
293
+ message = f'Skipping { member_kind } { member_symbol } { arglist } . Error reported from parser was: { e } '
294
+ should_report = True
295
+
296
+ if parse_error_ignore_regexes :
297
+ for pattern in parse_error_ignore_regexes :
298
+ try :
299
+ if re .search (pattern , message ):
300
+ should_report = False
301
+ break
302
+ except re .error :
303
+ # Invalid regex pattern - ignore it
304
+ continue
305
+
306
+ if should_report :
307
+ report_warning (None , message ) # Use None as env since we don't have access to it here
308
+ continue
294
309
else :
295
310
# Put the simple things directly into the list
296
311
entries .append (Entry (name = member_symbol , kind = member_kind , file = member_file , arglist = None ))
@@ -303,6 +318,11 @@ def join(*args):
303
318
304
319
305
320
def create_role (app , tag_filename , rootdir , cache_name , pdf = "" ):
321
+ parse_error_ignore_regexes = getattr (app .config , 'doxylink_parse_error_ignore_regexes' , [])
322
+
323
+ if parse_error_ignore_regexes :
324
+ report_info (app .env , f'Using parse error ignore patterns: { ", " .join (parse_error_ignore_regexes )} ' )
325
+
306
326
# Tidy up the root directory path
307
327
if not rootdir .endswith (('/' , '\\ ' )):
308
328
rootdir = join (rootdir , os .sep )
@@ -330,22 +350,22 @@ def _parse():
330
350
if not hasattr (app .env , 'doxylink_cache' ):
331
351
# no cache present at all, initialise it
332
352
report_info (app .env , 'No cache at all, rebuilding...' )
333
- mapping = SymbolMap (_parse ())
353
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
334
354
app .env .doxylink_cache = {cache_name : {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }}
335
355
elif not app .env .doxylink_cache .get (cache_name ):
336
356
# Main cache is there but the specific sub-cache for this tag file is not
337
357
report_info (app .env , 'Sub cache is missing, rebuilding...' )
338
- mapping = SymbolMap (_parse ())
358
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
339
359
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }
340
360
elif app .env .doxylink_cache [cache_name ]['mtime' ] < modification_time :
341
361
# tag file has been modified since sub-cache creation
342
362
report_info (app .env , 'Sub-cache is out of date, rebuilding...' )
343
- mapping = SymbolMap (_parse ())
363
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
344
364
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time }
345
365
elif not app .env .doxylink_cache [cache_name ].get ('version' ) or app .env .doxylink_cache [cache_name ].get ('version' ) != __version__ :
346
366
# sub-cache doesn't have a version or the version doesn't match
347
367
report_info (app .env , 'Sub-cache schema version doesn\' t match, rebuilding...' )
348
- mapping = SymbolMap (_parse ())
368
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
349
369
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }
350
370
else :
351
371
# The cache is up to date
0 commit comments