Skip to content

Commit a29a4bf

Browse files
build: update docs build (#2339)
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8a705c5 commit a29a4bf

File tree

11 files changed

+99
-43
lines changed

11 files changed

+99
-43
lines changed

.github/workflows/tests.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ jobs:
3333
run: python -m pip install nox
3434
- name: Build the documentation.
3535
run: nox -s docs
36+
docfx:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Set up Python
41+
uses: actions/setup-python@v5
42+
# Use python 3.10 for docs to match the version for the sphinx plugin
43+
# https://github.com/googleapis/synthtool/pull/1891
44+
with:
45+
python-version: "3.10"
46+
cache: 'pip'
47+
- name: Install nox.
48+
run: python -m pip install nox
49+
- name: Build the documentation.
50+
run: nox -s docfx
3651
mypy:
3752
strategy:
3853
matrix:

gapic/templates/noxfile.py.j2

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,9 @@ def docs(session):
370370
"-W", # warnings as errors
371371
"-T", # show full traceback on exception
372372
"-N", # no colors
373-
"-b",
374-
"html",
375-
"-d",
376-
os.path.join("docs", "_build", "doctrees", ""),
373+
"-b", "html", # builder
374+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
375+
# paths to build:
377376
os.path.join("docs", ""),
378377
os.path.join("docs", "_build", "html", ""),
379378
)

noxfile.py

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ def snippetgen(session):
630630

631631
@nox.session(python="3.10")
632632
def docs(session):
633-
"""Build the docs."""
633+
"""Build the docs for this generator."""
634+
635+
session.install("-e", ".")
634636

635637
session.install(
636638
# We need to pin to specific versions of the `sphinxcontrib-*` packages
@@ -643,21 +645,68 @@ def docs(session):
643645
"sphinxcontrib-qthelp==1.0.3",
644646
"sphinxcontrib-serializinghtml==1.1.5",
645647
"sphinx==4.5.0",
646-
"sphinx_rtd_theme",
648+
"sphinx-rtd-theme",
649+
)
650+
651+
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
652+
session.run(
653+
"sphinx-build",
654+
"-W", # warnings as errors
655+
"-T", # show full traceback on exception
656+
"-N", # no colors
657+
"-b",
658+
"html", # builder
659+
"-d",
660+
os.path.join("docs", "_build", "doctrees", ""), # cache directory
661+
# paths to build:
662+
os.path.join("docs", ""),
663+
os.path.join("docs", "_build", "html", ""),
664+
)
665+
666+
667+
@nox.session(python="3.10")
668+
def docfx(session):
669+
"""Build the docfx yaml files for this library."""
670+
671+
session.install("-e", ".")
672+
session.install(
673+
# We need to pin to specific versions of the `sphinxcontrib-*` packages
674+
# which still support sphinx 4.x.
675+
# See https://github.com/googleapis/sphinx-docfx-yaml/issues/344
676+
# and https://github.com/googleapis/sphinx-docfx-yaml/issues/345.
677+
"sphinxcontrib-applehelp==1.0.4",
678+
"sphinxcontrib-devhelp==1.0.2",
679+
"sphinxcontrib-htmlhelp==2.0.1",
680+
"sphinxcontrib-qthelp==1.0.3",
681+
"sphinxcontrib-serializinghtml==1.1.5",
682+
"gcp-sphinx-docfx-yaml",
683+
"sphinx-rtd-theme",
647684
)
648-
session.install(".")
649685

