diff --git a/gapic/ads-templates/docs/conf.py.j2 b/gapic/ads-templates/docs/conf.py.j2 index dcce591ca3..082da22742 100644 --- a/gapic/ads-templates/docs/conf.py.j2 +++ b/gapic/ads-templates/docs/conf.py.j2 @@ -1,6 +1,7 @@ {% extends '_base.py.j2' %} {% block content %} +{% from "gapic/templates/docs/common_setup.py.j2" import sphinx_imports, sphinx_setup %} # # {{ api.naming.warehouse_package_name }} documentation build configuration file @@ -17,6 +18,7 @@ import sys import os import shlex +{{ sphinx_imports() }} # 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 +363,6 @@ napoleon_use_admonition_for_references = False napoleon_use_ivar = False napoleon_use_param = True napoleon_use_rtype = True + +{{ sphinx_setup() }} {% endblock %} diff --git a/gapic/templates/docs/common_setup.py.j2 b/gapic/templates/docs/common_setup.py.j2 new file mode 100644 index 0000000000..aa88878dc7 --- /dev/null +++ b/gapic/templates/docs/common_setup.py.j2 @@ -0,0 +1,35 @@ +{% macro sphinx_imports() -%} +import logging +from typing import Any +{%- endmacro %} + +{% macro sphinx_setup() -%} +class UnexpectedUnindentFilter(logging.Filter): + """Filter out warnings about unexpected unindentation following bullet lists.""" + + def filter(self, record: logging.LogRecord) -> bool: + """Filter the log record. + + Args: + record (logging.LogRecord): The log record. + + Returns: + bool: 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 + + +def setup(app: Any) -> None: + """Setup the Sphinx application. + + Args: + app (Any): The Sphinx application. + """ + # 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()) +{%- endmacro %} diff --git a/gapic/templates/docs/conf.py.j2 b/gapic/templates/docs/conf.py.j2 index b509706ab6..4513ed3439 100644 --- a/gapic/templates/docs/conf.py.j2 +++ b/gapic/templates/docs/conf.py.j2 @@ -1,6 +1,7 @@ {% extends '_base.py.j2' %} {% block content %} +{% from "docs/common_setup.py.j2" import sphinx_imports, sphinx_setup %} # # {{ api.naming.warehouse_package_name }} documentation build configuration file @@ -17,6 +18,7 @@ import sys import os import shlex +{{ sphinx_imports() }} # 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 +374,6 @@ napoleon_use_admonition_for_references = False napoleon_use_ivar = False napoleon_use_param = True napoleon_use_rtype = True + +{{ sphinx_setup() }} {% endblock %}