diff options
author | Mark Daoust <markdaoust@google.com> | 2018-08-22 11:16:15 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-22 11:19:29 -0700 |
commit | 34544d1d6085a42bead8181f69ae28fb389ff09e (patch) | |
tree | cc927cba240ac72fc695de46597cccc0803b6985 | |
parent | 7f3580dbbc99185be01b19265ba576d58df0ac25 (diff) |
Don't generate empty _redirects.yaml files.
PiperOrigin-RevId: 209796931
-rw-r--r-- | tensorflow/tools/docs/generate_lib.py | 17 |
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 |