aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tools/docs
diff options
context:
space:
mode:
authorGravatar Mark Daoust <markdaoust@google.com>2018-08-22 11:16:15 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-22 11:19:29 -0700
commit34544d1d6085a42bead8181f69ae28fb389ff09e (patch)
treecc927cba240ac72fc695de46597cccc0803b6985 /tensorflow/tools/docs
parent7f3580dbbc99185be01b19265ba576d58df0ac25 (diff)
Don't generate empty _redirects.yaml files.
PiperOrigin-RevId: 209796931
Diffstat (limited to 'tensorflow/tools/docs')
-rw-r--r--tensorflow/tools/docs/generate_lib.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py
index 653e46fc41..090cf48a07 100644
--- a/tensorflow/tools/docs/generate_lib.py
+++ b/tensorflow/tools/docs/generate_lib.py
@@ -171,14 +171,15 @@ def write_docs(output_dir,
os.path.join('/', from_path),
os.path.join('/', to_path)))
- redirects = sorted(redirects)
- template = ('- from: {}\n'
- ' to: {}\n')
- redirects = [template.format(f, t) for f, t in redirects]
- api_redirects_path = os.path.join(output_dir, '_redirects.yaml')
- with open(api_redirects_path, 'w') as redirect_file:
- redirect_file.write('redirects:\n')
- redirect_file.write(''.join(redirects))
+ if redirects:
+ redirects = sorted(redirects)
+ template = ('- from: {}\n'
+ ' to: {}\n')
+ redirects = [template.format(f, t) for f, t in redirects]
+ api_redirects_path = os.path.join(output_dir, '_redirects.yaml')
+ with open(api_redirects_path, 'w') as redirect_file:
+ redirect_file.write('redirects:\n')
+ redirect_file.write(''.join(redirects))
if yaml_toc:
# Generate table of contents