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

Function docs_for_object

tensorflow/tools/docs/parser.py:1492–1558  ·  view source on GitHub ↗

Return a PageInfo object describing a given object from the TF API. This function uses _parse_md_docstring to parse the docs pertaining to `object`. This function resolves '@{symbol}' references in the docstrings into links to the appropriate location. It also adds a list of alternative na

(full_name, py_object, parser_config)

Source from the content-addressed store, hash-verified

1490
1491
1492def docs_for_object(full_name, py_object, parser_config):
1493 """Return a PageInfo object describing a given object from the TF API.
1494
1495 This function uses _parse_md_docstring to parse the docs pertaining to
1496 `object`.
1497
1498 This function resolves '@{symbol}' references in the docstrings into links to
1499 the appropriate location. It also adds a list of alternative names for the
1500 symbol automatically.
1501
1502 It assumes that the docs for each object live in a file given by
1503 `documentation_path`, and that relative links to files within the
1504 documentation are resolvable.
1505
1506 Args:
1507 full_name: The fully qualified name of the symbol to be
1508 documented.
1509 py_object: The Python object to be documented. Its documentation is sourced
1510 from `py_object`'s docstring.
1511 parser_config: A ParserConfig object.
1512
1513 Returns:
1514 Either a `_FunctionPageInfo`, `_ClassPageInfo`, or a `_ModulePageInfo`
1515 depending on the type of the python object being documented.
1516
1517 Raises:
1518 RuntimeError: If an object is encountered for which we don't know how
1519 to make docs.
1520 """
1521
1522 # Which other aliases exist for the object referenced by full_name?
1523 master_name = parser_config.reference_resolver.py_master_name(full_name)
1524 duplicate_names = parser_config.duplicates.get(master_name, [full_name])
1525
1526 # TODO(wicke): Once other pieces are ready, enable this also for partials.
1527 if (tf_inspect.ismethod(py_object) or tf_inspect.isfunction(py_object) or
1528 # Some methods in classes from extensions come in as routines.
1529 tf_inspect.isroutine(py_object)):
1530 page_info = _FunctionPageInfo(master_name)
1531 page_info.set_signature(py_object, parser_config.reverse_index)
1532
1533 elif tf_inspect.isclass(py_object):
1534 page_info = _ClassPageInfo(master_name)
1535 page_info.collect_docs_for_class(py_object, parser_config)
1536
1537 elif tf_inspect.ismodule(py_object):
1538 page_info = _ModulePageInfo(master_name)
1539 page_info.collect_docs_for_module(parser_config)
1540
1541 else:
1542 raise RuntimeError('Cannot make docs for object %s: %r' % (full_name,
1543 py_object))
1544
1545 relative_path = os.path.relpath(
1546 path='.', start=os.path.dirname(documentation_path(full_name)) or '.')
1547
1548 page_info.set_doc(_parse_md_docstring(
1549 py_object, relative_path, parser_config.reference_resolver))

Callers

nothing calls this directly

Calls 15

_FunctionPageInfoClass · 0.85
_ClassPageInfoClass · 0.85
_ModulePageInfoClass · 0.85
documentation_pathFunction · 0.85
_parse_md_docstringFunction · 0.85
_get_guides_markdownFunction · 0.85
_get_defined_inFunction · 0.85
py_master_nameMethod · 0.80
set_signatureMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected