diff options
author | Mark Daoust <markdaoust@google.com> | 2018-08-14 16:03:21 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-14 16:07:29 -0700 |
commit | 80675af4d86f3edf87a909ce36f548b36bab84a3 (patch) | |
tree | db9b91a689b1019ef32e5c4fd5715e2435501c28 /tensorflow/tools/docs | |
parent | 513b1441b406572bf6435a3af28803d8c00217ec (diff) |
Sort the redirects list so the output is consistent from run to run.
PiperOrigin-RevId: 208731275
Diffstat (limited to 'tensorflow/tools/docs')
-rw-r--r-- | tensorflow/tools/docs/generate_lib.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py index b9c418db1e..9387042224 100644 --- a/tensorflow/tools/docs/generate_lib.py +++ b/tensorflow/tools/docs/generate_lib.py @@ -97,7 +97,7 @@ def write_docs(output_dir, symbol_to_file = {} # Collect redirects for an api _redirects.yaml file. - redirects = ['redirects:\n'] + redirects = [] # Parse and write Markdown pages, resolving cross-links (@{symbol}). for full_name, py_object in six.iteritems(parser_config.index): @@ -166,17 +166,20 @@ def write_docs(output_dir, continue duplicates = [item for item in duplicates if item != full_name] - template = ('- from: /{}\n' - ' to: /{}\n') + for dup in duplicates: from_path = os.path.join(site_api_path, dup.replace('.', '/')) to_path = os.path.join(site_api_path, full_name.replace('.', '/')) - redirects.append( - template.format(from_path, to_path)) + redirects.append((from_path, to_path)) - if site_api_path: + if site_api_path and 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: |