本文整理汇总了Python中pydoc.getdoc函数的典型用法代码示例。如果您正苦于以下问题:Python getdoc函数的具体用法?Python getdoc怎么用?Python getdoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getdoc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc,
config={}):
if not inspect.isclass(cls) and cls is not None:
raise ValueError("Expected a class or None, but got %r" % cls)
self._cls = cls
if modulename and not modulename.endswith('.'):
modulename += '.'
self._mod = modulename
if doc is None:
if cls is None:
raise ValueError("No class or documentation string given")
doc = pydoc.getdoc(cls)
NumpyDocString.__init__(self, doc)
if config.get('show_class_members', True):
def splitlines_x(s):
if not s:
return []
else:
return s.splitlines()
for field, items in [('Methods', self.methods),
('Attributes', self.properties)]:
if not self[field]:
doc_list = []
for name in sorted(items):
try:
doc_item = pydoc.getdoc(getattr(self._cls, name))
doc_list.append((name, '', splitlines_x(doc_item)))
except AttributeError:
pass # method doesn't exist
self[field] = doc_list
开发者ID:AlexandreAbraham,项目名称:nilearn,代码行数:35,代码来源:docscrape.py
示例2: hh
def hh(cmd = None):
"""Get help on a command."""
shell_funcs['hh'] = hh
import pydoc
from inspect import getargspec, formatargspec
if not cmd:
print "\nUse self.addrspace for Kernel/Virtual AS"
print "Use self.addrspace.base for Physical AS"
print "Use self.proc to get the current _EPROCESS object"
print " and self.proc.get_process_address_space() for the current process AS"
print " and self.proc.get_load_modules() for the current process DLLs\n"
for f in sorted(shell_funcs):
doc = pydoc.getdoc(shell_funcs[f])
synop, _full = pydoc.splitdoc(doc)
print "{0:40} : {1}".format(f + formatargspec(*getargspec(shell_funcs[f])), synop)
print "\nFor help on a specific command, type 'hh(<command>)'"
elif type(cmd) == str:
try:
doc = pydoc.getdoc(shell_funcs[cmd])
except KeyError:
print "No such command: {0}".format(cmd)
return
print doc
else:
doc = pydoc.getdoc(cmd)
print doc
开发者ID:B-Rich,项目名称:amark,代码行数:26,代码来源:volshell.py
示例3: h
def h(cmd=None):
if cmd:
L = [cmd,]
else:
L = cmds[:]
for x in L:
print x
print pydoc.getdoc(eval(x))
开发者ID:gregglind,项目名称:werk,代码行数:9,代码来源:werk.py
示例4: __init__
def __init__(self, provider, permission, signatures, callable, name = None):
""" Accept a signature in the form returned by xmlrpc_methods. """
import pydoc
self.permission = permission
self.callable = callable
self.rpc_signatures = signatures
self.description = pydoc.getdoc(callable)
if name is None:
self.name = provider.xmlrpc_namespace() + '.' + callable.__name__
else:
self.name = provider.xmlrpc_namespace() + '.' + name
self.namespace = provider.xmlrpc_namespace()
self.namespace_description = pydoc.getdoc(provider)
开发者ID:Puppet-Finland,项目名称:trac,代码行数:13,代码来源:api.py
示例5: mangle_signature
def mangle_signature(app, what, name, obj, options, sig, retann):
# Do not try to inspect classes that don't define `__init__`
if (inspect.isclass(obj) and
'initializes x; see ' in pydoc.getdoc(obj.__init__)):
return '', ''
if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
if not hasattr(obj, '__doc__'): return
doc = SphinxDocString(pydoc.getdoc(obj))
if doc['Signature']:
sig = re.sub("^[^(]*", "", doc['Signature'])
return sig, ''
开发者ID:151706061,项目名称:connectomeviewer,代码行数:13,代码来源:numpydoc.py
示例6: docroutine
def docroutine(self, obj, name=None, mod=None, cl=None):
"""Produce text documentation for a function or method obj."""
realname = obj.__name__
name = name or realname
note = ''
skipdocs = 0
if inspect.ismethod(obj):
obj = obj.__func__
if name == realname:
title = self.bold(realname)
else:
if cl and realname in cl.__dict__ and cl.__dict__[realname] is obj:
skipdocs = 1
title = '%s = %s' % (self.bold(name), realname)
if inspect.isfunction(obj):
args, varargs, keywords, defaults = inspect.getargspec(obj)
argspec = inspect.formatargspec(args, varargs, keywords, defaults, formatvalue=self.formatvalue)
else:
argspec = '(...)'
decl = "def %s(%s'):\n{: .lead}%s" % (title, escape_equal(self.emphasis(argspec[1:-1])), note)
if skipdocs:
return decl + '\n'
else:
doc = pydoc.getdoc(obj) or ''
return '%s\n> %s' % (decl, (doc and self.indent(doc).rstrip() + '\n'))
开发者ID:tmthydvnprt,项目名称:utilipy,代码行数:26,代码来源:pydoc_markdown.py
示例7: pprinthook
def pprinthook(value):
"""Pretty print an object to sys.stdout and also save it in
__builtin__.
"""
if value is None:
return
__builtin__._ = value
if isinstance(value, help_types):
reprstr = repr(value)
try:
if inspect.isfunction(value):
parts = reprstr.split(' ')
parts[1] += inspect.formatargspec(*getargspec(value))
reprstr = ' '.join(parts)
elif inspect.ismethod(value):
parts = reprstr[:-1].split(' ')
parts[2] += inspect.formatargspec(*getargspec(value))
reprstr = ' '.join(parts) + '>'
except TypeError:
pass
sys.stdout.write(reprstr)
sys.stdout.write('\n')
if getattr(value, '__doc__', None):
sys.stdout.write('\n')
sys.stdout.write(pydoc.getdoc(value))
sys.stdout.write('\n')
else:
pphighlight(value, width=get_width() or 80)
开发者ID:Le-Stagiaire,项目名称:conf,代码行数:30,代码来源:.pythonrc.py
示例8: run
def run(self):
prefix = self.arguments and self.arguments.pop() or None
content = []
for resource_type, resource_classes in _filter_resources(
prefix, self.path(), self.statuses()):
for resource_class in resource_classes:
self.resource_type = resource_type
self.resource_class = resource_class
section = self._section(content, resource_type, '%s')
self.props_schemata = properties.schemata(
self.resource_class.properties_schema)
self.attrs_schemata = attributes.schemata(
self.resource_class.attributes_schema)
self._status_str(resource_class.support_status, section)
cls_doc = pydoc.getdoc(resource_class)
if cls_doc:
# allow for rst in the class comments
cls_nodes = core.publish_doctree(cls_doc).children
section.extend(cls_nodes)
self.contribute_properties(section)
self.contribute_attributes(section)
self.contribute_hot_syntax(section)
self.contribute_yaml_syntax(section)
self.contribute_json_syntax(section)
return content
开发者ID:james49,项目名称:heat,代码行数:31,代码来源:resources.py
示例9: run
def run(self):
prefix = self.arguments and self.arguments.pop() or None
content = []
for resource_type, resource_classes in _filter_resources(prefix, self.path(), self.statuses()):
for resource_class in resource_classes:
self.resource_type = resource_type
self.resource_class = resource_class
section = self._section(content, resource_type, "%s")
self.props_schemata = properties.schemata(self.resource_class.properties_schema)
self.attrs_schemata = attributes.schemata(self.resource_class.attributes_schema)
# NOTE(prazumovsky): Adding base_attributes_schema dict to
# Resource class should means adding new attributes from this
# dict to documentation of each resource, else there is no
# chance to learn about base attributes.
self.attrs_schemata.update(self.resource_class.base_attributes_schema)
self.update_policy_schemata = properties.schemata(self.resource_class.update_policy_schema)
self._status_str(resource_class.support_status, section)
cls_doc = pydoc.getdoc(resource_class)
if cls_doc:
# allow for rst in the class comments
cls_nodes = core.publish_doctree(cls_doc).children
section.extend(cls_nodes)
self.contribute_properties(section)
self.contribute_attributes(section)
self.contribute_update_policy(section)
self.contribute_hot_syntax(section)
return content
开发者ID:steveb,项目名称:heat,代码行数:33,代码来源:resources.py
示例10: get_doc_object
def get_doc_object(obj, what=None, doc=None, config={}):
if what is None:
if inspect.isclass(obj):
what = 'class'
elif inspect.ismodule(obj):
what = 'module'
elif isinstance(obj, collections.Callable):
what = 'function'
else:
what = 'object'
if what == 'class':
# It is important that the `doc=doc` is passed because
# this function may be run the second time with a
# prepared docstring `doc` and `obj=None`
# In that case the prepared `doc` is used
newdoc = SphinxTraitsDoc(obj, "", func_doc=SphinxFunctionDoc,
doc=doc, config=config)
if obj and looks_like_issubclass(obj, "HasTraits"):
for name, trait, comment in comment_eater.get_class_traits(obj):
# Exclude private traits.
if not name.startswith('_'):
newdoc['Traits'].append((name, trait, comment.splitlines()))
return newdoc
elif what in ('function', 'method'):
return SphinxFunctionDoc(obj, doc=doc, config=config)
else:
if doc is None and obj:
doc = pydoc.getobj(obj)
return SphinxDocString(pydoc.getdoc(obj), config=config)
开发者ID:PeterZhouSZ,项目名称:mayavi,代码行数:31,代码来源:traitsdoc.py
示例11: main
def main():
usage = __import__(__name__).__doc__.strip()
usage += "\n\nCommands:\n\n"
commands = {}
for func in sorted(COMMANDS):
name = func.__name__.strip().replace("cmd_", "").replace("_", "-")
commands[name] = func
head, tail = pydoc.splitdoc(pydoc.getdoc(func))
cmd_help = textwrap.fill(tail, width=70).replace("\n", "\n ").strip()
usage += "%s\n %s\n\n" % (head, cmd_help)
usage = usage.strip()
parser = OptionParser(usage=usage)
parser.allow_interspersed_args = False
(options, args) = parser.parse_args()
if len(args) < 1:
parser.error("No command given")
cmd_name = args.pop(0)
cmd = commands.get(cmd_name)
if cmd is None:
parser.error("Unknown command %s" % cmd_name)
else:
cmd(args)
开发者ID:pv,项目名称:pydocweb,代码行数:26,代码来源:pydoc-tool.py
示例12: docclass
def docclass(self, object, name=None, mod=None):
''' Produce text documentation for a given class object.
'''
realname = object.__name__
name = name or realname
bases = object.__bases__
if name == realname:
title = '### class ' + self.bold(realname)
else:
title = '### ' + self.bold(name) + ' = class ' + realname
if bases:
def makename(c, m=object.__module__): return pydoc.classname(c, m)
parents = map(makename, bases)
title = title + '(%s)' % ', '.join(parents)
doc = pydoc.getdoc(object)
contents = doc and doc + '\n'
methods = pydoc.allmethods(object).items()
methods.sort()
for key, value in methods:
if key.startswith('_'):
continue
contents = contents + '\n' + self.document(value, key, mod, object)
if not contents: return title + '\n'
return title + '\n' + self.indent(contents.rstrip()) + '\n'
开发者ID:ownport,项目名称:pydoc2md,代码行数:27,代码来源:pydoc2md.py
示例13: doc_element
def doc_element(self, element, namespace, qname):
"""
Document extension elements
"""
attributes = {'namespace-uri' : namespace or '',
'name' : qname,
}
self.start_element('element', attributes)
desc = self.escape(pydoc.getdoc(element))
self.write_element('description', content=desc)
if element.content:
content = self.escape(str(element.content))
self.write_element('content', content=content)
attributes = element.legalAttrs or {}
for name, info in attributes.items():
attrs = {'name' : name,
'content' : str(info),
'required' : info.required and 'yes' or 'no',
}
if info.default:
attrs['default'] = info.default
self.start_element('attribute', attrs)
desc = info.description or ''
self.write_element('description', content=desc)
self.end_element('attribute')
self.end_element('element')
return
开发者ID:H1d3r,项目名称:binary_blobs,代码行数:31,代码来源:ExtensionFormatter.py
示例14: setup
def setup(args=None):
# make sure our directory is at the front of sys.path
module = metadata('backupmgr')
# get the version and description from the source
version = module.__version__
description = pydoc.splitdoc(pydoc.getdoc(module))[0]
author, author_email = email.utils.parseaddr(module.__authors__[0])
# get the long description from README-type files
long_description = []
for path in READMES:
with open(os.path.join(SRCROOT, path), 'r') as fh:
long_description.append(fh.read())
long_description = '\n'.join([ x for x in long_description if x ])
# use setuptools to do the rest
setuptools.setup(
name=pkg_resources.safe_name(module.__name__),
packages=setuptools.find_packages(),
version=version,
description=description,
author=author,
author_email=author_email,
zip_safe=True,
#url=None,
install_requires=["python-dateutil"],
long_description=long_description,
license='BSD',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers'
])
开发者ID:theg5prank,项目名称:backupmgr,代码行数:32,代码来源:setup.py
示例15: write_doc
def write_doc(self, file):
file.write(str(self.entry.home) + "\n")
doc = pydoc.getdoc(self.entry.home)
if doc:
file.write(doc + "\n")
for field in str(self.entry.info).split(', '):
file.write("\t" + field + "\n")
开发者ID:TimSimpsonR,项目名称:python-proboscis,代码行数:7,代码来源:case.py
示例16: doc_arguments
def doc_arguments(self, object):
self.start_element("arguments")
if inspect.isfunction(object):
args, varargs, varkw, defaults = inspect.getargspec(object)
if defaults:
firstdefault = len(args) - len(defaults)
for i in xrange(len(args)):
if defaults and i >= firstdefault:
default = repr(defaults[i - firstdefault])
else:
default = None
self.format_arg(args[i], default)
if varargs:
self.write_element("var-args", {"name": varargs})
if varkw:
self.write_element("var-keywords", {"name": varkw})
else:
arglist = "..."
if inspect.isbuiltin(object):
# Extract argument list from docstring
match = _re_arglist.match(pydoc.getdoc(object))
if match:
arglist = match.group("arglist")
self.write_element("unknown", content=arglist)
self.end_element("arguments")
return
开发者ID:flaub,项目名称:Peach,代码行数:32,代码来源:ApiFormatter.py
示例17: docroutine
def docroutine(self, object, name=None, mod=None, cl=None):
"""Produce text documentation for a function or method object."""
realname = object.__name__
name = name or realname
note = ''
skipdocs = 0
if inspect.ismethod(object):
object = object.__func__
if name == realname:
title = self.bold(realname)
else:
if (cl and realname in cl.__dict__ and cl.__dict__[realname] is object):
skipdocs = 1
title = self.bold(name) + ' = ' + realname
if inspect.isfunction(object):
args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann = inspect.getfullargspec(object)
argspec = inspect.formatargspec(
args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann,
formatvalue=self.formatvalue,
formatannotation=inspect.formatannotationrelativeto(object))
if realname == '<lambda>':
title = self.bold(name) + ' lambda '
# XXX lambda's won't usually have func_annotations['return']
# since the syntax doesn't support but it is possible.
# So removing parentheses isn't truly safe.
argspec = argspec[1:-1] # remove parentheses
else:
argspec = '(...)'
decl = "#### " + "def " + title + argspec + ':' + '\n' + note
if skipdocs:
return decl + '\n'
else:
doc = pydoc.getdoc(object) or ''
return decl + '\n' + (doc and self.indent(doc).rstrip() + '\n')
开发者ID:jacob-carrier,项目名称:code,代码行数:35,代码来源:recipe-576733.py
示例18: help
def help(self, request):
global _img
topbar = '_' * 72 + '\n' # 72-character divider
if hasattr(request, '__name__'):
pydoc.pager(topbar + 'Help on ' + pydoc.text.bold(request.__name__)
+ ':\n\n' + pydoc.getdoc(request))
else:
opts = _img.opts.__class__.__dict__
try:
opt = opts[request]
desc_list = str(opt.doc()).split('\n')
desc = '\n\n'.join(desc_list)
default_val = opt._default
if isinstance(default_val, str):
valstr = "'" + default_val + "'"
else:
valstr = str(default_val)
default_val_text = 'Default value: ' + valstr
if opt.group() != None and opt.group() != 'hidden':
group_text = '\nBelongs to group: ' + opt.group()
else:
group_text = ''
desc_text = lofar.bdsm.interface.wrap(desc, 72)
desc_text = '\n'.join(desc_text)
pydoc.pager(topbar + 'Help on the ' + pydoc.text.bold(request)
+ ' parameter:\n\n' + default_val_text
+ group_text
+ '\n\n' + desc_text)
except(KeyError):
print "Parameter '" + request + "' not recognized."
开发者ID:saiyanprince,项目名称:pyimager,代码行数:30,代码来源:pybdsm.py
示例19: methods
def methods(self):
if self._cls is None:
return []
return [name for name,func in inspect.getmembers(self._cls)
if ((not name.startswith('_') or
'.. shownumpydoc' in pydoc.getdoc(func))
and isinstance(func, collections.Callable))]
开发者ID:AndreaEdwards,项目名称:scikit-bio,代码行数:7,代码来源:docscrape.py
示例20: __init__
def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc,
config={}):
if not inspect.isclass(cls) and cls is not None:
raise ValueError("Expected a class or None, but got %r" % cls)
self._cls = cls
self._exclude_class_members = config.get('exclude_class_members', [])
if modulename and not modulename.endswith('.'):
modulename += '.'
self._mod = modulename
if doc is None:
if cls is None:
raise ValueError("No class or documentation string given")
doc = pydoc.getdoc(cls)
NumpyDocString.__init__(self, doc)
if config.get('show_class_members', True):
if not self['Methods']:
self['Methods'] = [(name, '', '')
for name in sorted(self.methods)]
if not self['Attributes']:
self['Attributes'] = [(name, '', '')
for name in sorted(self.properties)]
开发者ID:PaulPrice,项目名称:healpy,代码行数:26,代码来源:docscrape.py
注:本文中的pydoc.getdoc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论