• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pydoc.splitdoc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: splitdocfor

def splitdocfor(path):
    """split the docstring for a path
    
    valid paths are::
        
        ./path/to/module.py
        ./path/to/module.py:SomeClass.method
    
    returns (description, long_description) from the docstring for path 
    or (None, None) if there isn't a docstring.
    
    Example::
    
        >>> splitdocfor("./wsgi_intercept/__init__.py")[0]
        'installs a WSGI application in place of a real URI for testing.'
        >>> splitdocfor("./wsgi_intercept/__init__.py:WSGI_HTTPConnection.get_app")[0]
        'Return the app object for the given (host, port).'
        >>> 
        
    """
    if ":" in path:
        filename, objpath = path.split(':')
    else:
        filename, objpath = path, None
    inspector = DocInspector(filename)
    visitor.walk(compiler.parseFile(filename), inspector)
    if objpath is None:
        if inspector.top_level_doc is None:
            return None, None
        return pydoc.splitdoc(inspector.top_level_doc)
    else:
        if inspector[objpath] is None:
            return None, None
        return pydoc.splitdoc(inspector[objpath])
开发者ID:Maseli,项目名称:fixofx,代码行数:34,代码来源:build_docs.py


示例2: main

def main():
    usage = __import__(__name__).__doc__.strip()
    usage += "\n\nCommands:\n\n"
    commands = {}
    for func in sorted(COMMANDS):
        name = func.__name__.strip().replace("cmd_", "").replace("_", "-")
        commands[name] = func
        head, tail = pydoc.splitdoc(pydoc.getdoc(func))
        cmd_help = textwrap.fill(tail, width=70).replace("\n", "\n    ").strip()
        usage += "%s\n    %s\n\n" % (head, cmd_help)
    usage = usage.strip()

    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    (options, args) = parser.parse_args()

    if len(args) < 1:
        parser.error("No command given")

    cmd_name = args.pop(0)
    cmd = commands.get(cmd_name)

    if cmd is None:
        parser.error("Unknown command %s" % cmd_name)
    else:
        cmd(args)
开发者ID:pv,项目名称:pydocweb,代码行数:26,代码来源:pydoc-tool.py


示例3: get_module_meta

def get_module_meta(modfile):
    docstring = None
    version = [(tokenize.NAME, '__version__'), (tokenize.OP, '=')]
    f = open(modfile,'r')
    for toknum, tokval, _, _, _ in tokenize.generate_tokens(lambda: f.readline()):
        if not docstring:
            if toknum == tokenize.STRING:
                docstring = tokval
                continue
        if len(version):
            if (toknum, tokval) == version[0]:
                version.pop(0)
        else:
            version = tokval
            break
    if docstring is None:
        raise ValueError("could not find docstring in %s" % modfile)
    if not isinstance(version, basestring):
        raise ValueError("could not find __version__ in %s" % modfile)
    # unquote :
    docstring = docstring[3:]
    docstring = docstring[:-3]
    version = version[1:]
    version = version[:-1]
    return (version,) + pydoc.splitdoc(docstring)
开发者ID:Helpfulpaw,项目名称:chalmers-web,代码行数:25,代码来源:setup.py


示例4: setup

def setup(args=None):
    # make sure our directory is at the front of sys.path
    module = metadata('backupmgr')

    # get the version and description from the source
    version = module.__version__
    description = pydoc.splitdoc(pydoc.getdoc(module))[0]
    author, author_email = email.utils.parseaddr(module.__authors__[0])

    # get the long description from README-type files
    long_description = []
    for path in READMES:
        with open(os.path.join(SRCROOT, path), 'r') as fh:
            long_description.append(fh.read())
    long_description = '\n'.join([ x for x in long_description if x ])
    # use setuptools to do the rest
    setuptools.setup(
        name=pkg_resources.safe_name(module.__name__),
        packages=setuptools.find_packages(),
        version=version,
        description=description,
        author=author,
        author_email=author_email,
        zip_safe=True,
        #url=None,
        install_requires=["python-dateutil"],
        long_description=long_description,
        license='BSD',
        classifiers=[
            'Development Status :: 3 - Alpha',
            'Intended Audience :: Developers'
        ])
开发者ID:theg5prank,项目名称:backupmgr,代码行数:32,代码来源:setup.py


