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

Commit 0e58b5a

Browse files
Refactor Sphinx setup with separated imports and setup macros
- Created gapic/templates/docs/common_setup.py.j2 with sphinx_imports and sphinx_setup macros - Updated gapic/templates/docs/conf.py.j2 to call imports at top and setup at bottom - Updated gapic/ads-templates/docs/conf.py.j2 similarly
1 parent c5b00ce commit 0e58b5a

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

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

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

33
{% block content %}
4-
{% from "docs/common_setup.py.j2" import sphinx_setup %}
4+
{% from "docs/common_setup.py.j2" import sphinx_imports, sphinx_setup %}
55

66
#
77
# {{ api.naming.warehouse_package_name }} documentation build configuration file
@@ -18,6 +18,7 @@
1818
import sys
1919
import os
2020
import shlex
21+
{{ sphinx_imports() }}
2122

2223
# If extensions (or modules to document with autodoc) are in another directory,
2324
# add these directories to sys.path here. If the directory is relative to the

gapic/templates/docs/common_setup.py.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
{% macro sphinx_setup() -%}
1+
{% macro sphinx_imports() -%}
22
import logging
33
from typing import Any
4+
{%- endmacro %}
45

6+
{% macro sphinx_setup() -%}
57
class UnexpectedUnindentFilter(logging.Filter):
68
"""Filter out warnings about unexpected unindentation following bullet lists."""
79

gapic/templates/docs/conf.py.j2

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

33
{% block content %}
4-
{% from "docs/common_setup.py.j2" import sphinx_setup %}
4+
{% from "docs/common_setup.py.j2" import sphinx_imports, sphinx_setup %}
55

66
#
77
# {{ api.naming.warehouse_package_name }} documentation build configuration file
@@ -18,6 +18,7 @@
1818
import sys
1919
import os
2020
import shlex
21+
{{ sphinx_imports() }}
2122

2223
# If extensions (or modules to document with autodoc) are in another directory,
2324
# add these directories to sys.path here. If the directory is relative to the

0 commit comments

Comments
 (0)