Skip to content

Commit db2019a

Browse files
authored
Docs: debug broken docs build (googleapis#6007)
- Run docs build during nox w/ better debug output. - Fix loop boundary bug in copying static HTML files. - Log each file copied. - Don't copy static HTML files on failed builds. The destination directory might not be present.
1 parent 3ec4a7f commit db2019a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

docs/conf.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
import pkg_resources
2929
import shutil
3030

31+
from sphinx.util import logging
32+
33+
logger = logging.getLogger(__name__)
34+
3135
# If extensions (or modules to document with autodoc) are in another directory,
3236
# add these directories to sys.path here. If the directory is relative to the
3337
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -325,18 +329,20 @@
325329
# See: https://tech.signavio.com/2017/managing-sphinx-redirects
326330
# HTML pages to be copied from source to target
327331
static_html_pages = [
328-
'datastore.usage.html',
332+
'datastore/usage.html',
329333
'bigquery/usage.html',
330334
'spanner/usage.html',
331335
]
332336

333-
def copy_static_html_pages(app, docname):
334-
if app.builder.name == 'html':
337+
def copy_static_html_pages(app, exception):
338+
if exception is None and app.builder.name == 'html':
335339
for static_html_page in static_html_pages:
336340
target_path = app.outdir + '/' + static_html_page
337341
src_path = app.srcdir + '/' + static_html_page
338-
if os.path.isfile(src_path):
339-
shutil.copyfile(src_path, target_path)
342+
if os.path.isfile(src_path):
343+
logger.info(
344+
'Copying static html: %s -> %s', src_path, target_path)
345+
shutil.copyfile(src_path, target_path)
340346

341347
def setup(app):
342348
app.connect('build-finished', copy_static_html_pages)

test_utils/scripts/update_docs.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2525
function build_docs {
2626
rm -rf docs/_build/
2727
rm -rf docs/bigquery/generated
28-
sphinx-build -W -b html -d docs/_build/doctrees docs/ docs/_build/html/
28+
# -W -> warnings as errors
29+
# -T -> show full traceback on exception
30+
# -N -> no color
31+
sphinx-build \
32+
-W -T -N \
33+
-b html \
34+
-d docs/_build/doctrees \
35+
docs/ \
36+
docs/_build/html/
2937
return $?
3038
}
3139

0 commit comments

Comments
 (0)