示例5: hh

 def hh(cmd = None):
     """Get help on a command."""
     shell_funcs['hh'] = hh
     import pydoc
     from inspect import getargspec, formatargspec
     if not cmd:
         print "\nUse self.addrspace for Kernel/Virtual AS"
         print "Use self.addrspace.base for Physical AS"
         print "Use self.proc to get the current _EPROCESS object"
         print "  and self.proc.get_process_address_space() for the current process AS"
         print "  and self.proc.get_load_modules() for the current process DLLs\n"
         for f in sorted(shell_funcs):
             doc = pydoc.getdoc(shell_funcs[f])
             synop, _full = pydoc.splitdoc(doc)
             print "{0:40} : {1}".format(f + formatargspec(*getargspec(shell_funcs[f])), synop)
         print "\nFor help on a specific command, type 'hh(<command>)'"
     elif type(cmd) == str:
         try:
             doc = pydoc.getdoc(shell_funcs[cmd])
         except KeyError:
             print "No such command: {0}".format(cmd)
             return
         print doc
     else:
         doc = pydoc.getdoc(cmd)
         print doc
开发者ID:B-Rich,项目名称:amark,代码行数:26,代码来源:volshell.py


示例6: module_section

    def module_section(self, obj, package_context ):
        """Create a module-links section for the given object (module)"""
        modules = inspect.getmembers(obj, inspect.ismodule)
        package_context.clean(modules, obj)
        package_context.recurse_scan(modules)

        if hasattr(obj, '__path__'):
            modpkgs = []
            modnames = []
            for file in os.listdir(obj.__path__[0]):
                path = os.path.join(obj.__path__[0], file)
                modname = inspect.getmodulename(file)
                if modname and modname not in modnames:
                    modpkgs.append((modname, obj.__name__, 0, 0))
                    modnames.append(modname)
                elif pydoc.ispackage(path):
                    modpkgs.append((file, obj.__name__, 1, 0))
            modpkgs.sort()
            # do more recursion here...
            for (modname, name, ya, yo) in modpkgs:
                package_context.add_interesting('.'.join((obj.__name__, modname)))
            items = []
            for (modname, name, ispackage, is_shadowed) in modpkgs:
                try:
                    # get the actual module obj...
                    #if modname == "events":
                    #    import pdb
                    #    pdb.set_trace()
                    module = pydoc.safeimport('{0}.{1}'.format(name, modname))
                    description, documentation = pydoc.splitdoc(inspect.getdoc(module))
                    if description:
                        items.append(
                            '{0} -- {1}'.format(
                                self.modpkglink((modname, name, ispackage, is_shadowed)),
                                description,
                            )
                        )
                    else:
                        items.append(
                            self.modpkglink((modname, name, ispackage, is_shadowed))
                        )
                except:
                    items.append(
                        self.modpkglink((modname, name, ispackage, is_shadowed))
                    )
            contents = '<br>'.join(items)
            result = self.bigsection(
                'Package Contents', '#ffffff', '#aa55cc', contents)
        elif modules:
            contents = self.multicolumn(
                modules,
                lambda a: self.modulelink(a[1])
            )
            result = self.bigsection(
                'Modules', '#fffff', '#aa55cc', contents)
        else:
            result = ""
        return result
开发者ID:ellepdesk,项目名称:pymodbus3,代码行数:58,代码来源:build.py


示例7: moduleSection

	def moduleSection( self, object, packageContext ):
		"""Create a module-links section for the given object (module)"""
		modules = inspect.getmembers(object, inspect.ismodule)
		packageContext.clean ( modules, object )
		packageContext.recurseScan( modules )

		if hasattr(object, '__path__'):
			modpkgs = []
			modnames = []
			for file in os.listdir(object.__path__[0]):
				path = os.path.join(object.__path__[0], file)
				modname = inspect.getmodulename(file)
				if modname and modname not in modnames:
					modpkgs.append((modname, object.__name__, 0, 0))
					modnames.append(modname)
				elif pydoc.ispackage(path):
					modpkgs.append((file, object.__name__, 1, 0))
			modpkgs.sort()
			# do more recursion here...
			for (modname, name, ya,yo) in modpkgs:
				packageContext.addInteresting( join( (object.__name__, modname), '.'))
			items = []
			for (modname, name, ispackage,isshadowed) in modpkgs:
				try:
					# get the actual module object...
