aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tools/docs
diff options
context:
space:
mode:
authorGravatar Mark Daoust <markdaoust@google.com>2017-11-07 06:31:00 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-11-07 06:35:20 -0800
commitd71abc570b15451232bf7582c9173c56651aed1b (patch)
treeb37ca5a0f13c2c6692732c8bd35dba8616345ce1 /tensorflow/tools/docs
parente07ce40153871321361d7adaeabe4b83a739424f (diff)
Use nesting to reduce the number of modules listed in the API TOC.
PiperOrigin-RevId: 174846842
Diffstat (limited to 'tensorflow/tools/docs')
-rw-r--r--tensorflow/tools/docs/generate_lib.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py
index 9b8b50f9cd..c0cde1d3bd 100644
--- a/tensorflow/tools/docs/generate_lib.py
+++ b/tensorflow/tools/docs/generate_lib.py
@@ -152,19 +152,36 @@ def write_docs(output_dir, parser_config, yaml_toc, root_title='TensorFlow'):
# Generate header
f.write('# Automatically generated file; please do not edit\ntoc:\n')
for module in modules:
- f.write(' - title: ' + module + '\n'
- ' section:\n' + ' - title: Overview\n' +
- ' path: /TARGET_DOC_ROOT/VERSION/' + symbol_to_file[module]
- + '\n')
+ indent_num = module.count('.')
+ # Don't list `tf.submodule` inside `tf`
+ indent_num = max(indent_num, 1)
+ indent = ' '*indent_num
+
+ if indent_num > 1:
+ # tf.contrib.baysflow.entropy will be under
+ # tf.contrib->baysflow->entropy
+ title = module.split('.')[-1]
+ else:
+ title = module
+
+ header = [
+ '- title: ' + title,
+ ' section:',
+ ' - title: Overview',
+ ' path: /TARGET_DOC_ROOT/VERSION/' + symbol_to_file[module]]
+ header = ''.join([indent+line+'\n' for line in header])
+ f.write(header)
symbols_in_module = module_children.get(module, [])
# Sort case-insensitive, if equal sort case sensitive (upper first)
symbols_in_module.sort(key=lambda a: (a.upper(), a))
for full_name in symbols_in_module:
- f.write(' - title: ' + full_name[len(module) + 1:] + '\n'
- ' path: /TARGET_DOC_ROOT/VERSION/' +
- symbol_to_file[full_name] + '\n')
+ item = [
+ ' - title: ' + full_name[len(module) + 1:],
+ ' path: /TARGET_DOC_ROOT/VERSION/' + symbol_to_file[full_name]]
+ item = ''.join([indent+line+'\n' for line in item])
+ f.write(item)
# Write a global index containing all full names with links.
with open(os.path.join(output_dir, 'index.md'), 'w') as f: