MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / generate_global_index

Function generate_global_index

tensorflow/tools/docs/parser.py:1702–1737  ·  view source on GitHub ↗

Given a dict of full names to python objects, generate an index page. The index page generated contains a list of links for all symbols in `index` that have their own documentation page. Args: library_name: The name for the documented library to use in the title. index: A dict mappin

(library_name, index, reference_resolver)

Source from the content-addressed store, hash-verified

1700
1701# TODO(markdaoust): This should just parse, pretty_docs should generate the md.
1702def generate_global_index(library_name, index, reference_resolver):
1703 """Given a dict of full names to python objects, generate an index page.
1704
1705 The index page generated contains a list of links for all symbols in `index`
1706 that have their own documentation page.
1707
1708 Args:
1709 library_name: The name for the documented library to use in the title.
1710 index: A dict mapping full names to python objects.
1711 reference_resolver: An instance of ReferenceResolver.
1712
1713 Returns:
1714 A string containing an index page as Markdown.
1715 """
1716 symbol_links = []
1717 for full_name, py_object in six.iteritems(index):
1718 if (tf_inspect.ismodule(py_object) or tf_inspect.isfunction(py_object) or
1719 tf_inspect.isclass(py_object)):
1720 # In Python 3, unbound methods are functions, so eliminate those.
1721 if tf_inspect.isfunction(py_object):
1722 if full_name.count('.') == 0:
1723 parent_name = ''
1724 else:
1725 parent_name = full_name[:full_name.rfind('.')]
1726 if parent_name in index and tf_inspect.isclass(index[parent_name]):
1727 # Skip methods (=functions with class parents).
1728 continue
1729 symbol_links.append((
1730 full_name, reference_resolver.python_link(full_name, full_name, '.')))
1731
1732 lines = ['# All symbols in %s' % library_name, '']
1733 for _, link in sorted(symbol_links, key=lambda x: x[0]):
1734 lines.append('* %s' % link)
1735
1736 # TODO(markdaoust): use a _ModulePageInfo -> prety_docs.build_md_page()
1737 return '\n'.join(lines)
1738
1739
1740class _Metadata(object):

Callers

nothing calls this directly

Calls 4

python_linkMethod · 0.80
countMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected