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


Python pydoc.writedoc函数代码示例

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


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

示例1: createPyDocs

 def createPyDocs(self, filename, dir):
     """Create an HTML module documentation using pydoc."""
     import pydoc
     package, module = os.path.split(filename)
     module = os.path.splitext(module)[0]
     if package:
         module = package.replace('/', '.') + '.' + module
     targetName = '%s/%s.html' % (dir, module)
     self.printMsg('Creating %s...' % targetName)
     saveDir = os.getcwd()
     os.chdir(dir)
     try:
         stdout = sys.stdout
         sys.stdout = StringIO()
         try:
             try:
                 pydoc.writedoc(module)
             except Exception:
                 pass
             msg = sys.stdout.getvalue()
         finally:
             sys.stdout = stdout
     finally:
         os.chdir(saveDir)
     if msg:
         self.printMsg(msg)
开发者ID:Cito,项目名称:w4py-olde-docs,代码行数:26,代码来源:install.py

示例2: writedoc

def writedoc(mn):
	#print mn
	try:
		exec("import %s as mod" % mn)
	except:
		print "WARNING: can't import %s" % mn
		raise
		return 
	if modified(mod):
		pydoc.writedoc(mod)
		killnbs(mod)
	else:
		print "%s not modified" % mn
	if not '__init__' in mod.__file__:
		return
	#is a package - need to get subpackages
	d=os.path.split(mod.__file__)[0]
	dd=os.listdir(d)
	for fn in dd:
		fpn=os.path.join(d, fn)
		wd=False
		if fn.startswith("_"):
			pass
		elif os.path.isfile(fpn) and fn.endswith('.py'):
			#found a module
			if not fn in ['test.py', 'testme.py', 'setup.py']:
				wd=True
		elif os.path.isdir(fpn):
			if '__init__.py' in os.listdir(fpn):
				if not fn=='tools':
					wd=True
		if wd:		
			nmn=os.path.splitext(fn)[0]
			nmn='.'.join([mn, nmn])
			writedoc(nmn)
开发者ID:gic888,项目名称:MIEN,代码行数:35,代码来源:makedocs.py

示例3: createPyDocs

	def createPyDocs(self, filename, dir):
		"""Create a HTML module documentation using pydoc."""
		try:
			import pydoc
		except ImportError:
			from MiscUtils import pydoc
		package, module = os.path.split(filename)
		module = os.path.splitext(module)[0]
		if package:
			module = package + '.' + module
		targetName = '%s/%s.html' % (dir, module)
		self.printMsg('Creating %s...' % targetName)
		saveDir = os.getcwd()
		try:
			os.chdir(dir)
			targetName = '../' + targetName
			stdout = sys.stdout
			sys.stdout = StringIO()
			try:
				pydoc.writedoc(module)
			except Exception:
				pass
			msg = sys.stdout.getvalue()
			sys.stdout = stdout
			if msg:
				self.printMsg(msg)
		finally:
			os.chdir(saveDir)
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:28,代码来源:install.py

示例4: main

def main():
    """ Generate all pydoc documentation files within our "doc" directory.

        After generation, there will be an index.html file that displays all
        the modules.
    """
    # Remove the existing documentation files, if any.

    if os.path.exists(DOC_DIR):
        shutil.rmtree(DOC_DIR)
    os.mkdir(DOC_DIR)

    # Create the new documentation files.

    filelist = buildFileList(SRC_DIR) + [SRC_DIR]
    for fName in filelist:
        f = filenameToDocname(fName)
        if not glob.glob(DOC_DIR + '/' + fName):
            pydoc.writedoc(filenameToPackagename(fName))
        if glob.glob(fName):
            cmd = 'mv -f ' + f + ' ' + DOC_DIR + '/'
            os.system(cmd)
        else:
            filelist.remove(fName)

    # Finally, rename the top-level file to "index.html" so it can be accessed
    # easily.

    cmd = 'mv ' + DOC_DIR + '/threetaps.html ' + DOC_DIR + '/index.html'
    os.system(cmd)
开发者ID:3taps,项目名称:3taps-Python-Client,代码行数:30,代码来源:generateDocs.py

示例5: get_modulo

