def help(obj): """ Display HTML help for ``obj``, a Python object, module, etc. This help is often more extensive than that given by 'obj?'. This function does not return a value --- it prints HTML as a side effect. .. note:: This a wrapper around the built-in help. If formats the output as HTML without word wrap, which looks better in the notebook. INPUT: - ``obj`` - a Python object, module, etc. TESTS:: sage: import numpy.linalg sage: current_dir = os.getcwd() sage: os.chdir(tmp_dir('server_doctest')) sage: sagenb.misc.support.help(numpy.linalg.norm) <html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d"> <a target='_new' href='cell://docs-....html'>Click to open help window</a> <br></font></tr></td></table></html> sage: os.chdir(current_dir) """ from pydoc import resolve, html, describe import sagenb.notebook.interact as interact print( '<html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">' ) object, name = resolve(obj) page = html.page(describe(object), html.document(object, name)) page = page.replace('<a href', '<a ') n = 0 while True: filename = 'docs-%s.html' % n if not os.path.exists(filename): break n += 1 open(filename, 'w').write(page) print( " <a target='_new' href='cell://%s'>Click to open help window</a> " % filename) print('<br></font></tr></td></table></html>')
def help(obj): """ Display HTML help for ``obj``, a Python object, module, etc. This help is often more extensive than that given by 'obj?'. This function does not return a value --- it prints HTML as a side effect. .. note:: This a wrapper around the built-in help. If formats the output as HTML without word wrap, which looks better in the notebook. INPUT: - ``obj`` - a Python object, module, etc. TESTS:: sage: import numpy.linalg sage: import os, sage.misc.misc ; current_dir = os.getcwd() sage: os.chdir(sage.misc.misc.tmp_dir('server_doctest')) sage: sage.server.support.help(numpy.linalg.norm) <html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d"> <a target='_new' href='cell://docs-....html'>Click to open help window</a> <br></font></tr></td></table></html> sage: os.chdir(current_dir) """ from pydoc import resolve, html, describe import sagenb.notebook.interact as interact print '<html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">' object, name = resolve(obj) page = html.page(describe(object), html.document(object, name)) page = page.replace("<a href", "<a ") n = 0 while True: filename = "docs-%s.html" % n if not os.path.exists(filename): break n += 1 open(filename, "w").write(page) print " <a target='_new' href='cell://%s'>Click to open help window</a> " % filename print "<br></font></tr></td></table></html>"
def help(obj): """ Display help on s. .. note:: This a wrapper around the builtin help. If formats the output as HTML without word wrap, which looks better in the notebook. INPUT: - ``s`` - Python object, module, etc. OUTPUT: prints out help about s; it's often more more extensive than foo? TESTS:: sage: import numpy.linalg sage: sage.server.support.help(numpy.linalg.norm) <html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d"> <a target='_new' href='cell://docs-....html'>Click to open help window</a> <br></font></tr></td></table></html> """ from pydoc import resolve, html, describe import sage.server.notebook.interact as interact print '<html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">' object, name = resolve(obj) page = html.page(describe(object), html.document(object, name)) page = page.replace('<a href','<a ') n = 0 while True: filename = 'docs-%s.html'%n if not os.path.exists(filename): break n += 1 open(filename, 'w').write(page) print " <a target='_new' href='cell://%s'>Click to open help window</a> "%filename print '<br></font></tr></td></table></html>'
import xbmc MODULES = ('xbmc', 'xbmcplugin', 'xbmcgui', 'xbmcaddon', 'xbmcvfs') if (__name__ == "__main__"): Addon = xbmcaddon.Addon('script.pydoc-html-generator') Dialog = xbmcgui.Dialog() getString = Addon.getLocalizedString if not Addon.getSetting('save_path'): if Dialog.yesno(getString(30001), # choose folder getString(30002), # Please choose a folder getString(30005)): # Do you want to set now? Addon.openSettings() if Addon.getSetting('save_path'): for module_name in MODULES: try: object, name = resolve(module_name, 0) page = html.page(describe(object), html.document(object, name)) file_path = '%s/%s.html' % (Addon.getSetting('save_path'), module_name) file = open(xbmc.translatePath(file_path), 'w') file.write(page) file.close() except: xbmc.log('Unable to save doc for module "%s"' % module_name) Dialog.ok(getString(30003), # Finish getString(30004), # HTML pydoc's generated in xbmc.translatePath(Addon.getSetting('save_path'))) # path