當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。