Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python3....
File: pydoc.py
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
[500] Fix | Delete
<tr bgcolor="%s">
[501] Fix | Delete
<td colspan=3 valign=bottom>&nbsp;<br>
[502] Fix | Delete
<font color="%s" face="helvetica, arial">%s</font></td></tr>
[503] Fix | Delete
''' % (bgcol, fgcol, title)
[504] Fix | Delete
if prelude:
[505] Fix | Delete
result = result + '''
[506] Fix | Delete
<tr bgcolor="%s"><td rowspan=2>%s</td>
[507] Fix | Delete
<td colspan=2>%s</td></tr>
[508] Fix | Delete
<tr><td>%s</td>''' % (bgcol, marginalia, prelude, gap)
[509] Fix | Delete
else:
[510] Fix | Delete
result = result + '''
[511] Fix | Delete
<tr><td bgcolor="%s">%s</td><td>%s</td>''' % (bgcol, marginalia, gap)
[512] Fix | Delete
[513] Fix | Delete
return result + '\n<td width="100%%">%s</td></tr></table>' % contents
[514] Fix | Delete
[515] Fix | Delete
def bigsection(self, title, *args):
[516] Fix | Delete
"""Format a section with a big heading."""
[517] Fix | Delete
title = '<big><strong>%s</strong></big>' % title
[518] Fix | Delete
return self.section(title, *args)
[519] Fix | Delete
[520] Fix | Delete
def preformat(self, text):
[521] Fix | Delete
"""Format literal preformatted text."""
[522] Fix | Delete
text = self.escape(text.expandtabs())
[523] Fix | Delete
return replace(text, '\n\n', '\n \n', '\n\n', '\n \n',
[524] Fix | Delete
' ', '&nbsp;', '\n', '<br>\n')
[525] Fix | Delete
[526] Fix | Delete
def multicolumn(self, list, format, cols=4):
[527] Fix | Delete
"""Format a list of items into a multi-column list."""
[528] Fix | Delete
result = ''
[529] Fix | Delete
rows = (len(list)+cols-1)//cols
[530] Fix | Delete
for col in range(cols):
[531] Fix | Delete
result = result + '<td width="%d%%" valign=top>' % (100//cols)
[532] Fix | Delete
for i in range(rows*col, rows*col+rows):
[533] Fix | Delete
if i < len(list):
[534] Fix | Delete
result = result + format(list[i]) + '<br>\n'
[535] Fix | Delete
result = result + '</td>'
[536] Fix | Delete
return '<table width="100%%" summary="list"><tr>%s</tr></table>' % result
[537] Fix | Delete
[538] Fix | Delete
def grey(self, text): return '<font color="#909090">%s</font>' % text
[539] Fix | Delete
[540] Fix | Delete
def namelink(self, name, *dicts):
[541] Fix | Delete
"""Make a link for an identifier, given name-to-URL mappings."""
[542] Fix | Delete
for dict in dicts:
[543] Fix | Delete
if name in dict:
[544] Fix | Delete
return '<a href="%s">%s</a>' % (dict[name], name)
[545] Fix | Delete
return name
[546] Fix | Delete
[547] Fix | Delete
def classlink(self, object, modname):
[548] Fix | Delete
"""Make a link for a class."""
[549] Fix | Delete
name, module = object.__name__, sys.modules.get(object.__module__)
[550] Fix | Delete
if hasattr(module, name) and getattr(module, name) is object:
[551] Fix | Delete
return '<a href="%s.html#%s">%s</a>' % (
[552] Fix | Delete
module.__name__, name, classname(object, modname))
[553] Fix | Delete
return classname(object, modname)
[554] Fix | Delete
[555] Fix | Delete
def modulelink(self, object):
[556] Fix | Delete
"""Make a link for a module."""
[557] Fix | Delete
return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)
[558] Fix | Delete
[559] Fix | Delete
def modpkglink(self, modpkginfo):
[560] Fix | Delete
"""Make a link for a module or package to display in an index."""
[561] Fix | Delete
name, path, ispackage, shadowed = modpkginfo
[562] Fix | Delete
if shadowed:
[563] Fix | Delete
return self.grey(name)
[564] Fix | Delete
if path:
[565] Fix | Delete
url = '%s.%s.html' % (path, name)
[566] Fix | Delete
else:
[567] Fix | Delete
url = '%s.html' % name
[568] Fix | Delete
if ispackage:
[569] Fix | Delete
text = '<strong>%s</strong>&nbsp;(package)' % name
[570] Fix | Delete
else:
[571] Fix | Delete
text = name
[572] Fix | Delete
return '<a href="%s">%s</a>' % (url, text)
[573] Fix | Delete
[574] Fix | Delete
def filelink(self, url, path):
[575] Fix | Delete
"""Make a link to source file."""
[576] Fix | Delete
return '<a href="file:%s">%s</a>' % (url, path)
[577] Fix | Delete
[578] Fix | Delete
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
[579] Fix | Delete
"""Mark up some plain text, given a context of symbols to look for.
[580] Fix | Delete
Each context dictionary maps object names to anchor names."""
[581] Fix | Delete
escape = escape or self.escape
[582] Fix | Delete
results = []
[583] Fix | Delete
here = 0
[584] Fix | Delete
pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
[585] Fix | Delete
r'RFC[- ]?(\d+)|'
[586] Fix | Delete
r'PEP[- ]?(\d+)|'
[587] Fix | Delete
r'(self\.)?(\w+))')
[588] Fix | Delete
while True:
[589] Fix | Delete
match = pattern.search(text, here)
[590] Fix | Delete
if not match: break
[591] Fix | Delete
start, end = match.span()
[592] Fix | Delete
results.append(escape(text[here:start]))
[593] Fix | Delete
[594] Fix | Delete
all, scheme, rfc, pep, selfdot, name = match.groups()
[595] Fix | Delete
if scheme:
[596] Fix | Delete
url = escape(all).replace('"', '&quot;')
[597] Fix | Delete
results.append('<a href="%s">%s</a>' % (url, url))
[598] Fix | Delete
elif rfc:
[599] Fix | Delete
url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
[600] Fix | Delete
results.append('<a href="%s">%s</a>' % (url, escape(all)))
[601] Fix | Delete
elif pep:
[602] Fix | Delete
url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
[603] Fix | Delete
results.append('<a href="%s">%s</a>' % (url, escape(all)))
[604] Fix | Delete
elif selfdot:
[605] Fix | Delete
# Create a link for methods like 'self.method(...)'
[606] Fix | Delete
# and use <strong> for attributes like 'self.attr'
[607] Fix | Delete
if text[end:end+1] == '(':
[608] Fix | Delete
results.append('self.' + self.namelink(name, methods))
[609] Fix | Delete
else:
[610] Fix | Delete
results.append('self.<strong>%s</strong>' % name)
[611] Fix | Delete
elif text[end:end+1] == '(':
[612] Fix | Delete
results.append(self.namelink(name, methods, funcs, classes))
[613] Fix | Delete
else:
[614] Fix | Delete
results.append(self.namelink(name, classes))
[615] Fix | Delete
here = end
[616] Fix | Delete
results.append(escape(text[here:]))
[617] Fix | Delete
return ''.join(results)
[618] Fix | Delete
[619] Fix | Delete
# ---------------------------------------------- type-specific routines
[620] Fix | Delete
[621] Fix | Delete
def formattree(self, tree, modname, parent=None):
[622] Fix | Delete
"""Produce HTML for a class tree as given by inspect.getclasstree()."""
[623] Fix | Delete
result = ''
[624] Fix | Delete
for entry in tree:
[625] Fix | Delete
if type(entry) is type(()):
[626] Fix | Delete
c, bases = entry
[627] Fix | Delete
result = result + '<dt><font face="helvetica, arial">'
[628] Fix | Delete
result = result + self.classlink(c, modname)
[629] Fix | Delete
if bases and bases != (parent,):
[630] Fix | Delete
parents = []
[631] Fix | Delete
for base in bases:
[632] Fix | Delete
parents.append(self.classlink(base, modname))
[633] Fix | Delete
result = result + '(' + ', '.join(parents) + ')'
[634] Fix | Delete
result = result + '\n</font></dt>'
[635] Fix | Delete
elif type(entry) is type([]):
[636] Fix | Delete
result = result + '<dd>\n%s</dd>\n' % self.formattree(
[637] Fix | Delete
entry, modname, c)
[638] Fix | Delete
return '<dl>\n%s</dl>\n' % result
[639] Fix | Delete
[640] Fix | Delete
def docmodule(self, object, name=None, mod=None, *ignored):
[641] Fix | Delete
"""Produce HTML documentation for a module object."""
[642] Fix | Delete
name = object.__name__ # ignore the passed-in name
[643] Fix | Delete
try:
[644] Fix | Delete
all = object.__all__
[645] Fix | Delete
except AttributeError:
[646] Fix | Delete
all = None
[647] Fix | Delete
parts = name.split('.')
[648] Fix | Delete
links = []
[649] Fix | Delete
for i in range(len(parts)-1):
[650] Fix | Delete
links.append(
[651] Fix | Delete
'<a href="%s.html"><font color="#ffffff">%s</font></a>' %
[652] Fix | Delete
('.'.join(parts[:i+1]), parts[i]))
[653] Fix | Delete
linkedname = '.'.join(links + parts[-1:])
[654] Fix | Delete
head = '<big><big><strong>%s</strong></big></big>' % linkedname
[655] Fix | Delete
try:
[656] Fix | Delete
path = inspect.getabsfile(object)
[657] Fix | Delete
url = urllib.parse.quote(path)
[658] Fix | Delete
filelink = self.filelink(url, path)
[659] Fix | Delete
except TypeError:
[660] Fix | Delete
filelink = '(built-in)'
[661] Fix | Delete
info = []
[662] Fix | Delete
if hasattr(object, '__version__'):
[663] Fix | Delete
version = str(object.__version__)
[664] Fix | Delete
if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
[665] Fix | Delete
version = version[11:-1].strip()
[666] Fix | Delete
info.append('version %s' % self.escape(version))
[667] Fix | Delete
if hasattr(object, '__date__'):
[668] Fix | Delete
info.append(self.escape(str(object.__date__)))
[669] Fix | Delete
if info:
[670] Fix | Delete
head = head + ' (%s)' % ', '.join(info)
[671] Fix | Delete
docloc = self.getdocloc(object)
[672] Fix | Delete
if docloc is not None:
[673] Fix | Delete
docloc = '<br><a href="%(docloc)s">Module Reference</a>' % locals()
[674] Fix | Delete
else:
[675] Fix | Delete
docloc = ''
[676] Fix | Delete
result = self.heading(
[677] Fix | Delete
head, '#ffffff', '#7799ee',
[678] Fix | Delete
'<a href=".">index</a><br>' + filelink + docloc)
[679] Fix | Delete
[680] Fix | Delete
modules = inspect.getmembers(object, inspect.ismodule)
[681] Fix | Delete
[682] Fix | Delete
classes, cdict = [], {}
[683] Fix | Delete
for key, value in inspect.getmembers(object, inspect.isclass):
[684] Fix | Delete
# if __all__ exists, believe it. Otherwise use old heuristic.
[685] Fix | Delete
if (all is not None or
[686] Fix | Delete
(inspect.getmodule(value) or object) is object):
[687] Fix | Delete
if visiblename(key, all, object):
[688] Fix | Delete
classes.append((key, value))
[689] Fix | Delete
cdict[key] = cdict[value] = '#' + key
[690] Fix | Delete
for key, value in classes:
[691] Fix | Delete
for base in value.__bases__:
[692] Fix | Delete
key, modname = base.__name__, base.__module__
[693] Fix | Delete
module = sys.modules.get(modname)
[694] Fix | Delete
if modname != name and module and hasattr(module, key):
[695] Fix | Delete
if getattr(module, key) is base:
[696] Fix | Delete
if not key in cdict:
[697] Fix | Delete
cdict[key] = cdict[base] = modname + '.html#' + key
[698] Fix | Delete
funcs, fdict = [], {}
[699] Fix | Delete
for key, value in inspect.getmembers(object, inspect.isroutine):
[700] Fix | Delete
# if __all__ exists, believe it. Otherwise use old heuristic.
[701] Fix | Delete
if (all is not None or
[702] Fix | Delete
inspect.isbuiltin(value) or inspect.getmodule(value) is object):
[703] Fix | Delete
if visiblename(key, all, object):
[704] Fix | Delete
funcs.append((key, value))
[705] Fix | Delete
fdict[key] = '#-' + key
[706] Fix | Delete
if inspect.isfunction(value): fdict[value] = fdict[key]
[707] Fix | Delete
data = []
[708] Fix | Delete
for key, value in inspect.getmembers(object, isdata):
[709] Fix | Delete
if visiblename(key, all, object):
[710] Fix | Delete
data.append((key, value))
[711] Fix | Delete
[712] Fix | Delete
doc = self.markup(getdoc(object), self.preformat, fdict, cdict)
[713] Fix | Delete
doc = doc and '<tt>%s</tt>' % doc
[714] Fix | Delete
result = result + '<p>%s</p>\n' % doc
[715] Fix | Delete
[716] Fix | Delete
if hasattr(object, '__path__'):
[717] Fix | Delete
modpkgs = []
[718] Fix | Delete
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
[719] Fix | Delete
modpkgs.append((modname, name, ispkg, 0))
[720] Fix | Delete
modpkgs.sort()
[721] Fix | Delete
contents = self.multicolumn(modpkgs, self.modpkglink)
[722] Fix | Delete
result = result + self.bigsection(
[723] Fix | Delete
'Package Contents', '#ffffff', '#aa55cc', contents)
[724] Fix | Delete
elif modules:
[725] Fix | Delete
contents = self.multicolumn(
[726] Fix | Delete
modules, lambda t: self.modulelink(t[1]))
[727] Fix | Delete
result = result + self.bigsection(
[728] Fix | Delete
'Modules', '#ffffff', '#aa55cc', contents)
[729] Fix | Delete
[730] Fix | Delete
if classes:
[731] Fix | Delete
classlist = [value for (key, value) in classes]
[732] Fix | Delete
contents = [
[733] Fix | Delete
self.formattree(inspect.getclasstree(classlist, 1), name)]
[734] Fix | Delete
for key, value in classes:
[735] Fix | Delete
contents.append(self.document(value, key, name, fdict, cdict))
[736] Fix | Delete
result = result + self.bigsection(
[737] Fix | Delete
'Classes', '#ffffff', '#ee77aa', ' '.join(contents))
[738] Fix | Delete
if funcs:
[739] Fix | Delete
contents = []
[740] Fix | Delete
for key, value in funcs:
[741] Fix | Delete
contents.append(self.document(value, key, name, fdict, cdict))
[742] Fix | Delete
result = result + self.bigsection(
[743] Fix | Delete
'Functions', '#ffffff', '#eeaa77', ' '.join(contents))
[744] Fix | Delete
if data:
[745] Fix | Delete
contents = []
[746] Fix | Delete
for key, value in data:
[747] Fix | Delete
contents.append(self.document(value, key))
[748] Fix | Delete
result = result + self.bigsection(
[749] Fix | Delete
'Data', '#ffffff', '#55aa55', '<br>\n'.join(contents))
[750] Fix | Delete
if hasattr(object, '__author__'):
[751] Fix | Delete
contents = self.markup(str(object.__author__), self.preformat)
[752] Fix | Delete
result = result + self.bigsection(
[753] Fix | Delete
'Author', '#ffffff', '#7799ee', contents)
[754] Fix | Delete
if hasattr(object, '__credits__'):
[755] Fix | Delete
contents = self.markup(str(object.__credits__), self.preformat)
[756] Fix | Delete
result = result + self.bigsection(
[757] Fix | Delete
'Credits', '#ffffff', '#7799ee', contents)
[758] Fix | Delete
[759] Fix | Delete
return result
[760] Fix | Delete
[761] Fix | Delete
def docclass(self, object, name=None, mod=None, funcs={}, classes={},
[762] Fix | Delete
*ignored):
[763] Fix | Delete
"""Produce HTML documentation for a class object."""
[764] Fix | Delete
realname = object.__name__
[765] Fix | Delete
name = name or realname
[766] Fix | Delete
bases = object.__bases__
[767] Fix | Delete
[768] Fix | Delete
contents = []
[769] Fix | Delete
push = contents.append
[770] Fix | Delete
[771] Fix | Delete
# Cute little class to pump out a horizontal rule between sections.
[772] Fix | Delete
class HorizontalRule:
[773] Fix | Delete
def __init__(self):
[774] Fix | Delete
self.needone = 0
[775] Fix | Delete
def maybe(self):
[776] Fix | Delete
if self.needone:
[777] Fix | Delete
push('<hr>\n')
[778] Fix | Delete
self.needone = 1
[779] Fix | Delete
hr = HorizontalRule()
[780] Fix | Delete
[781] Fix | Delete
# List the mro, if non-trivial.
[782] Fix | Delete
mro = deque(inspect.getmro(object))
[783] Fix | Delete
if len(mro) > 2:
[784] Fix | Delete
hr.maybe()
[785] Fix | Delete
push('<dl><dt>Method resolution order:</dt>\n')
[786] Fix | Delete
for base in mro:
[787] Fix | Delete
push('<dd>%s</dd>\n' % self.classlink(base,
[788] Fix | Delete
object.__module__))
[789] Fix | Delete
push('</dl>\n')
[790] Fix | Delete
[791] Fix | Delete
def spill(msg, attrs, predicate):
[792] Fix | Delete
ok, attrs = _split_list(attrs, predicate)
[793] Fix | Delete
if ok:
[794] Fix | Delete
hr.maybe()
[795] Fix | Delete
push(msg)
[796] Fix | Delete
for name, kind, homecls, value in ok:
[797] Fix | Delete
try:
[798] Fix | Delete
value = getattr(object, name)
[799] Fix | Delete
except Exception:
[800] Fix | Delete
# Some descriptors may meet a failure in their __get__.
[801] Fix | Delete
# (bug #1785)
[802] Fix | Delete
push(self.docdata(value, name, mod))
[803] Fix | Delete
else:
[804] Fix | Delete
push(self.document(value, name, mod,
[805] Fix | Delete
funcs, classes, mdict, object))
[806] Fix | Delete
push('\n')
[807] Fix | Delete
return attrs
[808] Fix | Delete
[809] Fix | Delete
def spilldescriptors(msg, attrs, predicate):
[810] Fix | Delete
ok, attrs = _split_list(attrs, predicate)
[811] Fix | Delete
if ok:
[812] Fix | Delete
hr.maybe()
[813] Fix | Delete
push(msg)
[814] Fix | Delete
for name, kind, homecls, value in ok:
[815] Fix | Delete
push(self.docdata(value, name, mod))
[816] Fix | Delete
return attrs
[817] Fix | Delete
[818] Fix | Delete
def spilldata(msg, attrs, predicate):
[819] Fix | Delete
ok, attrs = _split_list(attrs, predicate)
[820] Fix | Delete
if ok:
[821] Fix | Delete
hr.maybe()
[822] Fix | Delete
push(msg)
[823] Fix | Delete
for name, kind, homecls, value in ok:
[824] Fix | Delete
base = self.docother(getattr(object, name), name, mod)
[825] Fix | Delete
if callable(value) or inspect.isdatadescriptor(value):
[826] Fix | Delete
doc = getattr(value, "__doc__", None)
[827] Fix | Delete
else:
[828] Fix | Delete
doc = None
[829] Fix | Delete
if doc is None:
[830] Fix | Delete
push('<dl><dt>%s</dl>\n' % base)
[831] Fix | Delete
else:
[832] Fix | Delete
doc = self.markup(getdoc(value), self.preformat,
[833] Fix | Delete
funcs, classes, mdict)
[834] Fix | Delete
doc = '<dd><tt>%s</tt>' % doc
[835] Fix | Delete
push('<dl><dt>%s%s</dl>\n' % (base, doc))
[836] Fix | Delete
push('\n')
[837] Fix | Delete
return attrs
[838] Fix | Delete
[839] Fix | Delete
attrs = [(name, kind, cls, value)
[840] Fix | Delete
for name, kind, cls, value in classify_class_attrs(object)
[841] Fix | Delete
if visiblename(name, obj=object)]
[842] Fix | Delete
[843] Fix | Delete
mdict = {}
[844] Fix | Delete
for key, kind, homecls, value in attrs:
[845] Fix | Delete
mdict[key] = anchor = '#' + name + '-' + key
[846] Fix | Delete
try:
[847] Fix | Delete
value = getattr(object, name)
[848] Fix | Delete
except Exception:
[849] Fix | Delete
# Some descriptors may meet a failure in their __get__.
[850] Fix | Delete
# (bug #1785)
[851] Fix | Delete
pass
[852] Fix | Delete
try:
[853] Fix | Delete
# The value may not be hashable (e.g., a data attr with
[854] Fix | Delete
# a dict or list value).
[855] Fix | Delete
mdict[value] = anchor
[856] Fix | Delete
except TypeError:
[857] Fix | Delete
pass
[858] Fix | Delete
[859] Fix | Delete
while attrs:
[860] Fix | Delete
if mro:
[861] Fix | Delete
thisclass = mro.popleft()
[862] Fix | Delete
else:
[863] Fix | Delete
thisclass = attrs[0][2]
[864] Fix | Delete
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
[865] Fix | Delete
[866] Fix | Delete
if object is not builtins.object and thisclass is builtins.object:
[867] Fix | Delete
attrs = inherited
[868] Fix | Delete
continue
[869] Fix | Delete
elif thisclass is object:
[870] Fix | Delete
tag = 'defined here'
[871] Fix | Delete
else:
[872] Fix | Delete
tag = 'inherited from %s' % self.classlink(thisclass,
[873] Fix | Delete
object.__module__)
[874] Fix | Delete
tag += ':<br>\n'
[875] Fix | Delete
[876] Fix | Delete
sort_attributes(attrs, object)
[877] Fix | Delete
[878] Fix | Delete
# Pump out the attrs, segregated by kind.
[879] Fix | Delete
attrs = spill('Methods %s' % tag, attrs,
[880] Fix | Delete
lambda t: t[1] == 'method')
[881] Fix | Delete
attrs = spill('Class methods %s' % tag, attrs,
[882] Fix | Delete
lambda t: t[1] == 'class method')
[883] Fix | Delete
attrs = spill('Static methods %s' % tag, attrs,
[884] Fix | Delete
lambda t: t[1] == 'static method')
[885] Fix | Delete
attrs = spilldescriptors("Readonly properties %s" % tag, attrs,
[886] Fix | Delete
lambda t: t[1] == 'readonly property')
[887] Fix | Delete
attrs = spilldescriptors('Data descriptors %s' % tag, attrs,
[888] Fix | Delete
lambda t: t[1] == 'data descriptor')
[889] Fix | Delete
attrs = spilldata('Data and other attributes %s' % tag, attrs,
[890] Fix | Delete
lambda t: t[1] == 'data')
[891] Fix | Delete
assert attrs == []
[892] Fix | Delete
attrs = inherited
[893] Fix | Delete
[894] Fix | Delete
contents = ''.join(contents)
[895] Fix | Delete
[896] Fix | Delete
if name == realname:
[897] Fix | Delete
title = '<a name="%s">class <strong>%s</strong></a>' % (
[898] Fix | Delete
name, realname)
[899] Fix | Delete
else:
[900] Fix | Delete
title = '<strong>%s</strong> = <a name="%s">class %s</a>' % (
[901] Fix | Delete
name, name, realname)
[902] Fix | Delete
if bases:
[903] Fix | Delete
parents = []
[904] Fix | Delete
for base in bases:
[905] Fix | Delete
parents.append(self.classlink(base, object.__module__))
[906] Fix | Delete
title = title + '(%s)' % ', '.join(parents)
[907] Fix | Delete
[908] Fix | Delete
decl = ''
[909] Fix | Delete
try:
[910] Fix | Delete
signature = inspect.signature(object)
[911] Fix | Delete
except (ValueError, TypeError):
[912] Fix | Delete
signature = None
[913] Fix | Delete
if signature:
[914] Fix | Delete
argspec = str(signature)
[915] Fix | Delete
if argspec and argspec != '()':
[916] Fix | Delete
decl = name + self.escape(argspec) + '\n\n'
[917] Fix | Delete
[918] Fix | Delete
doc = getdoc(object)
[919] Fix | Delete
if decl:
[920] Fix | Delete
doc = decl + (doc or '')
[921] Fix | Delete
doc = self.markup(doc, self.preformat, funcs, classes, mdict)
[922] Fix | Delete
doc = doc and '<tt>%s<br>&nbsp;</tt>' % doc
[923] Fix | Delete
[924] Fix | Delete
return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
[925] Fix | Delete
[926] Fix | Delete
def formatvalue(self, object):
[927] Fix | Delete
"""Format an argument default value as text."""
[928] Fix | Delete
return self.grey('=' + self.repr(object))
[929] Fix | Delete
[930] Fix | Delete
def docroutine(self, object, name=None, mod=None,
[931] Fix | Delete
funcs={}, classes={}, methods={}, cl=None):
[932] Fix | Delete
"""Produce HTML documentation for a function or method object."""
[933] Fix | Delete
realname = object.__name__
[934] Fix | Delete
name = name or realname
[935] Fix | Delete
anchor = (cl and cl.__name__ or '') + '-' + name
[936] Fix | Delete
note = ''
[937] Fix | Delete
skipdocs = 0
[938] Fix | Delete
if _is_bound_method(object):
[939] Fix | Delete
imclass = object.__self__.__class__
[940] Fix | Delete
if cl:
[941] Fix | Delete
if imclass is not cl:
[942] Fix | Delete
note = ' from ' + self.classlink(imclass, mod)
[943] Fix | Delete
else:
[944] Fix | Delete
if object.__self__ is not None:
[945] Fix | Delete
note = ' method of %s instance' % self.classlink(
[946] Fix | Delete
object.__self__.__class__, mod)
[947] Fix | Delete
else:
[948] Fix | Delete
note = ' unbound %s method' % self.classlink(imclass,mod)
[949] Fix | Delete
[950] Fix | Delete
if (inspect.iscoroutinefunction(object) or
[951] Fix | Delete
inspect.isasyncgenfunction(object)):
[952] Fix | Delete
asyncqualifier = 'async '
[953] Fix | Delete
else:
[954] Fix | Delete
asyncqualifier = ''
[955] Fix | Delete
[956] Fix | Delete
if name == realname:
[957] Fix | Delete
title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
[958] Fix | Delete
else:
[959] Fix | Delete
if cl and inspect.getattr_static(cl, realname, []) is object:
[960] Fix | Delete
reallink = '<a href="#%s">%s</a>' % (
[961] Fix | Delete
cl.__name__ + '-' + realname, realname)
[962] Fix | Delete
skipdocs = 1
[963] Fix | Delete
else:
[964] Fix | Delete
reallink = realname
[965] Fix | Delete
title = '<a name="%s"><strong>%s</strong></a> = %s' % (
[966] Fix | Delete
anchor, name, reallink)
[967] Fix | Delete
argspec = None
[968] Fix | Delete
if inspect.isroutine(object):
[969] Fix | Delete
try:
[970] Fix | Delete
signature = inspect.signature(object)
[971] Fix | Delete
except (ValueError, TypeError):
[972] Fix | Delete
signature = None
[973] Fix | Delete
if signature:
[974] Fix | Delete
argspec = str(signature)
[975] Fix | Delete
if realname == '<lambda>':
[976] Fix | Delete
title = '<strong>%s</strong> <em>lambda</em> ' % name
[977] Fix | Delete
# XXX lambda's won't usually have func_annotations['return']
[978] Fix | Delete
# since the syntax doesn't support but it is possible.
[979] Fix | Delete
# So removing parentheses isn't truly safe.
[980] Fix | Delete
argspec = argspec[1:-1] # remove parentheses
[981] Fix | Delete
if not argspec:
[982] Fix | Delete
argspec = '(...)'
[983] Fix | Delete
[984] Fix | Delete
decl = asyncqualifier + title + self.escape(argspec) + (note and
[985] Fix | Delete
self.grey('<font face="helvetica, arial">%s</font>' % note))
[986] Fix | Delete
[987] Fix | Delete
if skipdocs:
[988] Fix | Delete
return '<dl><dt>%s</dt></dl>\n' % decl
[989] Fix | Delete
else:
[990] Fix | Delete
doc = self.markup(
[991] Fix | Delete
getdoc(object), self.preformat, funcs, classes, methods)
[992] Fix | Delete
doc = doc and '<dd><tt>%s</tt></dd>' % doc
[993] Fix | Delete
return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
[994] Fix | Delete
[995] Fix | Delete
def docdata(self, object, name=None, mod=None, cl=None):
[996] Fix | Delete
"""Produce html documentation for a data descriptor."""
[997] Fix | Delete
results = []
[998] Fix | Delete
push = results.append
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function