@@ -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 , parse_exception_ignore_pattern : Union [ 're.Pattern' , None ] = None ) -> None :
138
- entries = parse_tag_file (xml_doc , parse_exception_ignore_pattern )
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 , parse_exception_ignore_pattern : Union [ 're.Pattern' , None ]) -> 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,13 +290,21 @@ def parse_tag_file(doc: ET.ElementTree, parse_exception_ignore_pattern: Union['r
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
- # Check if the parse exception message matches the ignore regular expression, if it does do not print the message
294
293
message = f'Skipping { member_kind } { member_symbol } { arglist } . Error reported from parser was: { e } '
295
- matched = parse_exception_ignore_pattern .match (message ) if parse_exception_ignore_pattern else False
296
-
297
- if not matched :
298
- print (message )
299
-
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
300
308
continue
301
309
else :
302
310
# Put the simple things directly into the list
@@ -309,12 +317,15 @@ def join(*args):
309
317
return '' .join (args )
310
318
311
319
312
- def create_role (app , tag_filename , rootdir , cache_name , pdf = "" ):
313
- parse_exception_ignore_regex_list = getattr (app .config , 'doxylink_parse_exception_ignore_regex_list' )
314
- parse_exception_ignore_pattern = re .compile ('|' .join (parse_exception_ignore_regex_list )) if parse_exception_ignore_regex_list else None
320
+ def create_role (app : 'sphinx.application.Sphinx' ,
321
+ tag_filename : str ,
322
+ rootdir : str ,
323
+ cache_name : str ,
324
+ pdf : str = "" ) -> None :
325
+ parse_error_ignore_regexes = getattr (app .config , 'doxylink_parse_error_ignore_regexes' , [])
315
326
316
- if parse_exception_ignore_pattern :
317
- report_info (app .env , f'Ignoring parsing exceptions using ` { parse_exception_ignore_pattern } ` ' )
327
+ if parse_error_ignore_regexes :
328
+ report_info (app .env , f'Using parse error ignore patterns: { ", " . join ( parse_error_ignore_regexes ) } ' )
318
329
319
330
# Tidy up the root directory path
320
331
if not rootdir .endswith (('/' , '\\ ' )):
@@ -343,22 +354,22 @@ def _parse():
343
354
if not hasattr (app .env , 'doxylink_cache' ):
344
355
# no cache present at all, initialise it
345
356
report_info (app .env , 'No cache at all, rebuilding...' )
346
- mapping = SymbolMap (_parse (), parse_exception_ignore_pattern )
357
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
347
358
app .env .doxylink_cache = {cache_name : {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }}
348
359
elif not app .env .doxylink_cache .get (cache_name ):
349
360
# Main cache is there but the specific sub-cache for this tag file is not
350
361
report_info (app .env , 'Sub cache is missing, rebuilding...' )
351
- mapping = SymbolMap (_parse (), parse_exception_ignore_pattern )
362
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
352
363
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }
353
364
elif app .env .doxylink_cache [cache_name ]['mtime' ] < modification_time :
354
365
# tag file has been modified since sub-cache creation
355
366
report_info (app .env , 'Sub-cache is out of date, rebuilding...' )
356
- mapping = SymbolMap (_parse (), parse_exception_ignore_pattern )
367
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
357
368
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time }
358
369
elif not app .env .doxylink_cache [cache_name ].get ('version' ) or app .env .doxylink_cache [cache_name ].get ('version' ) != __version__ :
359
370
# sub-cache doesn't have a version or the version doesn't match
360
371
report_info (app .env , 'Sub-cache schema version doesn\' t match, rebuilding...' )
361
- mapping = SymbolMap (_parse (), parse_exception_ignore_pattern )
372
+ mapping = SymbolMap (_parse (), parse_error_ignore_regexes )
362
373
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }
363
374
else :
364
375
# The cache is up to date
0 commit comments