mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
implement nitpick_ignore_regex
This commit is contained in:
parent
9e1b4a8f16
commit
00bc3465b3
@ -131,6 +131,7 @@ class Config:
|
||||
'manpages_url': (None, 'env', []),
|
||||
'nitpicky': (False, None, []),
|
||||
'nitpick_ignore': ([], None, []),
|
||||
'nitpick_ignore_regex': ([], None, []),
|
||||
'numfig': (False, 'env', []),
|
||||
'numfig_secnum_depth': (1, 'env', []),
|
||||
'numfig_format': ({}, 'env', []), # will be initialized in init_numfig_format()
|
||||
|
@ -8,6 +8,7 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, cast
|
||||
|
||||
from docutils import nodes
|
||||
@ -171,14 +172,27 @@ class ReferencesResolver(SphinxPostTransform):
|
||||
warn = node.get('refwarn')
|
||||
if self.config.nitpicky:
|
||||
warn = True
|
||||
dtype = '%s:%s' % (domain.name, typ) if domain else typ
|
||||
if self.config.nitpick_ignore:
|
||||
dtype = '%s:%s' % (domain.name, typ) if domain else typ
|
||||
if (dtype, target) in self.config.nitpick_ignore:
|
||||
warn = False
|
||||
# for "std" types also try without domain name
|
||||
if (not domain or domain.name == 'std') and \
|
||||
(typ, target) in self.config.nitpick_ignore:
|
||||
warn = False
|
||||
if self.config.nitpick_ignore_regex:
|
||||
def matches_ignore(entry_type: str, entry_target: str) -> bool:
|
||||
for ignore_type, ignore_target in self.config.nitpick_ignore_regex:
|
||||
if re.fullmatch(ignore_type, entry_type) and \
|
||||
re.fullmatch(ignore_target, entry_target):
|
||||
return True
|
||||
return False
|
||||
if matches_ignore(dtype, target):
|
||||
warn = False
|
||||
# for "std" types also try without domain name
|
||||
if (not domain or domain.name == 'std') and \
|
||||
matches_ignore(typ, target):
|
||||
warn = False
|
||||
if not warn:
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user