当前位置: 首页>>代码示例>>Python>>正文


Python pydoc.render_doc方法代码示例

本文整理汇总了Python中pydoc.render_doc方法的典型用法代码示例。如果您正苦于以下问题:Python pydoc.render_doc方法的具体用法?Python pydoc.render_doc怎么用?Python pydoc.render_doc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pydoc的用法示例。


在下文中一共展示了pydoc.render_doc方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_builtin

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_builtin(self):
        for name in ('str', 'str.translate', '__builtin__.str',
                     '__builtin__.str.translate'):
            # test low-level function
            self.assertIsNotNone(pydoc.locate(name))
            # test high-level function
            try:
                pydoc.render_doc(name)
            except ImportError:
                self.fail('finding the doc of {!r} failed'.format(name))

        for name in ('not__builtin__', 'strrr', 'strr.translate',
                     'str.trrrranslate', '__builtin__.strrr',
                     '__builtin__.str.trrranslate'):
            self.assertIsNone(pydoc.locate(name))
            self.assertRaises(ImportError, pydoc.render_doc, name) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_pydoc.py

示例2: test_builtin

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_builtin(self):
        for name in ('str', 'str.translate', '__builtin__.str',
                     '__builtin__.str.translate'):
            # test low-level function
            self.assertIsNotNone(pydoc.locate(name))
            # test high-level function
            try:
                pydoc.render_doc(name)
            except ImportError:
                self.fail('finding the doc of {!r} failed'.format(o))

        for name in ('not__builtin__', 'strrr', 'strr.translate',
                     'str.trrrranslate', '__builtin__.strrr',
                     '__builtin__.str.trrranslate'):
            self.assertIsNone(pydoc.locate(name))
            self.assertRaises(ImportError, pydoc.render_doc, name) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:18,代码来源:test_pydoc.py

示例3: test_builtin

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_builtin(self):
        for name in ('str', 'str.translate', 'builtins.str',
                     'builtins.str.translate'):
            # test low-level function
            self.assertIsNotNone(pydoc.locate(name))
            # test high-level function
            try:
                pydoc.render_doc(name)
            except ImportError:
                self.fail('finding the doc of {!r} failed'.format(name))

        for name in ('notbuiltins', 'strrr', 'strr.translate',
                     'str.trrrranslate', 'builtins.strrr',
                     'builtins.str.trrranslate'):
            self.assertIsNone(pydoc.locate(name))
            self.assertRaises(ImportError, pydoc.render_doc, name) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_pydoc.py

示例4: __getattr__

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def __getattr__(self, attr):
        if attr.startswith('do_'):
            method = getattr(self.client, attr[3:])

            def wrapper(arg):
                args = arg.split()
                kwargs = dict(a.split('=') for a in args if '=' in a)
                args = [a for a in args if '=' not in a]
                try:
                    return method(*args, **kwargs)
                except DiscourseError as e:
                    print (e, e.response.text)
                    return e.response
            return wrapper

        elif attr.startswith('help_'):
            method = getattr(self.client, attr[5:])

            def wrapper():
                self.output.write(pydoc.render_doc(method))

            return wrapper

        raise AttributeError 
开发者ID:tindie,项目名称:pydiscourse,代码行数:26,代码来源:main.py

示例5: all_indicators_doc

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def all_indicators_doc():
    all_funcs = inspect.getmembers(sys.modules[__name__], inspect.isfunction)
    ret = ""
    for f in all_funcs:
        ret += pydoc.render_doc(f[1], renderer = pydoc.plaintext).splitlines()[2] + "\n"
    return ret 
开发者ID:geome-mitbbs,项目名称:QTS_Research,代码行数:8,代码来源:Quant_Indicators.py

示例6: test_non_str_name

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_pydoc.py

示例7: test_module

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_module(self):
        # Check that pydocfodder module can be described
        from test import pydocfodder
        doc = pydoc.render_doc(pydocfodder)
        self.assertIn("pydocfodder", doc) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_pydoc.py

示例8: test_classic_class

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_pydoc.py

示例9: test_class

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_pydoc.py

示例10: test_render_doc

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_render_doc(self):
        # render_doc is robust against unicode in docstrings
        doc = pydoc.render_doc(self.Q)
        self.assertIsInstance(doc, str) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_pydoc.py

示例11: test_tempfilepager

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_tempfilepager(self):
        # tempfilepager does not choke on unicode
        doc = pydoc.render_doc(self.Q)

        output = {}
        def mock_system(cmd):
            filename = cmd.strip()[1:-1]
            self.assertEqual('"' + filename + '"', cmd.strip())
            output['content'] = open(filename).read()
        saved, os.system = os.system, mock_system
        try:
            pydoc.tempfilepager(doc, '')
            self.assertEqual(output['content'], pydoc._encode(doc))
        finally:
            os.system = saved 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_pydoc.py

示例12: test_plainpager

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_plainpager(self):
        # plainpager does not choke on unicode
        doc = pydoc.render_doc(self.Q)

        # Note: captured_stdout is too permissive when it comes to
        # unicode, and using it here would make the test always
        # pass.
        with test.test_support.temp_cwd():
            with open('output', 'w') as f:
                saved, sys.stdout = sys.stdout, f
                try:
                    pydoc.plainpager(doc)
                finally:
                    sys.stdout = saved
            self.assertIn('Rational numbers:', open('output').read()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_pydoc.py

示例13: test_ttypager

# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import render_doc [as 别名]
def test_ttypager(self):
        # ttypager does not choke on unicode
        doc = pydoc.render_doc(self.Q)
        # Test ttypager
        with test.test_support.temp_cwd(), test.test_support.captured_stdin():
            with open('output', 'w') as f:
                saved, sys.stdout = sys.stdout, f
                try:
                    pydoc.ttypager(doc)
                finally:
                    sys.stdout = saved
            self.assertIn('Rational numbers:', open('output').read()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_pydoc.py


注:本文中的pydoc.render_doc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。