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


Python pydoc.describe函数代码示例

本文整理汇总了Python中pydoc.describe函数的典型用法代码示例。如果您正苦于以下问题:Python describe函数的具体用法?Python describe怎么用?Python describe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_classic_class

 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:49476291,项目名称:android-plus-plus,代码行数:7,代码来源:test_pydoc.py

示例2: test_classic_class

 def test_classic_class(self):
     class C: "Classic class"
     c = C()
     self.assertEqual(pydoc.describe(C), 'class C')
     self.assertEqual(pydoc.describe(c), 'C')
     expected = 'C in module %s' % __name__
     self.assertTrue(expected in pydoc.render_doc(c))
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:7,代码来源:test_pydoc.py

示例3: dump_object

def dump_object(name, tmp_obj):
    print ">>>>>>>>>>>>>>>>>>>>>>>>>>", name, tmp_obj
    print describe(tmp_obj)

    # From line 921, method docmodule:
    classes = []
    for key, value in inspect.getmembers(tmp_obj, inspect.isclass):
        if (inspect.getmodule(value) or tmp_obj) is tmp_obj:
            classes.append((key, value))
            dump_object(key, value)
    funcs = []
    for key, value in inspect.getmembers(tmp_obj, inspect.isroutine):
        if inspect.isbuiltin(value) or inspect.getmodule(value) is tmp_obj:
            funcs.append((key, value))
    data = []
    for key, value in inspect.getmembers(tmp_obj, isdata):
        if key not in ['__builtins__', '__doc__']:
            data.append((key, value))
    methods = []
    for key, value in inspect.getmembers(tmp_obj, inspect.ismethod):
        if key not in ['__builtins__', '__doc__']:
            methods.append((key, value))

    print "C:", classes
    print "\nF:", funcs
    print "\nD:", data
    print "\nM:", methods
    for m in methods:
        print inspect.getargspec(m[1]), inspect.getdoc(m[1]), inspect.getcomments(m[1])
    print "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
开发者ID:unioslo,项目名称:cerebrum,代码行数:30,代码来源:ext_doc.py

示例4: test_class

    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.assertTrue(expected in pydoc.render_doc(c))
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:8,代码来源:test_pydoc.py

示例5: test_class

    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))
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:10,代码来源:test_pydoc.py

示例6: _generate_assertions_html

    def _generate_assertions_html(self, lang):
        object = pikzie.assertions.Assertions
        html_name = "html/assertions.html"
        translation = None
        if lang:
            html_name = "%s.%s" % (html_name, lang)
            translation = gettext.translation("pikzie", "data/locale", [lang])

        print(html_name)

        original_getdoc = pydoc.getdoc
        def getdoc(object):
            document = original_getdoc(object)
            if document == "":
                return document
            else:
                return translation.gettext(document)
        if translation:
            pydoc.getdoc = getdoc
        page = pydoc.html.page(pydoc.describe(object),
                               pydoc.html.document(object, "assertions"))
        pydoc.getdoc = original_getdoc

        html = file(html_name, "w")
        html.write(page.strip())
        html.close()
开发者ID:clear-code,项目名称:pikzie,代码行数:26,代码来源:setup.py

示例7: doc2

def doc2(thing, title="Python Library Documentation: %s", forceload=0):
    """Display text documentation, given an object or a path to an object."""
    import types

    try:
        object, name = pydoc.resolve(thing, forceload)
        desc = pydoc.describe(object)
        module = mygetmodule(object)
        if name and "." in name:
            desc += " in " + name[: name.rfind(".")]
        elif module and module is not object:
            desc += " in module " + module.__name__

        if not (
            inspect.ismodule(object)
            or inspect.isclass(object)
            or inspect.isroutine(object)
            or isinstance(object, property)
        ):
            # If the passed object is a piece of data or an instance,
            # document its available methods instead of its value.

            # if this is a instance of used defined old-style class
            if type(object) == types.InstanceType:
                object = object.__class__
            else:
                object = type(object)
            desc += " object"
        pydoc.pager(title % desc + "\n\n" + pydoc.text.document(object, name))
    except (ImportError, pydoc.ErrorDuringImport), value:
        print value
开发者ID:wvengen,项目名称:lgipilot,代码行数:31,代码来源:gangadoc.py

示例8: gethtmldoc

def gethtmldoc(thing, forceload=0):
    obj, name = pydoc.resolve(thing, forceload)
    page = pydoc.html.page(
        pydoc.describe(obj),
        pydoc.html.document(obj, name)
    )
    return page
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:7,代码来源:pydochelper.py

示例9: writedoc

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)))
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:28,代码来源:kde_pydoc.py

示例10: PrintHtml

