def wrapped(*args, **kwds): frame = last_frame = None try: frame = inspect.currentframe() last_frame = frame.f_back fname = last_frame.f_code.co_filename func_file = func.func_code.co_filename opts = { 'func': func.__name__, 'line': last_frame.f_lineno, 'file': fname, 'class': classname, 'info': info, 'package': projex.packageFromPath(func_file) } msg = 'Deprecated method called from %(file)s, line %(line)d.' \ '\n %(package)s.%(class)s.%(func)s is deprecated.' \ ' %(info)s' % opts logger.warning(errors.DeprecatedMethodWarning(msg)) finally: del frame del last_frame return func(*args, **kwds)
def wrapped(*args, **kwds): frame = last_frame = None try: frame = inspect.currentframe() last_frame = frame.f_back fname = last_frame.f_code.co_filename func_file = func.func_code.co_filename opts = { 'func': func.__name__, 'line': last_frame.f_lineno, 'file': fname, 'class': classname, 'info': info, 'package': projex.packageFromPath(func_file), } msg = 'Abstract method called from %(file)s, line %(line)d.' \ '\n %(package)s.%(class)s.%(func)s is abstract.' \ ' %(info)s' % opts raise NotImplementedError(msg) finally: del frame del last_frame
def wrapped(*args, **kwds): frame = last_frame = None try: frame = inspect.currentframe() last_frame = frame.f_back fname = last_frame.f_code.co_filename func_file = func.func_code.co_filename opts = { 'func': func.__name__, 'line': last_frame.f_lineno, 'file': fname, 'class': classname, 'info': info, 'package': projex.packageFromPath(func_file) } msg = 'Deprecated method called from %(file)s, line %(line)d.' \ '\n %(package)s.%(class)s.%(func)s is deprecated.' \ ' %(info)s' % opts logger.warning(errors.DeprecatedMethodWarning(msg)) finally: del frame del last_frame return func(*args, **kwds)
def loadInstance(self): """ Loads the plugin from the proxy information that was created from the registry file. """ if (self._loaded): return self._loaded = True module_path = self.modulePath() package = projex.packageFromPath(module_path) path = os.path.normpath(projex.packageRootPath(module_path)) if (path in sys.path): sys.path.remove(path) sys.path.insert(0, path) try: __import__(package) except Exception, e: err = Plugin(self.name(), self.version()) err.setError(e) err.setFilepath(module_path) self._instance = err self.setError(e) msg = "%s.plugin('%s') errored loading instance from %s" opts = (self.proxyClass().__name__, self.name(), module_path) logger.warning(msg % opts) logger.error(e)
def wrapped(*args, **kwds): try: frame = inspect.currentframe() last_frame = frame.f_back fname = last_frame.f_code.co_filename func_file = func.func_code.co_filename opts = {} opts['func'] = func.__name__ opts['line'] = last_frame.f_lineno opts['file'] = fname opts['class'] = classname opts['info'] = info opts['package'] = projex.packageFromPath(func_file) msg = 'Abstract method called from %(file)s, line %(line)d.'\ '\n %(package)s.%(class)s.%(func)s is abstract.'\ ' %(info)s' % opts logger.warning(errors.AbstractMethodWarning(msg)) finally: del frame del last_frame return func(*args, **kwds)
def loadInstance( self ): """ Loads the plugin from the proxy information that was created from the registry file. """ if ( self._loaded ): return self._loaded = True module_path = self.modulePath() package = projex.packageFromPath(module_path) path = os.path.normpath(projex.packageRootPath(module_path)) if ( path in sys.path ): sys.path.remove(path) sys.path.insert(0, path) try: __import__(package) except Exception, e: err = Plugin(self.name(), self.version()) err.setError(e) err.setFilepath(module_path) self._instance = err self.setError(e) msg = "%s.plugin('%s') errored loading instance from %s" opts = (self.proxyClass().__name__, self.name(), module_path) logger.warning(msg % opts) logger.error(e)
def wrapped(*args, **kwds): frame = last_frame = None try: frame = inspect.currentframe() last_frame = frame.f_back fname = last_frame.f_code.co_filename func_file = func.func_code.co_filename opts = { 'func': func.__name__, 'line': last_frame.f_lineno, 'file': fname, 'class': classname, 'info': info, 'package': projex.packageFromPath(func_file), } msg = 'Abstract method called from %(file)s, line %(line)d.' \ '\n %(package)s.%(class)s.%(func)s is abstract.' \ ' %(info)s' % opts raise NotImplementedError(msg) finally: del frame del last_frame
def generatePlugin(sourcePath, buildPath = None): """ Generates a particular ui plugin for ths system and imports it. :param widgetPath | <str> buildPath | <str> || None """ if ( buildPath is None ): buildPath = BUILD_PATH pkg_name = projex.packageFromPath(sourcePath) module = os.path.basename(sourcePath).split('.')[0] if module != '__init__': pkg_name += '.' + module try: __import__(pkg_name) except ImportError, e: logging.exception(e) return
def generateSetupFile(self, outpath='.'): """ Generates the setup file for this builder. """ outfile = os.path.join(os.path.abspath(outpath), 'setup.py') opts = {} opts['name'] = self.distributionName() opts['version'] = self.version() opts['author'] = self.author() opts['author_email'] = self.authorEmail() opts['keywords'] = self.keywords() opts['license'] = self.license() opts['brief'] = self.brief() opts['description'] = self.description() opts['url'] = self.companyUrl() wrap_dict = lambda x: map(lambda k: "r'{0}': [{1}]".format(k[0], ',\n'.join(wrap_str(k[1]))), x.items()) opts['dependencies'] = ',\n'.join(wrap_str(self.dependencies())) opts['classifiers'] = ',\n'.join(wrap_str(self.classifiers())) packages = [] package_data = {} if os.path.isfile(self.sourcePath()): basepath = os.path.normpath(os.path.dirname(self.sourcePath())) else: basepath = os.path.normpath(self.sourcePath()) baselen = len(basepath) + 1 rootdir = os.path.basename(basepath) basepkg = None basepkgpath = '' package_data = {} for root, folders, files in os.walk(basepath): if '.svn' in root or '.git' in root: continue data_types = set() # generate the package information pkg = projex.packageFromPath(root) if pkg: packages.append(pkg) if basepkg is None: basepkg = pkg basepkgpath = root # load the modules for file in files: modname, ext = os.path.splitext(file) # ignore standard ignore files if ext in self.ignoreFileTypes(): continue # ignore non-data files elif ext.startswith('.py') and ext != '.pytempl': if not basepkg: packages.append(modname) continue data_types.add('*' + ext) if data_types: subpath = os.path.join(basepkgpath, root[len(basepkgpath):]) subpath = subpath.strip(os.path.sep) data_paths = [] for data_type in data_types: type_path = os.path.join(subpath, data_type) data_paths.append(type_path) package_data.setdefault(basepkg, []) package_data[basepkg] += data_paths opts['packages'] = ',\n'.join(wrap_str(packages)) opts['package_data'] = ',\n'.join(wrap_dict(package_data)) text = templ.SETUPFILE.format(**opts) # generate the file f = open(outfile, 'w') f.write(text) f.close()
def collect(basepath, exclude=None, processPlugins=True): """ Collects all the packages associated with the inputted filepath. :param module | <module> :return ([<str> pkg, ..], [(<str> path, <str> relpath), ..] data) """ if exclude is None: exclude = ['.py', '.pyc', '.pyo', '.css', '.exe'] imports = [] datas = [] # walk the folder structure looking for all packages and data files basename = os.path.basename(basepath) basepath = os.path.abspath(basepath) baselen = len(basepath) - len(basename) plugfiles = [] for root, folders, files in os.walk(basepath): if '.svn' in root or '.git' in root: continue # mark the plugins file for load plugdata = None if processPlugins and '__plugins__.py' in files: filename = os.path.join(root, '__plugins__.py') package = projex.packageFromPath(filename) + '.__plugins__' pkgpath = projex.packageRootPath(filename) if pkgpath not in sys.path: sys.path.insert(0, pkgpath) # import the plugins module __import__(package) pkg = sys.modules[package] recurse = getattr(pkg, '__recurse__', False) plugdata = {'recurse': recurse, 'packages': [], 'path': root} plugfiles.append(plugdata) # look for any recursion plugins else: for data in plugfiles: if data['recurse'] and root.startswith(data['path']): plugdata = data break if plugdata is not None: packages = plugdata['packages'] # include package plugins for folder in folders: pkgpath = os.path.join(root, folder, '__init__.py') if os.path.exists(pkgpath): packages.append(projex.packageFromPath(pkgpath)) for file_ in files: module, ext = os.path.splitext(file_) # look for python modules if ext == '.py': package_path = projex.packageFromPath(os.path.join( root, file_)) if not package_path: continue if module != '__init__': package_path += '.' + module imports.append(package_path) # test to see if this is a plugin file if plugdata is not None and module not in ('__init__', '__plugins__'): plugdata['packages'].append(package_path) # look for data elif ext not in exclude: src = os.path.join(root, file_) targ = os.path.join(root[baselen:]) datas.append((src, targ)) # save the plugin information for plugdata in plugfiles: fname = os.path.join(plugdata['path'], '__plugins__.py') packages = plugdata['packages'] plugs = ',\n'.join(map(lambda x: "r'{0}'".format(x), packages)) data = [ '__recurse__ = {0}'.format(plugdata['recurse']), '__toc__ = [{0}]'.format(plugs) ] # write the data to the system f = open(fname, 'w') f.write('\n'.join(data)) f.close() return imports, datas
def generate(module, outputpath='./resources/docs/html', userpath='', config=None): """ Generates documenation for the inputed filepath at the given output \ location. The system can also supply the root location for user \ documentation that can be included in addition to the code by supplying \ a root userdocs path. :param module | <module> || <str> :param outputpath | <str> :param config | <module> || None :return <bool> success """ from projex.docgen.document import Document if (type(module) == str): # extract from a specific filepath if (os.path.exists(module)): package = projex.packageFromPath(module) if (not package): msg = '%s is an invalid module.' % module raise errors.DocumentationError(msg) root_path = projex.packageRootPath(module) sys.path.insert(0, root_path) # otherwise, use it as the package name else: projex.requires(module) package = module.split('-')[0] try: __import__(package) module = sys.modules[package] except ImportError: msg = 'Could not import the %s module' % package raise errors.DocumentationError(msg) except KeyError: msg = 'Could not import the %s module' % package raise errors.DocumentationError(msg) # initialize the global environ if (config is None): config = default_config init_environ(module, config) logger.info('Generating module documentation %s...' % module.__name__) # load the base page and style information page = templates.template('page.html') # start generating the documents Document.cache.clear() # generate the module documentation try: ignore = config.IGNORE except AttributeError: ignore = None doc = generateModuleDocument(module, ignore=ignore) modpath = os.path.dirname(module.__file__) outpath = outputpath.replace('./', modpath + '/') # clear the docs path if (os.path.exists(outpath)): shutil.rmtree(outpath) if (not os.path.exists(outpath)): logger.info('Making doc path: ' + outpath) os.makedirs(outpath) # make the root api documentation api_path = outpath.rstrip('/') + '/api/' if not os.path.exists(api_path): logger.info('Making doc path:' + api_path) os.mkdir(api_path) # generate the api docs doc.export(api_path, page=page) # generate the all classes page generateClassDocs(outpath, page, module.__name__) generateModuleDocs(outpath, page, module.__name__) generateFunctionDocs(outpath, page, module.__name__) generateApiIndex(outpath, page) generateDocumentIndex(outpath, page) # create the user docs if (userpath): userdocs = os.path.abspath(userpath) elif (config != default_config): userdocs = os.path.dirname(config.__file__) else: userdocs = os.path.abspath('./docs') if (os.path.exists(userdocs)): targetuserdocs = outpath templ = templates.template('link_breadcrumbs.html') generateUserDocs(userdocs, targetuserdocs, page) # copy the syntaxhighlighter code targetpath = os.path.join(outpath, '_static') paths = [] paths.append(resources.find('ext/prettify')) paths.append(templates.path('javascript')) paths.append(templates.path('css')) paths.append(templates.path('images')) paths.append(templates.path('img')) logger.info('Copying static resources...') # python26+ try: ignore = shutil.ignore_patterns('.svn') except AttributeError: ignore = None for path in paths: if (not os.path.exists(path)): continue basename = os.path.basename(path) instpath = os.path.join(targetpath, basename) if (ignore is not None): shutil.copytree(path, instpath, ignore=ignore) else: shutil.copytree(path, instpath) # create a compressed xdk file logger.info('Creating XDK file...') zfilename = os.path.join(outpath, '../%s.xdk' % module.__name__) zfilename = os.path.abspath(zfilename) generateXdk(outpath, zfilename)
def loadPlugins(cls): """ Initializes the plugins by loading modules from the inputed paths. """ plugs = getattr(cls, '_%s__plugins' % cls.__name__, None) if plugs is not None: return plugs = {} setattr(cls, '_%s__plugins' % cls.__name__, plugs) typ = cls.pluginRegisterType() for path in cls.pluginPath(): base_package = projex.packageFromPath(path) base_path = os.path.normpath(projex.packageRootPath(path)) # make sure it is at the front of the path if base_path in sys.path: sys.path.remove(base_path) sys.path.insert(0, base_path) processed = ['__init__'] # load support for registries if typ & Plugin.Type.RegistryFile: files = glob.glob(os.path.join(path, '*/register.xml')) for file in files: name = os.path.normpath(file).split(os.path.sep)[-2] processed.append(name) try: proxy = PluginProxy.fromFile(cls, file) cls.register(proxy) except Exception, e: name = projex.text.pretty(name) err = Plugin(name) err.setError(e) err.setFilepath(file) cls.register(err) # log the error msg = "%s.plugin('%s') failed to load from %s." logger.warning(msg % (cls.__name__, name, file)) logger.error(e) # load support for packages if typ & Plugin.Type.Package: files = glob.glob(os.path.join(path, '*/__init__.py')) for file in files: name = os.path.normpath(file).split(os.path.sep)[-2] if (name in processed): continue processed.append(name) package = '.'.join([base_package, name]).strip('.') if (not package): continue try: __import__(package) except Exception, e: name = projex.text.pretty(name) err = Plugin(name) err.setError(e) err.setFilepath(file) cls.register(err) # log the error msg = "%s.plugin('%s') failed to load from %s." logger.warning(msg % (cls.__name__, name, file)) logger.error(e)
def loadPlugins(cls): """ Initializes the plugins by loading modules from the inputed paths. """ plugs = getattr(cls, '_%s__plugins' % cls.__name__, None) if plugs is not None: return plugs = {} setattr(cls, '_%s__plugins' % cls.__name__, plugs) typ = cls.pluginRegisterType() for path in cls.pluginPath(): base_package = projex.packageFromPath(path) base_path = os.path.normpath(projex.packageRootPath(path)) # make sure it is at the front of the path if base_path in sys.path: sys.path.remove(base_path) sys.path.insert(0, base_path) processed = ['__init__'] # load support for registries if typ & Plugin.Type.RegistryFile: files = glob.glob(os.path.join(path, '*/register.xml')) for file in files: name = os.path.normpath(file).split(os.path.sep)[-2] processed.append(name) try: proxy = PluginProxy.fromFile(cls, file) cls.register(proxy) except Exception, e: name = projex.text.pretty(name) err = Plugin(name) err.setError(e) err.setFilepath(file) cls.register(err) # log the error msg = "%s.plugin('%s') failed to load from %s." logger.warning(msg % (cls.__name__, name, file)) logger.error(e) # load support for packages if typ & Plugin.Type.Package: files = glob.glob(os.path.join(path, '*/__init__.py')) for file in files: name = os.path.normpath(file).split(os.path.sep)[-2] if ( name in processed ): continue processed.append(name) package = '.'.join([base_package, name]).strip('.') if ( not package ): continue try: __import__(package) except Exception, e: name = projex.text.pretty(name) err = Plugin(name) err.setError(e) err.setFilepath(file) cls.register(err) # log the error msg = "%s.plugin('%s') failed to load from %s." logger.warning(msg % (cls.__name__, name, file)) logger.error(e)
def generateSetupFile(self, outpath='.'): """ Generates the setup file for this builder. """ outfile = os.path.join(os.path.abspath(outpath), 'setup.py') opts = {} opts['name'] = self.distributionName() opts['version'] = self.version() opts['author'] = self.author() opts['author_email'] = self.authorEmail() opts['keywords'] = self.keywords() opts['license'] = self.license() opts['brief'] = self.brief() opts['description'] = self.description() opts['url'] = self.companyUrl() wrap_dict = lambda x: map( lambda k: "r'{0}': [{1}]".format(k[0], ',\n'.join(wrap_str(k[1]))), x.items()) opts['dependencies'] = ',\n'.join(wrap_str(self.dependencies())) opts['classifiers'] = ',\n'.join(wrap_str(self.classifiers())) packages = [] package_data = {} if os.path.isfile(self.sourcePath()): basepath = os.path.normpath(os.path.dirname(self.sourcePath())) else: basepath = os.path.normpath(self.sourcePath()) baselen = len(basepath) + 1 rootdir = os.path.basename(basepath) basepkg = None basepkgpath = '' package_data = {} for root, folders, files in os.walk(basepath): if '.svn' in root or '.git' in root: continue data_types = set() # generate the package information pkg = projex.packageFromPath(root) if pkg: packages.append(pkg) if basepkg is None: basepkg = pkg basepkgpath = root # load the modules for file in files: modname, ext = os.path.splitext(file) # ignore standard ignore files if ext in self.ignoreFileTypes(): continue # ignore non-data files elif ext.startswith('.py') and ext != '.pytempl': if not basepkg: packages.append(modname) continue data_types.add('*' + ext) if data_types: subpath = os.path.join(basepkgpath, root[len(basepkgpath):]) subpath = subpath.strip(os.path.sep) data_paths = [] for data_type in data_types: type_path = os.path.join(subpath, data_type) data_paths.append(type_path) package_data.setdefault(basepkg, []) package_data[basepkg] += data_paths opts['packages'] = ',\n'.join(wrap_str(packages)) opts['package_data'] = ',\n'.join(wrap_dict(package_data)) text = templ.SETUPFILE.format(**opts) # generate the file f = open(outfile, 'w') f.write(text) f.close()
def collect(basepath, exclude=None): """ Collects all the packages associated with the inputed filepath. :param module | <module> :return ([<str> pkg, ..], [(<str> path, <str> relpath), ..] data) """ if exclude is None: exclude = ['.py', '.pyc', '.pyo', '.css', '.exe'] imports = [] datas = [] # walk the folder structure looking for all packages and data files basename = os.path.basename(basepath) basepath = os.path.abspath(basepath) baselen = len(basepath) - len(basename) for root, folders, files in os.walk(basepath): if '.svn' in root or '.git' in root: continue # generate the __plugins__.py file plugins = None if '__plugins__.py' in files: plugins = [] if plugins is not None: rootpkg = projex.packageFromPath(root) # include package plugins for folder in folders: if os.path.exists(os.path.join(root, folder, '__init__.py')): plugins.append('.'.join([rootpkg, folder])) for file in files: module, ext = os.path.splitext(file) # look for python modules if ext == '.py': package_path = projex.packageFromPath(os.path.join(root, file)) if not package_path: continue if module != '__init__': package_path += '.' + module imports.append(package_path) # test to see if this is a plugin file if plugins is not None and module not in ('__init__', '__plugins__'): plugins.append(package_path) # look for data elif ext not in exclude: src = os.path.join(root, file) targ = os.path.join(root[baselen:]) datas.append((src, targ)) # save the plugin information if plugins is not None: plugs = ',\n'.join(map(lambda x: "r'{0}'".format(x), plugins)) data = '__toc__ = [{plugs}]'.format(plugs=plugs) fname = os.path.join(root, '__plugins__.py') f = open(fname, 'w') f.write(data) f.close() return imports, datas
def collect(basepath, exclude=None): """ Collects all the packages associated with the inputed filepath. :param module | <module> :return ([<str> pkg, ..], [(<str> path, <str> relpath), ..] data) """ if exclude is None: exclude = ['.py', '.pyc', '.pyo', '.css', '.exe'] imports = [] datas = [] # walk the folder structure looking for all packages and data files basename = os.path.basename(basepath) basepath = os.path.abspath(basepath) baselen = len(basepath) - len(basename) for root, folders, files in os.walk(basepath): if '.svn' in root or '.git' in root: continue # generate the __plugins__.py file plugins = None if '__plugins__.py' in files: plugins = [] if plugins is not None: rootpkg = projex.packageFromPath(root) # include package plugins for folder in folders: if os.path.exists(os.path.join(root, folder, '__init__.py')): plugins.append('.'.join([rootpkg, folder])) for file in files: module, ext = os.path.splitext(file) # look for python modules if ext == '.py': package_path = projex.packageFromPath(os.path.join(root, file)) if not package_path: continue if module != '__init__': package_path += '.' + module imports.append(package_path) # test to see if this is a plugin file if plugins is not None and module not in ('__init__', '__plugins__'): plugins.append(package_path) # look for data elif ext not in exclude: src = os.path.join(root, file) targ = os.path.join(root[baselen:]) datas.append((src, targ)) # save the plugin information if plugins is not None: plugs = ',\n'.join(map(lambda x: "r'{0}'".format(x), plugins)) data = '__toc__ = [{plugs}]'.format(plugs=plugs) fname = os.path.join(root, '__plugins__.py') f = open(fname, 'w') f.write(data) f.close() return imports, datas
def collect(basepath, exclude=None, processPlugins=True): """ Collects all the packages associated with the inputted filepath. :param module | <module> :return ([<str> pkg, ..], [(<str> path, <str> relpath), ..] data) """ if exclude is None: exclude = ['.py', '.pyc', '.pyo', '.css', '.exe'] imports = [] datas = [] # walk the folder structure looking for all packages and data files basename = os.path.basename(basepath) basepath = os.path.abspath(basepath) baselen = len(basepath) - len(basename) plugfiles = [] for root, folders, files in os.walk(basepath): if '.svn' in root or '.git' in root: continue # mark the plugins file for load plugdata = None if processPlugins and '__plugins__.py' in files: filename = os.path.join(root, '__plugins__.py') package = projex.packageFromPath(filename) + '.__plugins__' pkgpath = projex.packageRootPath(filename) if pkgpath not in sys.path: sys.path.insert(0, pkgpath) # import the plugins module __import__(package) pkg = sys.modules[package] recurse = getattr(pkg, '__recurse__', False) plugdata = {'recurse': recurse, 'packages': [], 'path': root} plugfiles.append(plugdata) # look for any recursion plugins else: for data in plugfiles: if data['recurse'] and root.startswith(data['path']): plugdata = data break if plugdata is not None: packages = plugdata['packages'] # include package plugins for folder in folders: pkgpath = os.path.join(root, folder, '__init__.py') if os.path.exists(pkgpath): packages.append(projex.packageFromPath(pkgpath)) for file_ in files: module, ext = os.path.splitext(file_) # look for python modules if ext == '.py': package_path = projex.packageFromPath(os.path.join(root, file_)) if not package_path: continue if module != '__init__': package_path += '.' + module imports.append(package_path) # test to see if this is a plugin file if plugdata is not None and module not in ('__init__', '__plugins__'): plugdata['packages'].append(package_path) # look for data elif ext not in exclude: src = os.path.join(root, file_) targ = os.path.join(root[baselen:]) datas.append((src, targ)) # save the plugin information for plugdata in plugfiles: fname = os.path.join(plugdata['path'], '__plugins__.py') packages = plugdata['packages'] plugs = ',\n'.join(map(lambda x: "r'{0}'".format(x), packages)) data = [ '__recurse__ = {0}'.format(plugdata['recurse']), '__toc__ = [{0}]'.format(plugs) ] # write the data to the system f = open(fname, 'w') f.write('\n'.join(data)) f.close() return imports, datas
def generate( module, outputpath = './resources/docs/html', userpath = '', config = None ): """ Generates documenation for the inputed filepath at the given output \ location. The system can also supply the root location for user \ documentation that can be included in addition to the code by supplying \ a root userdocs path. :param module | <module> || <str> :param outputpath | <str> :param config | <module> || None :return <bool> success """ from projex.docgen.document import Document if ( type(module) == str ): # extract from a specific filepath if ( os.path.exists(module) ): package = projex.packageFromPath(module) if ( not package ): msg = '%s is an invalid module.' % module raise errors.DocumentationError(msg) root_path = projex.packageRootPath(module) sys.path.insert(0, root_path) # otherwise, use it as the package name else: projex.requires(module) package = module.split('-')[0] try: __import__(package) module = sys.modules[package] except ImportError: msg = 'Could not import the %s module' % package raise errors.DocumentationError(msg) except KeyError: msg = 'Could not import the %s module' % package raise errors.DocumentationError(msg) # initialize the global environ if ( config is None ): config = default_config init_environ(module, config) logger.info('Generating module documentation %s...' % module.__name__) # load the base page and style information page = templates.template('page.html') # start generating the documents Document.cache.clear() # generate the module documentation try: ignore = config.IGNORE except AttributeError: ignore = None doc = generateModuleDocument(module, ignore = ignore) modpath = os.path.dirname(module.__file__) outpath = outputpath.replace( './', modpath + '/' ) # clear the docs path if ( os.path.exists( outpath ) ): shutil.rmtree( outpath ) if ( not os.path.exists( outpath ) ): logger.info( 'Making doc path: ' + outpath ) os.makedirs(outpath) # make the root api documentation api_path = outpath.rstrip('/') + '/api/' if not os.path.exists(api_path): logger.info( 'Making doc path:' + api_path ) os.mkdir(api_path) # generate the api docs doc.export(api_path, page = page) # generate the all classes page generateClassDocs( outpath, page, module.__name__ ) generateModuleDocs( outpath, page, module.__name__) generateFunctionDocs( outpath, page, module.__name__) generateApiIndex( outpath, page ) generateDocumentIndex( outpath, page) # create the user docs if ( userpath ): userdocs = os.path.abspath(userpath) elif ( config != default_config ): userdocs = os.path.dirname(config.__file__) else: userdocs = os.path.abspath('./docs') if ( os.path.exists(userdocs) ): targetuserdocs = outpath templ = templates.template('link_breadcrumbs.html') generateUserDocs( userdocs, targetuserdocs, page ) # copy the syntaxhighlighter code targetpath = os.path.join(outpath,'_static') paths = [] paths.append(resources.find('ext/prettify')) paths.append(templates.path('javascript')) paths.append(templates.path('css')) paths.append(templates.path('images')) paths.append(templates.path('img')) logger.info('Copying static resources...') # python26+ try: ignore = shutil.ignore_patterns('.svn') except AttributeError: ignore = None for path in paths: if ( not os.path.exists(path) ): continue basename = os.path.basename(path) instpath = os.path.join(targetpath, basename) if ( ignore is not None ): shutil.copytree( path, instpath, ignore = ignore ) else: shutil.copytree(path, instpath) # create a compressed xdk file logger.info('Creating XDK file...') zfilename = os.path.join(outpath, '../%s.xdk' % module.__name__) zfilename = os.path.abspath(zfilename) generateXdk(outpath, zfilename)