コード例 #1
0
def writedoc(key,top=False):
    """Write HTML documentation to a file in the current directory."""
    if(type(key) == str and (key == "modules" or key == "/.")):
        heading = pydoc.html.heading(
            '<br><big><big><strong>&nbsp;'
            'Python: Index of Modules'
            '</strong></big></big>',
            '#ffffff', '#7799ee')
        builtins = []
        for name in sys.builtin_module_names:
            builtins.append('<a href="%s">%s</a>' % (cgi.escape(name,quote=True), cgi.escape(name)))
        indices = ['<p>Built-in modules: ' + cgi.escape(join(builtins, ', '))]
        seen = {}
        for dir in pydoc.pathdirs():
            indices.append(pydoc.html.index(dir, seen))
        print cleanlinks(heading + join(indices))
        return

    if(type(key) != types.ModuleType):
        object = pydoc.locate(key)
        if(object == None and top):
            print "could not locate module/object for key " + \
                   cgi.escape(key) + "<br><a href=\"pydoc:modules\">go to index</a>";
    else:
        object = key
            
    if object:
        print cleanlinks(pydoc.html.page(pydoc.describe(object), pydoc.html.document(object)))
コード例 #2
0
ファイル: Doc.py プロジェクト: chadwhitacre/public
    def getindex(self):
        """Return an HTML list of packages and modules in site-packages.
        """

        html = ['<div id="index"><div id="index-hack">']
        seen = []

        for path in pydoc.pathdirs():

            if 'site-packages' not in path:
                continue

            # Generate a list of importables.
            # ===============================
            # Package spam/__init__.py takes precedence over module spam.py.

            index = []

            for name in os.listdir(path):
                if name.startswith('_'):
                    continue
                fullpath = os.path.join(path, name)
                if pydoc.ispackage(fullpath):
                    if name not in seen:
                        seen.append(name)
                        index.append(name)
                elif os.path.isfile(fullpath):
                    modname = inspect.getmodulename(fullpath)
                    if modname:
                        if modname not in seen:
                            index.append(modname)
                            seen.append(modname)

            index.sort()

            # Build the HTML.
            # ===============

            html.append('<h3>%s</h3>' % path)
            html.append('<ul class="index">')
            for name in index:
                html.append('<li><a href="%s/">%s</a></li>' % (name, name))
            html.append('</ul>')

            #contents = self.multicolumn(modpkgs, self.modpkglink)

        html.append('</div></div>')

        return '\n'.join(html)
コード例 #3
0
ファイル: documentation.py プロジェクト: CrazyPython/SPE
    def index(self):
        heading = pydoc.html.heading(
'<big><big><strong>Python: Index of Modules</strong></big></big>',
'#ffffff', '#7799ee')
        def bltinlink(name):
            return '<a href="%s.html">%s</a>' % (name, name)
        names = filter(lambda x: x != '__main__',
                       sys.builtin_module_names)
        contents = pydoc.html.multicolumn(names, bltinlink)
        indices = ['<p>' + pydoc.html.bigsection(
            'Built-in Modules', '#ffffff', '#ee77aa', contents)]
        seen = {}
        for dir in pydoc.pathdirs():
            indices.append(pydoc.html.index(dir, seen))
        contents = heading + pydoc.join(indices) + '''<p align=right>
<font color="#909090" face="helvetica, arial"><strong>
pydoc</strong> by Ka-Ping Yee &lt;[email protected]&gt;</font>'''
        self.SetPage(contents)
