Python pydoc 模块,describe() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用pydoc.describe()

项目:vspheretools    作者:devopshq    | 项目源码 | 文件源码
def _writedoc(doc, thing, forceload=0):
    """Write HTML documentation to a file in the current directory.
    """
    try:
        obj, name = pydoc.resolve(thing, forceload)
        page = pydoc.html.page(pydoc.describe(obj), pydoc.html.document(obj, name))
        fname = os.path.join(doc, name + '.html')
        fd = open(fname, 'w')
        fd.write(page)
        fd.close()
    except (ImportError, pydoc.ErrorDuringImport):
        traceback.print_exc(sys.stderr)
    else:
        return name + '.html'
项目:vspheretools    作者:devopshq    | 项目源码 | 文件源码
def _writeclientdoc(doc, thing, forceload=0):
    """Write HTML documentation to a file in the current directory.
    """
    docmodule = pydoc.HTMLDoc.docmodule
    def strongarm(self, obj, name=None, mod=None, *ignored):
        result = docmodule(self, obj, name, mod, *ignored)

        # Grab all the aliases to pyclasses and create links.
        nonmembers = []
        push = nonmembers.append
        for k,v in inspect.getmembers(obj, inspect.isclass):
            if inspect.getmodule(v) is not obj and getattr(v,'typecode',None) is not None:
                push('<a href="%s.html">%s</a>: pyclass alias<br/>' %(v.__name__,k))

        result += self.bigsection('Aliases', '#ffffff', '#eeaa77', ''.join(nonmembers))
        return result

    pydoc.HTMLDoc.docmodule = strongarm
    try:
        obj, name = pydoc.resolve(thing, forceload)
        page = pydoc.html.page(pydoc.describe(obj), pydoc.html.document(obj, name))
        name = os.path.join(doc, name + '.html')
        fd = open(name, 'w')
        fd.write(page)
        fd.close()
    except (ImportError, pydoc.ErrorDuringImport), value:
        log.debug(str(value))

    pydoc.HTMLDoc.docmodule = docmodule
项目:vspheretools    作者:devopshq    | 项目源码 | 文件源码
def _writebrokedoc(doc, ex, name, forceload=0):
    try:
        fname = os.path.join(doc, name + '.html')
        page = pydoc.html.page(pydoc.describe(ex), pydoc.html.document(str(ex), fname))
        fd = open(fname, 'w')
        fd.write(page)
        fd.close()
    except (ImportError, pydoc.ErrorDuringImport), value:
        log.debug(str(value))

    return name + '.html'
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
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))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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))
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
项目:pypydispatcher    作者:scrapy    | 项目源码 | 文件源码
def process( self ):
        """Having added all of the base and/or interesting modules,
        proceed to generate the appropriate documentation for each
        module in the appropriate directory, doing the recursion
        as we go."""
        try:
            while self.pending:
                try:
                    if self.completed.has_key( self.pending[0] ):
                        raise AlreadyDone( self.pending[0] )
                    self.info( """Start %s"""% (repr(self.pending[0])))
                    object = pydoc.locate ( self.pending[0] )
                    self.info( """   ... found %s"""% (repr(object.__name__)))
                except AlreadyDone:
                    pass
                except pydoc.ErrorDuringImport, value:
                    self.info( """   ... FAILED %s"""% (repr( value)))
                    self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                except (SystemError, SystemExit), value:
                    self.info( """   ... FAILED %s"""% (repr( value)))
                    self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                except Exception, value:
                    self.info( """   ... FAILED %s"""% (repr( value)))
                    self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                else:
                    page = self.formatter.page(
                        pydoc.describe(object),
                        self.formatter.docmodule(
                            object,
                            object.__name__,
                            packageContext = self,
                        )
                    )
                    file = open (
                        os.path.join(
                            self.destinationDirectory,
                            self.pending[0] + ".html",
                        ),
                        'w',
                    )
                    file.write(page)
                    file.close()
                    self.completed[ self.pending[0]] = object
                del self.pending[0]
        finally:
            for item in self.warnings:
                print item