##					if modname == "events":
##						import pdb
##						pdb.set_trace()
					module = pydoc.safeimport( "%s.%s"%(name,modname) )
					description, documentation = pydoc.splitdoc( inspect.getdoc( module ))
					if description:
						items.append(
							"""%s -- %s"""% (
								self.modpkglink( (modname, name, ispackage, isshadowed) ),
								description,
							)
						)
					else:
						items.append(
							self.modpkglink( (modname, name, ispackage, isshadowed) )
						)
				except:
					items.append(
						self.modpkglink( (modname, name, ispackage, isshadowed) )
					)
			contents = string.join( items, '<br>')
			result = self.bigsection(
				'Package Contents', '#ffffff', '#aa55cc', contents)
		elif modules:
			contents = self.multicolumn(
				modules, lambda (key, value), s=self: s.modulelink(value))
			result = self.bigsection(
				'Modules', '#fffff', '#aa55cc', contents)
		else:
			result = ""
		return result
开发者ID:4rc4n4,项目名称:pymodbus,代码行数:56,代码来源:build.py


示例8: formatDocString

 def formatDocString(self, doc):
     doc = pydoc.splitdoc(doc)
     bodylines = doc[1].splitlines()
     body = ""
     for idx, line in enumerate(bodylines):
         if len(line) == 0:
             body += "\n"
         body += line.strip() + " "
     ret = "%s\n\n%s" % (doc[0], body)
     return ret.strip()
开发者ID:CarlFK,项目名称:dabo,代码行数:10,代码来源:ClassDesignerPropSheet.py


示例9: get_module_meta

def get_module_meta(modfile):            
    ast = compiler.parseFile(modfile)
    modnode = ModuleVisitor()
    visitor.walk(ast, modnode)
    if modnode.mod_doc is None:
        raise RuntimeError(
            "could not parse doc string from %s" % modfile)
    if modnode.mod_version is None:
        raise RuntimeError(
            "could not parse __version__ from %s" % modfile)
    return (modnode.mod_version,) + pydoc.splitdoc(modnode.mod_doc)
开发者ID:lqc,项目名称:fixture,代码行数:11,代码来源:setup.py


示例10: build_help_cb

def build_help_cb(bot, *args, **kwargs):
    '''
    Build the help overview so it can be cached and poked at from shell.
    '''
    global HELP_OVERVIEW
    HELP_OVERVIEW += 'Available commands:\n'
    for category in sorted(COMMAND_CATEGORIES):
        if category:
            HELP_OVERVIEW += '- {}:\n'.format(category)
        for command in sorted(COMMAND_CATEGORIES[category]):
            HELP_OVERVIEW += '{}: {}\n'.format(
                command[0], pydoc.splitdoc(command[2].__doc__)[0])
开发者ID:spasticVerbalizer,项目名称:tom-bot,代码行数:12,代码来源:system_plugin.py


示例11: _default_optparse

def _default_optparse(cmd, args, option_list=[], indoc=False, outfile=False,
                      nargs=None, syspath=False):
    if indoc:
        option_list += [
            make_option("-i", action="store", dest="infile", type="str",
                        help="input file, '-' means stdin, '--' means empty input file (default)",
                        default="--")
        ]
    if outfile:
        option_list += [
            make_option("-o", action="store", dest="outfile", type="str",
                        help="output file, '-' means stdout (default)",
                        default="-")
        ]
    if syspath:
        option_list += [
            make_option("-s", "--sys-path", action="store", dest="path",
                        type="str", default=None,
                        help="prepend paths to sys.path")
        ]

    head, tail = pydoc.splitdoc(pydoc.getdoc(cmd))
    p = OptionParser(usage="pydoc-tool.py %s\n\n%s" % (head, tail),
                     option_list=option_list)
    opts, args = p.parse_args(args)

    if nargs is not None:
        if len(args) != nargs:
            p.error("wrong number of arguments")
    
    if outfile:
        if opts.outfile == '-':
            opts.outfile = sys.stdout
        else:
            opts.outfile = open(opts.outfile, 'w')
    
    if indoc:
        if opts.infile == '--':
            opts.indoc = Documentation()
        elif opts.infile == '-':
            opts.indoc = Documentation.load(sys.stdin)
        else:
            opts.indoc = Documentation.load(open(opts.infile, 'r'))
    
    if syspath:
        if opts.path is not None:
            sys.path = [os.path.abspath(x)
                        for x in opts.path.split(os.path.pathsep)] + sys.path
    return opts, args, p
开发者ID:pv,项目名称:pydocweb,代码行数:49,代码来源:pydoc-tool.py


示例12: split_doc_from_module

def split_doc_from_module(modfile):
    docstring = None
    f = open(modfile,'r')
    for toknum, tokval, _, _, _ in tokenize.generate_tokens(lambda: f.readline()):
        if toknum == tokenize.STRING:
            docstring = tokval
            break
        if toknum not in (tokenize.NL, tokenize.COMMENT):
            # we went too far
            break
    if docstring is None:
        raise ValueError("could not find docstring in %s" % modfile)
    docstring = docstring[3:]
    docstring = docstring[:-3]
    return pydoc.splitdoc(docstring)
