Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions gapic/ads-templates/docs/common_setup.py.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Copy link
Contributor Author

@chalmerlowe chalmerlowe Jan 29, 2026

Choose a reason for hiding this comment

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

NOTE to the reviewer:

Why duplicate the content in ads-templates/docs/common_setup.py.j2 and in templates/docs/common_setup.py.j2 as opposed to having a single source of truth?

My understanding is that "for reasons" we isolate the content in ads-templates from templates. Until that stance is revised, my understanding is that by and large much of the content needs to be duplicated.

Related to:

Resolving this issue is out of scope for this PR.

8 changes: 7 additions & 1 deletion gapic/ads-templates/docs/conf.py.j2
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,9 +15,11 @@
# 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
{{ 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
Expand Down Expand Up @@ -361,4 +364,7 @@ napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True

# Setup for sphinx behaviors such as warning filters.
{{ sphinx_setup() }}
{% endblock %}
35 changes: 35 additions & 0 deletions gapic/templates/docs/common_setup.py.j2
Original file line number Diff line number Diff line change
@@ -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 %}
9 changes: 7 additions & 2 deletions gapic/templates/docs/conf.py.j2
Original file line number Diff line number Diff line change
@@ -1,7 +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
#
Expand All @@ -14,9 +14,11 @@
# 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
{{ 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
Expand Down Expand Up @@ -372,4 +374,7 @@ napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True

# Setup for sphinx behaviors such as warning filters.
{{ sphinx_setup() }}
{% endblock %}
38 changes: 35 additions & 3 deletions tests/integration/goldens/asset/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
##
# google-cloud-asset documentation build configuration file
#
# This file is execfile()d with the current directory set to its
Expand All @@ -25,9 +24,12 @@
# 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
import logging
from typing import Any

# 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 @@ -383,3 +385,33 @@
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True

# Setup for sphinx behaviors such as warning filters.
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())
38 changes: 35 additions & 3 deletions tests/integration/goldens/credentials/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
##
# google-iam-credentials documentation build configuration file
#
# This file is execfile()d with the current directory set to its
Expand All @@ -25,9 +24,12 @@
# 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
import logging
from typing import Any

# 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 @@ -383,3 +385,33 @@
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True

# Setup for sphinx behaviors such as warning filters.
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())
38 changes: 35 additions & 3 deletions tests/integration/goldens/eventarc/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
##
# google-cloud-eventarc documentation build configuration file
#
# This file is execfile()d with the current directory set to its
Expand All @@ -25,9 +24,12 @@
# 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
import logging
from typing import Any

# 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 @@ -383,3 +385,33 @@
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True

# Setup for sphinx behaviors such as warning filters.
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())
38 changes: 35 additions & 3 deletions tests/integration/goldens/logging/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
##
# google-cloud-logging documentation build configuration file
#
# This file is execfile()d with the current directory set to its
Expand All @@ -25,9 +24,12 @@
# 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
import logging
from typing import Any

# 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 @@ -383,3 +385,33 @@
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True

# Setup for sphinx behaviors such as warning filters.
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())
Loading
Loading