def get_modulo(name, attrib):
    modulo = False

    if len(name.split(".")) == 2:
        try:
            mod = __import__(name)
            modulo = mod.__getattribute__(
                name.replace("%s." % name.split(".")[0], ''))
        except:
            pass

    elif len(name.split(".")) == 1:
        try:
            modulo = __import__(name)
        except:
            pass
    else:
        pass

    if modulo:
        try:
            clase = getattr(modulo, attrib)
            archivo = os.path.join(BASEPATH, '%s.html' % attrib)
            ar = open(archivo, "w")
            ar.write("")
            ar.close()
            pydoc.writedoc(clase)
        except:
            sys.exit(0)
    else:
        sys.exit(0)
开发者ID:fdanesse,项目名称:JAMediaSuite,代码行数:31,代码来源:Make_doc.py

示例6: writedocs

def writedocs(dir, pkgpath='', done=None):
    """Write out HTML documentation for all modules in a directory tree."""
    if done is None: done = {}
    for importer, modname, ispkg in pkgutil.walk_packages([dir], pkgpath):
    		# Ignore all debug modules
    		if modname[-2:] != '_d':
        		pydoc.writedoc(modname)
    return
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:8,代码来源:pythondoc.py

示例7: _GetHTMLDoc

def _GetHTMLDoc():
    """
    #################################################################
    Write HTML documentation for this module.
    #################################################################
    """
    import pydoc
    pydoc.writedoc('topology')    
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:8,代码来源:topology.py

示例8: create_pydocs

def create_pydocs():
    print "It's useful to use pydoc to generate docs."
    pydoc_dir = "pydoc"
    module = "recipe15_all"
    __import__(module)
    if not os.path.exists(pydoc_dir):
        os.mkdir(pydoc_dir)
    cur = os.getcwd()
    os.chdir(pydoc_dir)
    pydoc.writedoc("recipe15_all")
    os.chdir(cur)
开发者ID:jinpeng,项目名称:PythonTestingCookbook,代码行数:11,代码来源:recipe15.py

示例9: autodoc_html_cb

def autodoc_html_cb (data, flags) :
	import pydoc
	import os
	try :
		path = os.environ["TEMP"]
	except KeyError :
		# with os.tmpnam() we get a RuntimeWarning so fall back to
		path = "/tmp/"
	os.chdir(path)
	pydoc.writedoc(dia)
	dia.message(0, path + os.path.sep + "dia.html saved.")
开发者ID:AmiGanguli,项目名称:dia,代码行数:11,代码来源:pydiadoc.py

示例10: generateDoc

def generateDoc(moduleName):
	"""
	@param moduleName is the name of the module to document (example: robot)
	generates the HTML pydoc file for the given module
	then it moves the file to OUTFOLDER 
		(this is necessary because pydoc does not allow user-defined destination path)
	"""
	pydoc.writedoc(moduleName)
	filename = moduleName+'.html'
	destination = OUTFOLDER+filename
	command = "mv %s %s"%(filename, destination)
	os.system(command)
开发者ID:CSSDePaul,项目名称:Computerized-Robot-Arena-Program,代码行数:12,代码来源:documentationGenerator.py

示例11: main

def main():
    dir = sys.argv[1]
    lib_list = import_libs(dir)

    # generate pydoc here
    print lib_list
    for l in lib_list:
        try:
            module = __import__(l)
            pydoc.writedoc(l)
        except:
            pass
开发者ID:ska-sa,项目名称:meqtrees-timba,代码行数:12,代码来源:generate-docs.py

示例12: _generate_docs

 def _generate_docs(self):
     # FIXME: this is really hacky
     olddir = os.getcwd()
     html_dir = os.path.join('docs', 'html')
     if not os.path.exists(html_dir):
         os.makedirs(html_dir)
     os.chdir(html_dir)
     writedoc('osc2')
     os.rename('osc2.html', 'index.html')
     modules = ('build', 'core', 'httprequest', 'oscargs', 'remote',
                'source', 'util', 'util.io', 'util.xml', 'wc', 'wc.base',
                'wc.convert', 'wc.package', 'wc.project', 'wc.util')
     for mod in modules:
         writedoc('osc2.' + mod)
     os.chdir(olddir)
开发者ID:nijel,项目名称:osc2,代码行数:15,代码来源:setup.py

示例13: main

