-
Notifications
You must be signed in to change notification settings - Fork 77
fix: filter sphinx warnings related to adding a new line after lists #2533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,10 @@ | |
| # All configuration values have a default; values that are commented out | ||
| # serve to show the default. | ||
|
|
||
| import sys | ||
| import logging | ||
| import os | ||
| import shlex | ||
| import sys | ||
|
|
||
| # If extensions (or modules to document with autodoc) are in another directory, | ||
| # add these directories to sys.path here. If the directory is relative to the | ||
|
|
@@ -361,4 +362,21 @@ napoleon_use_admonition_for_references = False | |
| napoleon_use_ivar = False | ||
| napoleon_use_param = True | ||
| napoleon_use_rtype = True | ||
|
|
||
| # --- Specific warning filters not covered by suppress_warnings --- | ||
|
|
||
| class UnexpectedUnindentFilter(logging.Filter): | ||
| """Filter out warnings about unexpected unindentation following bullet lists.""" | ||
| def filter(self, record): | ||
| # Return False to suppress the warning, True to allow it | ||
| msg = record.getMessage() | ||
| if "Bullet list ends without a blank line" in msg: | ||
| return False | ||
| return True | ||
|
Comment on lines
+368
to
+375
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we include this (and the setup function below) in a separate file as a macro and use it in both templates and ad-templates? I'm guessing we'll keep introducing new code for each warning as per this pattern and it'll be easier to maintain code if it's one place. |
||
|
|
||
| def setup(app): | ||
| # Sphinx's logger is hierarchical. Adding a filter to the | ||
| # root 'sphinx' logger will catch warnings from all sub-loggers. | ||
| logger = logging.getLogger('sphinx') | ||
| logger.addFilter(UnexpectedUnindentFilter()) | ||
| {% endblock %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,10 @@ | |
| # All configuration values have a default; values that are commented out | ||
| # serve to show the default. | ||
|
|
||
| import sys | ||
| import logging | ||
| import os | ||
| import shlex | ||
| import sys | ||
|
|
||
| # If extensions (or modules to document with autodoc) are in another directory, | ||
| # add these directories to sys.path here. If the directory is relative to the | ||
|
|
@@ -372,4 +373,21 @@ napoleon_use_admonition_for_references = False | |
| napoleon_use_ivar = False | ||
| napoleon_use_param = True | ||
| napoleon_use_rtype = True | ||
|
|
||
| # --- Specific warning filters not covered by suppress_warnings --- | ||
|
|
||
| class UnexpectedUnindentFilter(logging.Filter): | ||
| """Filter out warnings about unexpected unindentation following bullet lists.""" | ||
| def filter(self, record): | ||
| # Return False to suppress the warning, True to allow it | ||
| msg = record.getMessage() | ||
| if "Bullet list ends without a blank line" in msg: | ||
| return False | ||
| return True | ||
|
Comment on lines
+383
to
+386
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| def setup(app): | ||
| # Sphinx's logger is hierarchical. Adding a filter to the | ||
| # root 'sphinx' logger will catch warnings from all sub-loggers. | ||
| logger = logging.getLogger('sphinx') | ||
| logger.addFilter(UnexpectedUnindentFilter()) | ||
| {% endblock %} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For conciseness, the logic in the
filtermethod can be simplified to a singlereturnstatement.