开发者ID:EwaldHartmann,项目名称:mars,代码行数:15,代码来源:rst2trac.py


示例13: hh

 def hh(cmd = None):
     """Get help on a command."""
     shell_funcs['hh'] = hh
     import pydoc
     from inspect import getargspec, formatargspec
     if not cmd:
         for f in shell_funcs:
             doc = pydoc.getdoc(shell_funcs[f])
             synop, _full = pydoc.splitdoc(doc)
             print("{0:40} : {1}".format(f + formatargspec(*getargspec(shell_funcs[f])), synop))
         print()
         print("For help on a specific command, type 'hh(<command>)'")
     elif type(cmd) == str:
         try:
             doc = pydoc.getdoc(shell_funcs[cmd])
         except KeyError:
             print("No such command: {0}".format(cmd))
             return
         print(doc)
     else:
         doc = pydoc.getdoc(cmd)
         print(doc)
开发者ID:carmaa,项目名称:volatility-2.2-python3,代码行数:22,代码来源:volshell.py


示例14: makedocindex

def makedocindex():
    """
    Return a string with GPI Index.
    """

    import pydoc

    sections = {}

    from Ganga.Utility.strings import ItemizedTextParagraph

    for sec, names in zip(_GPIhelp_sections.keys(), _GPIhelp_sections.values()):
        itbuf = ItemizedTextParagraph(sec + ":")
        for name, obj, docstring in names:
            # if docstring not provided when exporting the object to GPI then use the docstring generated by pydoc
            if not docstring:
                docstring = pydoc.splitdoc(pydoc.getdoc(obj))[0]
            itbuf.addLine(name, docstring)

        sections[sec] = itbuf.getString()

    return _GPIhelp % sections
开发者ID:wvengen,项目名称:lgipilot,代码行数:22,代码来源:gangadoc.py


示例15: hh

 def hh(cmd=None):
     """Get help on a command."""
     shell_funcs['hh'] = hh
     import pydoc
     from inspect import getargspec, formatargspec
     if not cmd:
         for f in shell_funcs:
             doc = pydoc.getdoc(shell_funcs[f])
             synop, full = pydoc.splitdoc(doc)
             print "%-40s : %s" % (f + formatargspec(*getargspec(shell_funcs[f])), synop)
         print
         print "For help on a specific command, type 'hh(<command>)'"
     elif type(cmd) == str:
         try:
             doc = pydoc.getdoc(shell_funcs[cmd])
         except KeyError:
             print "No such command: %s" % cmd
             return
         print doc
     else:
         doc = pydoc.getdoc(cmd)
         print doc
开发者ID:carriegardner428,项目名称:virtuoso,代码行数:22,代码来源:volshell.py


示例16: list


fromlist_expects_type = str
if sys.version_info < (3, 0):
    fromlist_expects_type = bytes


main_module_name = 'daemon'
main_module_fromlist = list(map(fromlist_expects_type, [
        '_metadata']))
main_module = __import__(
        main_module_name,
        level=0, fromlist=main_module_fromlist)
metadata = main_module._metadata

(synopsis, long_description) = pydoc.splitdoc(pydoc.getdoc(main_module))

version_info = metadata.get_distribution_version_info()
version_string = version_info['version']

(maintainer_name, maintainer_email) = metadata.parse_person_field(
        version_info['maintainer'])


