19
19
from sphinx .util .logging import getLogger
20
20
21
21
from . import __version__
22
+ from . import config
22
23
from .parsing import normalise , ParseException
23
24
24
25
@@ -134,8 +135,8 @@ def is_url(str_to_validate: str) -> bool:
134
135
135
136
class SymbolMap :
136
137
"""A SymbolMap maps symbols to Entries."""
137
- def __init__ (self , xml_doc : ET .ElementTree ) -> None :
138
- entries = parse_tag_file (xml_doc )
138
+ def __init__ (self , xml_doc : ET .ElementTree , ignore_parse_exceptions : bool ) -> None :
139
+ entries = parse_tag_file (xml_doc , ignore_parse_exceptions )
139
140
140
141
# Sort the entry list for use with bisect
141
142
self ._entries = sorted (entries )
@@ -225,7 +226,7 @@ def __getitem__(self, item: str) -> Entry:
225
226
return self ._disambiguate (symbol , candidates )
226
227
227
228
228
- def parse_tag_file (doc : ET .ElementTree ) -> List [Entry ]:
229
+ def parse_tag_file (doc : ET .ElementTree , ignore_parse_exceptions : bool ) -> List [Entry ]:
229
230
"""
230
231
Takes in an XML tree from a Doxygen tag file and returns a list that looks something like:
231
232
@@ -290,7 +291,9 @@ def parse_tag_file(doc: ET.ElementTree) -> List[Entry]:
290
291
entries .append (
291
292
Entry (name = member_symbol , kind = member_kind , file = member_file , arglist = normalised_arglist ))
292
293
except ParseException as e :
293
- print (f'Skipping { member_kind } { member_symbol } { arglist } . Error reported from parser was: { e } ' )
294
+ if not ignore_parse_exceptions :
295
+ print (f'Skipping { member_kind } { member_symbol } { arglist } . Error reported from parser was: { e } ' )
296
+ continue
294
297
else :
295
298
# Put the simple things directly into the list
296
299
entries .append (Entry (name = member_symbol , kind = member_kind , file = member_file , arglist = None ))
@@ -303,6 +306,10 @@ def join(*args):
303
306
304
307
305
308
def create_role (app , tag_filename , rootdir , cache_name , pdf = "" ):
309
+ ignore_parse_exceptions = getattr (app .config , config .DOXYLINK_IGNORE_PARSE_EXCEPTIONS_KEY )
310
+ if ignore_parse_exceptions :
311
+ report_info (app .env ,"Ignoring parsing exceptions" )
312
+
306
313
# Tidy up the root directory path
307
314
if not rootdir .endswith (('/' , '\\ ' )):
308
315
rootdir = join (rootdir , os .sep )
@@ -330,22 +337,22 @@ def _parse():
330
337
if not hasattr (app .env , 'doxylink_cache' ):
331
338
# no cache present at all, initialise it
332
339
report_info (app .env , 'No cache at all, rebuilding...' )
333
- mapping = SymbolMap (_parse ())
340
+ mapping = SymbolMap (_parse (), ignore_parse_exceptions )
334
341
app .env .doxylink_cache = {cache_name : {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }}
335
342
elif not app .env .doxylink_cache .get (cache_name ):
336
343
# Main cache is there but the specific sub-cache for this tag file is not
337
344
report_info (app .env , 'Sub cache is missing, rebuilding...' )
338
- mapping = SymbolMap (_parse ())
345
+ mapping = SymbolMap (_parse (), ignore_parse_exceptions )
339
346
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }
340
347
elif app .env .doxylink_cache [cache_name ]['mtime' ] < modification_time :
341
348
# tag file has been modified since sub-cache creation
342
349
report_info (app .env , 'Sub-cache is out of date, rebuilding...' )
343
- mapping = SymbolMap (_parse ())
350
+ mapping = SymbolMap (_parse (), ignore_parse_exceptions )
344
351
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time }
345
352
elif not app .env .doxylink_cache [cache_name ].get ('version' ) or app .env .doxylink_cache [cache_name ].get ('version' ) != __version__ :
346
353
# sub-cache doesn't have a version or the version doesn't match
347
354
report_info (app .env , 'Sub-cache schema version doesn\' t match, rebuilding...' )
348
- mapping = SymbolMap (_parse ())
355
+ mapping = SymbolMap (_parse (), ignore_parse_exceptions )
349
356
app .env .doxylink_cache [cache_name ] = {'mapping' : mapping , 'mtime' : modification_time , 'version' : __version__ }
350
357
else :
351
358
# The cache is up to date
0 commit comments