def main():

    description="Convenience script to generate HTML documentation using pydoc"
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('--out', required=True,  metavar="PATH", 
                        help="Directory in which to write HTML output files.")
    parser.add_argument('--recursive', action='store_true', default=False,
                        help="Recursively import documentation for dependencies. If not recursive, zcall documents will contain broken links to standard modules. Recursive mode generates approximately 180 HTML files comprising 6 MB of data.")
    parser.add_argument('--verbose', action='store_true', default=False,
                        help="Write pydoc information to stdout.")
    args = vars(parser.parse_args())
    recursive = args['recursive']
    verbose = args['verbose']
    if not verbose: # suppress stdout chatter from pydoc.writedoc
        sys.stdout = open('/dev/null', 'w')

    localDir = os.path.dirname(os.path.realpath(__file__))
    sys.path.append(os.path.abspath(localDir+"/..")) # import from zcall dir
    zcallDir = os.path.abspath(localDir+"/../zcall")
    outDir = os.path.abspath(args['out'])
    if not (os.access(outDir, os.W_OK) and os.path.isdir(outDir)):
        msg = "ERROR: Output path "+outDir+" is not a writable directory.\n"
        sys.stderr.write(msg)
        sys.exit(1)
    os.chdir(outDir)
    import zcall
    pydoc.writedoc(zcall)
    modules = set()
    zcall = set()
    scripts = []
    mf = ModuleFinder()
    for script in os.listdir(zcallDir):
        if re.search("\.py$", script) and script!="__init__.py":
            words = re.split("\.", script)
            words.pop()
            scriptName = (".".join(words)) # name without .py suffix
            modules.add("zcall."+scriptName)
            zcall.add(scriptName)
            scripts.append(script)
    if recursive:
        for script in scripts:
            mf.run_script(os.path.join(zcallDir, script))
            for name, mod in mf.modules.iteritems(): 
                if name not in zcall: modules.add(name)
    for module in modules:
        pydoc.writedoc(import_module(module))
开发者ID:wtsi-npg,项目名称:zCall,代码行数:46,代码来源:createDocs.py

示例14: documentModules

def documentModules(moduleNames, exclude=[], destination=".", Path=None):
    """ Generates pydoc documentation for each module name given and outputs the HTML files into the destination directory.
        @input moduleNames - a list of names for the modules to document.
        @input exclude - a list of module and package names that should NOT be documented
        @input destination - a string indicating the directory path where the documentation HTML should be written.  Defaults to "."
        @input Path - any specific PATH to use?
        @return - a list of the filenames of all html files which were written.
    """

    # update the path variable with any special info
    sys.path.append(Path)
    
    writtenFiles = [] # list for all files that have been written
    
    # change to the appropriate directory
    os.chdir(destination)
    
    # loop through all the module names we were given
    for modName in moduleNames:
        
        # filter out any excluded modules
        for x in exclude:
            if modName.find(x) != -1:
                out.log("Skipping module " + modName)
                modName = ""

        # filter out bogus module names
        if modName == "":
            continue
    

        # import the module and write out the documentation for it.
        try:
            M = importModule(modName, Path=Path)

	    out.log("",nl=False)

            pydoc.writedoc(M)

            writtenFiles.append(modName+".html")
        except ImportError as e: # print error msg and proceed to next object
            out.log("Could not import module " + modName + " - " + str(e), err=True)
            continue

    return writtenFiles
开发者ID:benguillet,项目名称:dcor_frontend,代码行数:45,代码来源:doc.py

示例15: _generate_docs

 def _generate_docs(self):
     # FIXME: this is really hacky
     # Need to work in the modules directory.
     # Otherwise install with e.g. pip will not work.
     olddir = os.getcwd()
     module_dir = os.path.dirname(os.path.abspath(__file__))
     sys.path.append(module_dir)
     os.chdir(module_dir)
     html_dir = os.path.join('docs', 'html')
     if not os.path.exists(html_dir):
         os.makedirs(html_dir)
     os.chdir(html_dir)
     writedoc('osc2')
     os.rename('osc2.html', 'index.html')
     modules = ('build', 'core', 'httprequest', 'oscargs', 'remote',
                'source', 'util', 'util.io', 'util.xml', 'wc', 'wc.base',
                'wc.convert', 'wc.package', 'wc.project', 'wc.util')
     for mod in modules:
         writedoc('osc2.' + mod)
     os.chdir(olddir)
开发者ID:openSUSE,项目名称:osc2,代码行数:20,代码来源:setup.py


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