コード例 #4
0
    def index(self):
        heading = pydoc.html.heading(
            '<big><big><strong>Python: Index of Modules</strong></big></big>',
            '#ffffff', '#7799ee')

        def bltinlink(name):
            return '<a href="%s.html">%s</a>' % (name, name)

        names = filter(lambda x: x != '__main__', sys.builtin_module_names)
        contents = pydoc.html.multicolumn(names, bltinlink)
        indices = [
            '<p>' + pydoc.html.bigsection('Built-in Modules', '#ffffff',
                                          '#ee77aa', contents)
        ]
        seen = {}
        for dir in pydoc.pathdirs():
            indices.append(pydoc.html.index(dir, seen))
        contents = heading + pydoc.join(indices) + '''<p align=right>
<font color="#909090" face="helvetica, arial"><strong>
pydoc</strong> by Ka-Ping Yee &lt;[email protected]&gt;</font>'''
        self.SetPage(contents)
コード例 #5
0
 def __init__(self):
     roots = map(lambda dir: (dir, ''), pathdirs())
     Scanner.__init__(self, roots, self.submodules, self.isnewpackage)
     self.inodes = map(lambda (dir, pkg): os.stat(dir).st_ino, roots)
コード例 #6
0
 def __init__(self):
     roots = map(lambda dir: (dir, ''), pathdirs())
     Scanner.__init__(self, roots, self.submodules, self.isnewpackage)
     self.inodes = map(lambda (dir, pkg): os.stat(dir).st_ino, roots)
コード例 #7
0
                return 'text/html', pydoc.html.page(path, pydoc.html.escape(str(value)))
            print obj
            if obj:
                return 'text/html', pydoc.html.page(pydoc.describe(obj), pydoc.html.document(obj, path))
            else:
                return 'text/html', pydoc.html.page(path, 'no Python documentation found for %s' % repr(path))
        else:
            heading = pydoc.html.heading('<big><big><strong>Python: Index of Modules</strong></big></big>',
                '#ffffff', '#7799ee')
            def bltinlink(name):
                return '<a href="/python/%s.html">%s</a>' % (name, name)
            names = filter(lambda x: x != '__main__', sys.builtin_module_names)
            contents = pydoc.html.multicolumn(names, bltinlink)
            indices = ['<p>' + pydoc.html.bigsection('Built-in Modules', '#ffffff', '#ee77aa', contents)]
            seen = {}
            for dir in pydoc.pathdirs():
                indices.append(pydoc.html.index(dir, seen))
            contents = heading + ''.join(indices) + '''<p align=right><font color="#909090" face="helvetica, arial">
                <strong>pydoc</strong> by Ka-Ping Yee &lt;[email protected]&gt;</font>'''
            return 'text/html', pydoc.html.page('Index of Modules', contents)



def startServer():
    global helpServer
    helpServer = HelpServer()



def stopServer():
    global helpServer
コード例 #8
0
ファイル: modpydoc.py プロジェクト: PyTis/PyTis
        except ErrorDuringImport, value:
            req.write(html.page(path, html.escape(str(value))))
            return apache.OK
        if obj:
            req.write(html.page(describe(obj), html.document(obj, path)))
            return apache.OK
        else:
            req.write(html.page(path,
                'no Python documentation found for %s' % repr(path)))
            return apache.OK
    else:
        heading = html.heading(
            '<big><big><strong>Python: Index of Modules</strong></big></big>',
            '#ffffff', '#7799ee')
        def bltinlink(name):
            return '<a href="%s.html">%s</a>' % (name, name)
        names = filter(lambda x: x != '__main__',
                       sys.builtin_module_names)
        contents = html.multicolumn(names, bltinlink)
        indices = ['<p>' + html.bigsection(
            'Built-in Modules', '#ffffff', '#ee77aa', contents)]
        seen = {}
        for dir in pathdirs():
            indices.append(html.index(dir, seen))
        contents = heading + ' '.join(indices) + '''<p align=right>
<font color="#909090" face="helvetica, arial"><strong>
pydoc</strong> by Ka-Ping Yee &lt;[email protected]&gt;</font>'''
        req.write(html.page('Index of Modules', contents))
        return apache.OK

コード例 #9
0
 def update_event(self, inp=-1):
     self.set_output_val(0, pydoc.pathdirs())