setup(
        name=metadata.distribution_name,
        version=version_string,
        packages=find_packages(exclude=["test"]),
        cmdclass={
            "write_version_info": version.WriteVersionInfoCommand,
            "egg_info": version.EggInfoCommand,
开发者ID:nyov,项目名称:python-daemon,代码行数:29,代码来源:setup.py


示例17: docmodule

    def docmodule(self, obj, name=None, mod=None):
        """Produce markdown documentation for a given module obj."""
        name = obj.__name__ # ignore the passed-in name
        synop, desc = pydoc.splitdoc(pydoc.getdoc(obj))
        result = self.section('NAME', name.replace(r'_', r'\_') + (synop and ' - ' + synop))

        try:
            moduleall = obj.__all__
        except AttributeError:
            moduleall = None

        try:
            filepath = os.path.dirname(inspect.getabsfile(obj))
        except TypeError:
            filepath = '(built-in)'
        result = result + self.section('FILE', '`'+filepath+'`')

        docloc = self.getdocloc(obj)
        if docloc is not None:
            result = result + self.section('MODULE DOCS', docloc)

        if desc:
            result = result + self.section('DESCRIPTION', desc)

        if hasattr(obj, '__version__'):
            version = pydoc._binstr(obj.__version__)
            if version[:11] == '$Revision: ' and version[-1:] == '$':
                version = version[11:-1].strip()
            result = result + self.section('VERSION', version)
        if hasattr(obj, '__date__'):
            result = result + self.section('DATE', pydoc._binstr(obj.__date__))
        if hasattr(obj, '__author__'):
            result = result + self.section('AUTHOR', pydoc._binstr(obj.__author__))
        if hasattr(obj, '__credits__'):
            result = result + self.section('CREDITS', pydoc._binstr(obj.__credits__))

        classes = []
        for key, value in inspect.getmembers(obj, inspect.isclass):
            # if __all__ exists, believe it.  Otherwise use old heuristic.
            if moduleall is not None or (inspect.getmodule(value) or obj) is obj:
                if pydoc.visiblename(key, moduleall, obj):
                    classes.append((key, value))
        funcs = []
        for key, value in inspect.getmembers(obj, inspect.isroutine):
            # if __all__ exists, believe it.  Otherwise use old heuristic.
            if moduleall is not None or inspect.isbuiltin(value) or inspect.getmodule(value) is obj:
                if pydoc.visiblename(key, moduleall, obj):
                    funcs.append((key, value))
        data = []
        for key, value in inspect.getmembers(obj, pydoc.isdata):
            if pydoc.visiblename(key, moduleall, obj):
                data.append((key, value))

        modules = []
        for key, _ in inspect.getmembers(obj, inspect.ismodule):
            modules.append(key)
        if modules:
            modules = sorted(modules)
            contents = ', '.join(['[%s](https://www.google.com/#q=python+%s)' % (m, m) for m in modules]) + '\n{: .lead}'
            result = result + self.section('MODULES', contents)

        modpkgs = []
        modpkgs_names = set()
        if hasattr(obj, '__path__'):
            for _, modname, ispkg in pkgutil.iter_modules(obj.__path__):
                modpkgs_names.add(modname)
                if ispkg:
                    modpkgs.append(modname + ' (package)')
                else:
                    modpkgs.append(modname)

            modpkgs.sort()
            result = result + self.section('PACKAGE CONTENTS', pydoc.join(modpkgs, '\n'))

        # Detect submodules as sometimes created by C extensions
        submodules = []
        for key, value in inspect.getmembers(obj, inspect.ismodule):
            if value.__name__.startswith(name + '.') and key not in modpkgs_names:
                submodules.append(key)
        if submodules:
            submodules.sort()
            result = result + self.section('SUBMODULES', pydoc.join(submodules, '\n'))

        if funcs:
            contents = []
            for key, value in funcs:
                contents.append(self.document(value, key, name))
            result = result + self.section('FUNCTIONS', pydoc.join(contents, '\n'))

        if classes:
            classlist = [x[1] for x in classes]
            contents = [self.formattree(inspect.getclasstree(classlist, 1), name)]
            for key, value in classes:
                contents.append(self.document(value, key, name))
            result = result + self.section('CLASSES', pydoc.join(contents, '\n'))

        if data:
            contents = []
            for key, value in data:
                contents.append(self.docother(value, key, name))
#.........这里部分代码省略.........
开发者ID:tmthydvnprt,项目名称:utilipy,代码行数:101,代码来源:pydoc_markdown.py


示例18: test_splitdoc_with_description

 def test_splitdoc_with_description(self):
     example_string = "I Am A Doc\n\n\nHere is my description"
     self.assertEqual(pydoc.splitdoc(example_string),
                      ('I Am A Doc', '\nHere is my description'))
开发者ID:524777134,项目名称:cpython,代码行数:4,代码来源:test_pydoc.py


示例19: get_module_description

def get_module_description(module):
    """Return a description of the number."""
    doc = pydoc.splitdoc(pydoc.getdoc(module))[1]
    # remove the doctests
    return _strip_doctest_re.sub('', doc[1]).strip(),
开发者ID:benregn,项目名称:python-stdnum,代码行数:5,代码来源:util.py


示例20: get_module_name

def get_module_name(module):
    """Return the short description of the number."""
    return pydoc.splitdoc(pydoc.getdoc(module))[0].strip('.')
开发者ID:benregn,项目名称:python-stdnum,代码行数:3,代码来源:util.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pydoc.synopsis函数代码示例发布时间:2022-05-25
下一篇:
Python pydoc.resolve函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap