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

Method collect_docs_for_class

tensorflow/tools/docs/parser.py:1196–1302  ·  view source on GitHub ↗

Collects information necessary specifically for a class's doc page. Mainly, this is details about the class's members. Args: py_class: The class object being documented parser_config: An instance of ParserConfig.

(self, py_class, parser_config)

Source from the content-addressed store, hash-verified

1194 self._other_members.append(other_member_info)
1195
1196 def collect_docs_for_class(self, py_class, parser_config):
1197 """Collects information necessary specifically for a class's doc page.
1198
1199 Mainly, this is details about the class's members.
1200
1201 Args:
1202 py_class: The class object being documented
1203 parser_config: An instance of ParserConfig.
1204 """
1205 self.set_namedtuplefields(py_class)
1206 doc_path = documentation_path(self.full_name)
1207 relative_path = os.path.relpath(
1208 path='.', start=os.path.dirname(doc_path) or '.')
1209
1210 self._set_bases(relative_path, parser_config)
1211
1212 for short_name in parser_config.tree[self.full_name]:
1213 # Remove builtin members that we never want to document.
1214 if short_name in [
1215 '__class__', '__base__', '__weakref__', '__doc__', '__module__',
1216 '__dict__', '__abstractmethods__', '__slots__', '__getnewargs__',
1217 '__str__', '__repr__', '__hash__', '__reduce__'
1218 ]:
1219 continue
1220
1221 child_name = '.'.join([self.full_name, short_name])
1222 child = parser_config.py_name_to_object(child_name)
1223
1224 # Don't document anything that is defined in object or by protobuf.
1225 defining_class = _get_defining_class(py_class, short_name)
1226 if defining_class in [object, type, tuple, BaseException, Exception]:
1227 continue
1228
1229 # The following condition excludes most protobuf-defined symbols.
1230 if (defining_class and
1231 defining_class.__name__ in ['CMessage', 'Message', 'MessageMeta']):
1232 continue
1233 # TODO(markdaoust): Add a note in child docs showing the defining class.
1234
1235 if doc_controls.should_skip_class_attr(py_class, short_name):
1236 continue
1237
1238 child_doc = _parse_md_docstring(child, relative_path,
1239 parser_config.reference_resolver)
1240
1241 if isinstance(child, property):
1242 self._add_property(short_name, child_name, child, child_doc)
1243
1244 elif tf_inspect.isclass(child):
1245 if defining_class is None:
1246 continue
1247 url = parser_config.reference_resolver.reference_to_url(
1248 child_name, relative_path)
1249 self._add_class(short_name, child_name, child, child_doc, url)
1250
1251 elif (tf_inspect.ismethod(child) or tf_inspect.isfunction(child) or
1252 tf_inspect.isroutine(child)):
1253 if defining_class is None:

Callers 1

docs_for_objectFunction · 0.80

Calls 15

set_namedtuplefieldsMethod · 0.95
_set_basesMethod · 0.95
_add_propertyMethod · 0.95
_add_classMethod · 0.95
_add_methodMethod · 0.95
_add_other_memberMethod · 0.95
documentation_pathFunction · 0.85
_get_defining_classFunction · 0.85
_parse_md_docstringFunction · 0.85
_generate_signatureFunction · 0.85
py_name_to_objectMethod · 0.80
reference_to_urlMethod · 0.80

Tested by

no test coverage detected