Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
20 changes: 19 additions & 1 deletion gapic/ads-templates/docs/conf.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For conciseness, the logic in the filter method can be simplified to a single return statement.

        return "Bullet list ends without a blank line" not in record.getMessage()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ohmayr please take a look. I attempted to incorporate your comments.


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 %}
20 changes: 19 additions & 1 deletion gapic/templates/docs/conf.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For conciseness, the logic in the filter method can be simplified to a single return statement.

        return "Bullet list ends without a blank line" not in record.getMessage()


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 %}
Loading