Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 3146a63

Browse files
committed
updates conf.py.j2 templates and adds content to common_setup.py.j2
1 parent df9df95 commit 3146a63

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{% macro sphinx_imports() -%}
2+
import logging
3+
from typing import Any
4+
{%- endmacro %}
5+
6+
{% macro sphinx_setup() -%}
7+
class UnexpectedUnindentFilter(logging.Filter):
8+
"""Filter out warnings about unexpected unindentation following bullet lists."""
9+
10+
def filter(self, record: logging.LogRecord) -> bool:
11+
"""Filter the log record.
12+
13+
Args:
14+
record (logging.LogRecord): The log record.
15+
16+
Returns:
17+
bool: False to suppress the warning, True to allow it.
18+
"""
19+
msg = record.getMessage()
20+
if "Bullet list ends without a blank line" in msg:
21+
return False
22+
return True
23+
24+
25+
def setup(app: Any) -> None:
26+
"""Setup the Sphinx application.
27+
28+
Args:
29+
app (Any): The Sphinx application.
30+
"""
31+
# Sphinx's logger is hierarchical. Adding a filter to the
32+
# root 'sphinx' logger will catch warnings from all sub-loggers.
33+
logger = logging.getLogger('sphinx')
34+
logger.addFilter(UnexpectedUnindentFilter())
35+
{%- endmacro %}

gapic/templates/docs/conf.py.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,5 +375,6 @@ napoleon_use_ivar = False
375375
napoleon_use_param = True
376376
napoleon_use_rtype = True
377377

378+
# Setup for sphinx behaviors such as warning filters.
378379
{{ sphinx_setup() }}
379380
{% endblock %}

0 commit comments

Comments
 (0)