def PrintHtml(name, things):
  """Print HTML documentation to stdout."""
  ambiguous = len(things) > 1
  
  content = ""
  for thing in things:
    obj, name = pydoc.resolve(thing, forceload=0)
    title = pydoc.describe(obj)
    if ambiguous:
      if inspect.ismethoddescriptor(obj):
        content += '\n\n<h2>method %s in class %s</h2>\n' % (obj.__name__, obj.__dict__)
      else:
        content += '<h2>%s in module <a href="py:%s">%s</a></h2>\n' % (title, obj.__module__, obj.__module__)
    content += pydoc.html.document(obj, name)
  
  if ambiguous:
    title = 'Matches for "%s"' % name
    content = '<h1>%s</h1>\n\n%s' % (title, content)
  
  page = pydoc.html.page(title, content)
  
  # Note: rewriting the anchors in a form more useful to Evergreen should be in Evergreen, not here.
  # The rewriting here should be generally useful to anyone or anything that needs Python documentation.
  
  # Remove a couple of useless (and seemingly broken) links.
  page = page.replace('<a href=".">index</a><br>', '')
  page = re.sub('<br><a href="[^"]+\.html">Module Docs</a>', '', page)
  
  # There's a bug in pydoc that makes it output the text of the "Modules" section in cyan instead of white.
  page = re.sub('"#fffff"', '"#ffffff"', page)
  # The explicit font specifications are unnecessary manual uglification.
  page = re.sub(' face="[^"]+"', '', page);
  
  sys.stdout.write(page + '\n')
开发者ID:007durgesh219,项目名称:jessies,代码行数:34,代码来源:epydoc.py

示例11: _writeclientdoc

def _writeclientdoc(doc, thing, forceload=0):
    """Write HTML documentation to a file in the current directory.
    """
    docmodule = pydoc.HTMLDoc.docmodule
    def strongarm(self, object, name=None, mod=None, *ignored):
        result = docmodule(self, object, name, mod, *ignored)

        # Grab all the aliases to pyclasses and create links.
        nonmembers = []
        push = nonmembers.append
        for k,v in inspect.getmembers(object, inspect.isclass):
            if inspect.getmodule(v) is not object 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:
        object, name = pydoc.resolve(thing, forceload)
        page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
        name = os.path.join(doc, name + '.html')
        file = open(name, 'w')
        file.write(page)
        file.close()
    except (ImportError, pydoc.ErrorDuringImport), value:
        log.debug(str(value))
开发者ID:mikedougherty,项目名称:ZSI,代码行数:27,代码来源:commands.py

示例12: GenerateHTMLForModule

def GenerateHTMLForModule(module):
  html = pydoc.html.page(pydoc.describe(module),
                         pydoc.html.document(module, module.__name__))

  # pydoc writes out html with links in a variety of funky ways. We need
  # to fix them up.
  assert not telemetry_dir.endswith(os.sep)
  links = re.findall('(<a href="(.+?)">(.+?)</a>)', html)
  for link_match in links:
    link, href, link_text = link_match
    if not href.startswith('file:'):
      continue

    new_href = href.replace('file:', '')
    new_href = new_href.replace(telemetry_dir, '..')
    new_href = new_href.replace(os.sep, '/')

    new_link_text = link_text.replace(telemetry_dir + os.sep, '')

    new_link = '<a href="%s">%s</a>' % (new_href, new_link_text)
    html = html.replace(link, new_link)

  # pydoc writes out html with absolute path file links. This is not suitable
  # for checked in documentation. So, fix up the HTML after it is generated.
  #html = re.sub('href="file:%s' % telemetry_dir, 'href="..', html)
  #html = re.sub(telemetry_dir + os.sep, '', html)
  return html
开发者ID:jiayuwang,项目名称:chromium,代码行数:27,代码来源:update_docs.py

示例13: local_docs

def local_docs(word):
    import pydoc
    try:
        obj, name = pydoc.resolve(word)
    except ImportError:
        return None
    desc = pydoc.describe(obj)
    return [(desc, urljoin(pydoc_url()[0], "%s.html" % word))]
开发者ID:prymatex,项目名称:python.tmbundle,代码行数:8,代码来源:docmate.py

示例14: _writebrokedoc

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))
        file = open(fname, 'w')
        file.write(page)
        file.close()
    except (ImportError, pydoc.ErrorDuringImport), value:
        log.debug(str(value))
开发者ID:mikedougherty,项目名称:ZSI,代码行数:9,代码来源:commands.py

示例15: custom_writedoc

def custom_writedoc(thing, forceload=0):
    """Write HTML documentation to specific directory"""
    try:
        object, name = pydoc.resolve(thing, forceload)
        page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
        file = open(PYDOC_OUTPUT_DIR + name + '.html', 'w')
        file.write(page)
        file.close()
        print 'wrote', PYDOC_OUTPUT_DIR + name + '.html'
    except (ImportError, pydoc.ErrorDuringImport), value:
        print value
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:11,代码来源:pydocx.py


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