forked from Pycord-Development/pycord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly ignore legacy file reference errors in sphinx -n mode
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import logging | ||
|
||
from sphinx.application import Sphinx | ||
from sphinx.util import logging as sphinx_logging | ||
|
||
|
||
class NitpickFileIgnorer(logging.Filter): | ||
|
||
def __init__(self, app: Sphinx) -> None: | ||
self.app = app | ||
super().__init__() | ||
|
||
def filter(self, record: sphinx_logging.SphinxLogRecord) -> bool: | ||
if getattr(record, 'type', None) == 'ref': | ||
return record.location.get('refdoc') not in self.app.config.nitpick_ignore_files | ||
return True | ||
|
||
|
||
def setup(app: Sphinx): | ||
app.add_config_value('nitpick_ignore_files', [], '') | ||
f = NitpickFileIgnorer(app) | ||
sphinx_logging.getLogger('sphinx.transforms.post_transforms').logger.addFilter(f) |