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

Commit c5b00ce

Browse files
Refactor Sphinx setup into a shared macro
- Created gapic/templates/docs/common_setup.py.j2 - Updated gapic/templates/docs/conf.py.j2 - Updated gapic/ads-templates/docs/conf.py.j2
1 parent b75b8f4 commit c5b00ce

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

gapic/ads-templates/docs/conf.py.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends '_base.py.j2' %}
22

33
{% block content %}
4+
{% from "docs/common_setup.py.j2" import sphinx_setup %}
45

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

gapic/templates/docs/conf.py.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends '_base.py.j2' %}
22

33
{% block content %}
4+
{% from "docs/common_setup.py.j2" import sphinx_setup %}
45

56
#
67
# {{ api.naming.warehouse_package_name }} documentation build configuration file
@@ -372,4 +373,6 @@ napoleon_use_admonition_for_references = False
372373
napoleon_use_ivar = False
373374
napoleon_use_param = True
374375
napoleon_use_rtype = True
376+
377+
{{ sphinx_setup() }}
375378
{% endblock %}

0 commit comments

Comments
 (0)