Skip to content

Commit cfd538e

Browse files
committed
Add Sphinx logic for managing static redirect files.
Add a redirect for BigQuery from 'usage.html' -> 'index.html'.
1 parent f73050e commit cfd538e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

bigquery/docs/usage.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="refresh" content="1; url=./index.html:" />
4+
<script>
5+
window.location.href = "./index.html"
6+
</script>
7+
</head>
8+
</html>

docs/conf.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import email
2727
import os
2828
import pkg_resources
29+
import shutil
2930

3031
# If extensions (or modules to document with autodoc) are in another directory,
3132
# add these directories to sys.path here. If the directory is relative to the
@@ -319,3 +320,21 @@
319320
'pandas': ('http://pandas.pydata.org/pandas-docs/stable/', None),
320321
'python': ('https://docs.python.org/3', None),
321322
}
323+
324+
# Static HTML pages, e.g. to support redirects
325+
# See: https://tech.signavio.com/2017/managing-sphinx-redirects
326+
# HTML pages to be copied from source to target
327+
static_html_pages = [
328+
'bigquery/usage.html',
329+
]
330+
331+
def copy_static_html_pages(app, docname):
332+
if app.builder.name == 'html':
333+
for static_html_page in static_html_pages:
334+
target_path = app.outdir + '/' + static_html_page
335+
src_path = app.srcdir + '/' + static_html_page
336+
if os.path.isfile(src_path):
337+
shutil.copyfile(src_path, target_path)
338+
339+
def setup(app):
340+
app.connect('build-finished', copy_static_html_pages)

0 commit comments

Comments
 (0)