MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / docclass

Method docclass

tools/python-3.11.9-amd64/Lib/pydoc.py:1360–1512  ·  view source on GitHub ↗

Produce text documentation for a given class object.

(self, object, name=None, mod=None, *ignored)

Source from the content-addressed store, hash-verified

1358 return result
1359
1360 def docclass(self, object, name=None, mod=None, *ignored):
1361 """Produce text documentation for a given class object."""
1362 realname = object.__name__
1363 name = name or realname
1364 bases = object.__bases__
1365
1366 def makename(c, m=object.__module__):
1367 return classname(c, m)
1368
1369 if name == realname:
1370 title = 'class ' + self.bold(realname)
1371 else:
1372 title = self.bold(name) + ' = class ' + realname
1373 if bases:
1374 parents = map(makename, bases)
1375 title = title + '(%s)' % ', '.join(parents)
1376
1377 contents = []
1378 push = contents.append
1379
1380 try:
1381 signature = inspect.signature(object)
1382 except (ValueError, TypeError):
1383 signature = None
1384 if signature:
1385 argspec = str(signature)
1386 if argspec and argspec != '()':
1387 push(name + argspec + '\n')
1388
1389 doc = getdoc(object)
1390 if doc:
1391 push(doc + '\n')
1392
1393 # List the mro, if non-trivial.
1394 mro = deque(inspect.getmro(object))
1395 if len(mro) > 2:
1396 push("Method resolution order:")
1397 for base in mro:
1398 push(' ' + makename(base))
1399 push('')
1400
1401 # List the built-in subclasses, if any:
1402 subclasses = sorted(
1403 (str(cls.__name__) for cls in type.__subclasses__(object)
1404 if not cls.__name__.startswith("_") and cls.__module__ == "builtins"),
1405 key=str.lower
1406 )
1407 no_of_subclasses = len(subclasses)
1408 MAX_SUBCLASSES_TO_DISPLAY = 4
1409 if subclasses:
1410 push("Built-in subclasses:")
1411 for subclassname in subclasses[:MAX_SUBCLASSES_TO_DISPLAY]:
1412 push(' ' + subclassname)
1413 if no_of_subclasses > MAX_SUBCLASSES_TO_DISPLAY:
1414 push(' ... and ' +
1415 str(no_of_subclasses - MAX_SUBCLASSES_TO_DISPLAY) +
1416 ' other subclasses')
1417 push('')

Callers

nothing calls this directly

Calls 15

boldMethod · 0.95
indentMethod · 0.95
strFunction · 0.85
dequeFunction · 0.85
sortedFunction · 0.85
visiblenameFunction · 0.85
_split_listFunction · 0.85
classnameFunction · 0.85
sort_attributesFunction · 0.85
signatureMethod · 0.80
startswithMethod · 0.80
getdocFunction · 0.70

Tested by

no test coverage detected