本文整理汇总了Python中pydoc.render_doc函数的典型用法代码示例。如果您正苦于以下问题:Python render_doc函数的具体用法?Python render_doc怎么用?Python render_doc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_doc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: helphtml
def helphtml(obj,*aos):
txt=''
import pydoc,re
if aos:
aos=flat(obj,aos,noNone=True)
for i in aos:
#TODO
txt+=re.sub('.\b', '', pydoc.render_doc(i,'%s'))
txt+='\n==============%s=======================\n'%ct(aos)
else:txt=re.sub('.\b', '', pydoc.render_doc(obj,'%s'))
# txt=txt.replace(txthtml[1],txthtml[1][:1]+'!!!qgb-padding!!!'+txthtml[1][1:])
# txt=txthtml[0]+txt+txthtml[1]
# msgbox(txt[txt.find(b'\x08'):])
# repl()
# exit()
file='Uhelp_obj.txt'
try:
import T
if obj:file=T.filename(getObjName(obj))+'.txt'
elif aos:file=T.filename(getObjName(aos[0]))+'..%s.txt'%len(aos)
except:pass
with open(file,'w') as f:
f.write(txt)
# write(file,txt)
globals()['browser'](file)
示例2: handle_input
def handle_input(self, inpt):
if inpt == 'enter':
return self.accept_input()
elif inpt == 'ctrl d':
raise urwid.ExitMainLoop()
elif inpt == 'ctrl p':
self.screen.page(pydoc.render_doc('pydoc'))
return True
elif inpt == 'ctrl o':
txt = self.widget.inputbox.text.strip()
try:
fulltxt = pydoc.render_doc(str(txt))
except ImportError:
fulltxt = 'No documentation found for ' + repr(txt)
self.screen.page(fulltxt)
return True
if inpt == 'ctrl w': # widget switch
if self.widget.upperbox.widget == self.widget.completionbox:
self.widget.upperbox.widget = urwid.Text(self.usagetext)
else:
self.widget.upperbox.widget = self.widget.completionbox
#self.widget.upperbox.widget = urwid.Text('Another widget!')
return True
else:
self.widget.upperbox.widget = urwid.Text(inpt)
return True
示例3: main
def main():
try:
action = getattr(sys.modules[__name__], sys.argv[1])
action(*sys.argv[2:])
except IndexError as error:
print "Usage {0} function [args]".format(sys.argv[0])
print pydoc.render_doc(sys.modules[__name__], "Help on %s")
示例4: help
def help(which=None):
''' help about all functions or one specific function '''
m = sys.modules[__name__]
if which:
print (pydoc.render_doc(getattr(m, which)))
else:
print (pydoc.render_doc(m))
sys.exit(1)
示例5: test_non_str_name
def test_non_str_name(self):
# issue14638
# Treat illegal (non-str) name like no name
class A:
__name__ = 42
class B:
pass
adoc = pydoc.render_doc(A())
bdoc = pydoc.render_doc(B())
self.assertEqual(adoc.replace("A", "B"), bdoc)
示例6: test_typing_pydoc
def test_typing_pydoc(self):
def foo(data: typing.List[typing.Any],
x: int) -> typing.Iterator[typing.Tuple[int, typing.Any]]:
...
T = typing.TypeVar('T')
class C(typing.Generic[T], typing.Mapping[int, str]): ...
self.assertEqual(pydoc.render_doc(foo).splitlines()[-1],
'f\x08fo\x08oo\x08o(data:List[Any], x:int)'
' -> Iterator[Tuple[int, Any]]')
self.assertEqual(pydoc.render_doc(C).splitlines()[2],
'class C\x08C(typing.Mapping)')
示例7: connected_all_devices
def connected_all_devices():
print(pydoc.plain(pydoc.render_doc(topology.mount)))
unmounted_list = topology.unmounted_nodes()
if unmounted_list:
for device_name in unmounted_list:
mount_device(device_name)
# time.sleep(15)
else:
print('There are no (configured) devices unmounted.')
print(pydoc.plain(pydoc.render_doc(topology.connected)))
print('connected: ', topology.connected_nodes())
示例8: test_field_order_for_named_tuples
def test_field_order_for_named_tuples(self):
Person = namedtuple('Person', ['nickname', 'firstname', 'agegroup'])
s = pydoc.render_doc(Person)
self.assertLess(s.index('nickname'), s.index('firstname'))
self.assertLess(s.index('firstname'), s.index('agegroup'))
class NonIterableFields:
_fields = None
class NonHashableFields:
_fields = [[]]
# Make sure these doesn't fail
pydoc.render_doc(NonIterableFields)
pydoc.render_doc(NonHashableFields)
示例9: print_desc
def print_desc(prefix, pkg_path):
for pkg in pu.iter_modules(pkg_path):
name = prefix+"."+pkg[1]
if (pkg[2] == True):
try:
print(pd.plain(pd.render_doc(name)))
docstr = pd.plain(pd.render_doc(name))
docstr = clean(docstr)
start = docstr.find("DESCRIPTION")
docstr = docstr[start: start + 140]
print(name, docstr)
except:
print("UnexpectedError", sys.exc_info()[0])
continue
示例10: print_doc
def print_doc (symbol):
import pydoc;
# if symbol is "module.symbol", try auto-import
match_module = _re_mod_command.match(symbol);
if match_module:
_autoimport(match_module.group(1));
# try to evaluate the symbol to 'what'
what = None
try:
what = eval(symbol,Pyxis.Context);
except:
# if symbol does not contain a dot, try to treat it as a module name
if '.' not in symbol:
try:
_autoimport(symbol)
what = eval(symbol,Pyxis.Context)
except:
pass
if what is None:
print("Pyxis doesn't know anything about '%s'"%symbol);
return;
docs = pydoc.render_doc(what).split("\n");
if docs[0].startswith("Python Library"):
docs[0] = "Pyxis documentation for %s (%s):"%(symbol, type(what).__name__);
print("\n".join(docs));
示例11: main
def main():
print(pydoc.plain(pydoc.render_doc(topology.mount)))
try:
device_name = topology.unmounted_nodes()[0]
mount_device(device_name)
except IndexError:
print('All configured devices are mounted. Demonstration cancelled.')
示例12: print_function
def print_function(functions, function):
func = get_function(functions, function)
if func:
print pydoc.plain(pydoc.render_doc(
func,
"Displaying docstring for %s")
)
示例13: __init__
def __init__(self, name):
self['data'] = MyDocFileDataDict('')
self['func'] = MyDocFileFunctionDict('')
self['class'] = MyDocFileClassDict('')
self['desc'] = MyDocFileDataDesc('')
self['tree'] = ''
self['name'] = name
self['raw'] = re.sub('.\b', '', pydoc.render_doc(name))
self['synmols'] = __import__(name,fromlist=[name.split('.')[-1]])
d = split_sections(self['raw'].split('\n'))
if 'DATA' in d.keys():
self['data'] = MyDocFileDataDict('\n'.join(d['DATA']))
if 'FUNCTIONS' in d.keys():
self['func'] = MyDocFileFunctionDict('\n'.join(d['FUNCTIONS']))
if 'CLASSES' in d.keys():
for x in do_undent(d['CLASSES']):
if re.match(r'[ ]*class ', x):
break
self['tree'] += x + '\n'
self['tree'] = self['tree'].rstrip()
self['class'] = MyDocFileClassDict('\n'.join(d['CLASSES']))
if 'DESCRIPTION' in d.keys():
self['desc'] = MyDocFileDataDesc('\n'.join(d['DESCRIPTION']))
self['name1'] = d['NAME'][0].strip()
else:
x = d['NAME'][0].split('-', 1)
self['name1'] = x[0].strip()
self['desc'] = MyDocFileDataDesc(x[1].strip())
self['desc'] = MyDocFileDataDesc(self['synmols'].__doc__)
## print name, repr(self['synmols'].__doc__)
self['file'] = d['FILE'][0].strip()
示例14: test_classic_class
def test_classic_class(self):
class C: "Classic class"
c = C()
self.assertEqual(pydoc.describe(C), 'class C')
self.assertEqual(pydoc.describe(c), 'instance of C')
expected = 'instance of C in module %s' % __name__
self.assertIn(expected, pydoc.render_doc(c))
示例15: usage
def usage():
usage_text = '''
This script is a barebones version of query_cqadupstack.py which can be downloaded from https://github.com/D1Doris/CQADupStack/.
It is called from insertrecords.cgi (see https://github.com/D1Doris/AnnotateCQADupStack), to fill a database with
posts from CQADupStack, the StackExchange data which can be downloaded from http://nlp.cis.unimelb.edu.au/resources/cqadupstack/,
so they can be annotated.
The script contains a main function called load_subforum(). It has one argument: a StackExchange (CQADupStack) subforum.zip file.
load_subforum() uses this file to create a 'Subforum' object and returns this.
Subforum objects can be queried using the following methods:
'''
strhelp = pydoc.render_doc(Subforum, "Help on %s")
i = strhelp.find('below')
strhelp = strhelp[i+9:]
usage_text += strhelp
usage_text += '\n\n -----------------------------'
usage_text += '\n\n Here are some examples of how to use the script:'
usage_text += '''\n\n >>> import query_cqadupstack_barebones as qcqa
>>> o = qcqa.load_subforum('/home/hoogeveen/datasets/CQADupStack/webmasters.zip')
>>> o.get_posttitle('18957')
u'What do you consider a "mobile" device?'
>>> o.get_postbody('18957')'''
usage_text += u'<p>I\'m implementing a mobile-friendly version of our corporate web site and will be using <a href="http://wurfl.sourceforge.net/" rel="nofollow" title="WURFL">WURFL</a> to detect mobile browsers and redirect them to our mobile site. Having recently purchased an Android tablet, I\'ve found that many sites consider it to be a mobile device even though it has a large 10" screen and it\'s perfectly capable of handling sites designed using standard desktop resolutions.</p>\n\n<p>My plan is to use WURFL, examine the device capabilities and treat anything with a resolution width of less than 700px as a mobile device, but I\'d like some input as to that sweet spot for determining mobile vs desktop.</p>\n'
usage_text += '\n\n -----------------------------'
usage_text += '\n\n Please see the README file that came with this script for more information on the data.\n'
print usage_text
sys.exit(' ')