650-
# Build the docs!
651-
session.run("rm", "-rf", "docs/_build/")
686+
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
652687
session.run(
653688
"sphinx-build",
654-
"-W",
689+
"-T", # show full traceback on exception
690+
"-N", # no colors
691+
"-D", # Override configuration values set in the conf.py file
692+
(
693+
"extensions=sphinx.ext.autodoc,"
694+
"sphinx.ext.autosummary,"
695+
"docfx_yaml.extension,"
696+
"sphinx.ext.intersphinx,"
697+
"sphinx.ext.coverage,"
698+
"sphinx.ext.napoleon,"
699+
"sphinx.ext.todo,"
700+
"sphinx.ext.viewcode,"
701+
"recommonmark"
702+
),
655703
"-b",
656-
"html",
704+
"html", # builder
657705
"-d",
658-
"docs/_build/doctrees",
659-
"docs/",
660-
"docs/_build/html/",
706+
os.path.join("docs", "_build", "doctrees", ""), # cache directory
707+
# paths to build:
708+
os.path.join("docs", ""),
709+
os.path.join("docs", "_build", "html", ""),
661710
)
662711

663712

owlbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
templated_files = CommonTemplates().py_library()
1919
s.move(
2020
templated_files / ".kokoro",
21-
excludes=["samples/**/*", "test-samples*", "publish-docs.sh", "*/prerelease-deps.cfg"],
21+
excludes=["samples/**/*", "test-samples*", "*/prerelease-deps.cfg"],
2222
)
2323

2424
# needed for docs build

tests/integration/goldens/asset/noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def docs(session):
364364
"-W", # warnings as errors
365365
"-T", # show full traceback on exception
366366
"-N", # no colors
367-
"-b",
368-
"html",
369-
"-d",
370-
os.path.join("docs", "_build", "doctrees", ""),
367+
"-b", "html", # builder
368+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
369+
# paths to build:
371370
os.path.join("docs", ""),
372371
os.path.join("docs", "_build", "html", ""),
373372
)

tests/integration/goldens/credentials/noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def docs(session):
364364
"-W", # warnings as errors
365365
"-T", # show full traceback on exception
366366
"-N", # no colors
367-
"-b",
368-
"html",
369-
"-d",
370-
os.path.join("docs", "_build", "doctrees", ""),
367+
"-b", "html", # builder
368+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
369+
# paths to build:
371370
os.path.join("docs", ""),
372371
os.path.join("docs", "_build", "html", ""),
373372
)

tests/integration/goldens/eventarc/noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def docs(session):
364364
"-W", # warnings as errors
365365
"-T", # show full traceback on exception
366366
"-N", # no colors
367-
"-b",
368-
"html",
369-
"-d",
370-
os.path.join("docs", "_build", "doctrees", ""),
367+
"-b", "html", # builder
368+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
369+
# paths to build:
371370
os.path.join("docs", ""),
372371
os.path.join("docs", "_build", "html", ""),
373372
)

tests/integration/goldens/logging/noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def docs(session):
364364
"-W", # warnings as errors
365365
"-T", # show full traceback on exception
366366
"-N", # no colors
367-
"-b",
368-
"html",
369-
"-d",
370-
os.path.join("docs", "_build", "doctrees", ""),
367+
"-b", "html", # builder
368+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
369+
# paths to build:
371370
os.path.join("docs", ""),
372371
os.path.join("docs", "_build", "html", ""),
373372
)

tests/integration/goldens/logging_internal/noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def docs(session):
364364
"-W", # warnings as errors
365365
"-T", # show full traceback on exception
366366
"-N", # no colors
367-
"-b",
368-
"html",
369-
"-d",
370-
os.path.join("docs", "_build", "doctrees", ""),
367+
"-b", "html", # builder
368+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
369+
# paths to build:
371370
os.path.join("docs", ""),
372371
os.path.join("docs", "_build", "html", ""),
373372
)

tests/integration/goldens/redis/noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@ def docs(session):
364364
"-W", # warnings as errors
365365
"-T", # show full traceback on exception
366366
"-N", # no colors
367-
"-b",
368-
"html",
369-
"-d",
370-
os.path.join("docs", "_build", "doctrees", ""),
367+
"-b", "html", # builder
368+
"-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory
369+
# paths to build:
371370
os.path.join("docs", ""),
372371
os.path.join("docs", "_build", "html", ""),
373372
)

0 commit comments

Comments
 (0)