diff options
| author | ruro <ruro.ruro@ya.ru> | 2021-04-24 02:13:20 +0300 |
|---|---|---|
| committer | ruro <ruro.ruro@ya.ru> | 2021-05-02 13:31:13 +0300 |
| commit | 00bc3465b3a7a68b7e59cb9cccfb2a91c3afced7 (patch) | |
| tree | a3b1bea427f4a7a927dc9b7744746ea679ba99a5 /sphinx/transforms/post_transforms | |
| parent | 9e1b4a8f1678e26670d34765e74edf3a3be3c62c (diff) | |
| download | sphinx-git-00bc3465b3a7a68b7e59cb9cccfb2a91c3afced7.tar.gz | |
implement nitpick_ignore_regex
Diffstat (limited to 'sphinx/transforms/post_transforms')
| -rw-r--r-- | sphinx/transforms/post_transforms/__init__.py | 16 |
1 files changed, 15 insertions, 1 deletions
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 |
