Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorruro <ruro.ruro@ya.ru>2021-04-24 02:13:20 +0300
committerruro <ruro.ruro@ya.ru>2021-05-02 13:31:13 +0300
commit00bc3465b3a7a68b7e59cb9cccfb2a91c3afced7 (patch)
treea3b1bea427f4a7a927dc9b7744746ea679ba99a5 /sphinx
parent9e1b4a8f1678e26670d34765e74edf3a3be3c62c (diff)
implement nitpick_ignore_regex
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/config.py1
-rw-r--r--sphinx/transforms/post_transforms/__init__.py16
2 files changed, 16 insertions, 1 deletions
diff --git a/sphinx/config.py b/sphinx/config.py
index a9fdddc8a..9a968aedf 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -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()
diff --git a/sphinx/transforms/post_transforms/__init__.py b/sphinx/transforms/post_transforms/__init__.py
index e2899d994..281407983 100644
--- a/sphinx/transforms/post_transforms/__init__.py
+++ b/sphinx/transforms/post_transforms/__init__.py
@@ -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