def test_gen_easyblocks(self): """ Test gen_easyblocks_overview_rst function """ gen_easyblocks_pkg = 'easybuild.easyblocks.generic' modules = import_available_modules(gen_easyblocks_pkg) common_params = { 'ConfigureMake': ['configopts', 'buildopts', 'installopts'], } doc_functions = ['build_step', 'configure_step', 'test_step'] eb_overview = gen_easyblocks_overview_rst(gen_easyblocks_pkg, 'easyconfigs', common_params, doc_functions) ebdoc = '\n'.join(eb_overview) # extensive check for ConfigureMake easyblock check_configuremake = '\n'.join([ ".. _ConfigureMake:", '', "``ConfigureMake``", "=================", '', "(derives from EasyBlock)", '', "Dummy support for building and installing applications with configure/make/make install.", '', "Commonly used easyconfig parameters with ``ConfigureMake`` easyblock", "--------------------------------------------------------------------", '', "==================== ================================================================", "easyconfig parameter description ", "==================== ================================================================", "configopts Extra options passed to configure (default already has --prefix)", "buildopts Extra options passed to make step (default already has -j X) ", "installopts Extra options for installation ", "==================== ================================================================", ]) self.assertTrue(check_configuremake in ebdoc) names = [] for mod in modules: for name, obj in inspect.getmembers(mod, inspect.isclass): eb_class = getattr(mod, name) # skip imported classes that are not easyblocks if eb_class.__module__.startswith(gen_easyblocks_pkg): self.assertTrue(name in ebdoc) names.append(name) toc = [":ref:`" + n + "`" for n in sorted(set(names))] pattern = " - ".join(toc) regex = re.compile(pattern) self.assertTrue(re.search(regex, ebdoc), "Pattern %s found in %s" % (regex.pattern, ebdoc))
def test_gen_easyblocks(self): """ Test gen_easyblocks_overview_rst function """ module = 'easybuild.easyblocks.generic' modules = import_available_modules(module) common_params = { 'ConfigureMake' : ['configopts', 'buildopts', 'installopts'], } doc_functions = ['build_step', 'configure_step', 'test_step'] eb_overview = gen_easyblocks_overview_rst(module, 'easyconfigs', common_params, doc_functions) ebdoc = '\n'.join(eb_overview) # extensive check for ConfigureMake easyblock check_configuremake = '\n'.join([ ".. _ConfigureMake:", '', "``ConfigureMake``", "=================", '', "(derives from EasyBlock)", '', "Dummy support for building and installing applications with configure/make/make install.", '', "Commonly used easyconfig parameters with ``ConfigureMake`` easyblock", "--------------------------------------------------------------------", '', "==================== ================================================================", "easyconfig parameter description ", "==================== ================================================================", "configopts Extra options passed to configure (default already has --prefix)", "buildopts Extra options passed to make step (default already has -j X) ", "installopts Extra options for installation ", "==================== ================================================================", ]) self.assertTrue(check_configuremake in ebdoc) names = [] for mod in modules: for name, obj in inspect.getmembers(mod, inspect.isclass): eb_class = getattr(mod, name) # skip imported classes that are not easyblocks if eb_class.__module__.startswith(module): self.assertTrue(name in ebdoc) names.append(name) toc = [":ref:`" + n + "`" for n in sorted(names)] pattern = " - ".join(toc) regex = re.compile(pattern) self.assertTrue(re.search(regex, ebdoc), "Pattern %s found in %s" % (regex.pattern, ebdoc))
options = { 'out-file': ('Path to output file', 'string', 'store', None, 'o'), 'examples': ('Path to dir that contains example files', 'string', 'store', DEFAULT_EXAMPLE_PATH, 'e'), 'module': ('Name of module to load the easyblocks from', 'string', 'store', DEFAULT_MODULE, 'm') } so = simple_option(options) config.init_build_options({'validate': False, 'external_modules_metadata': {}}) autogen_comment = [ ".. This file is automatically generated using the %s script, " % os.path.basename(__file__), ".. and information and docstrings from easyblocks and the EasyBuild framework.", ".. Doo not edit this file manually, but update the docstrings and regenerate it.", '', ] easyblocks_overview = gen_easyblocks_overview_rst(so.options.module, so.options.examples, COMMON_PARAMS, DOC_FUNCTIONS) txt = '\n'.join(autogen_comment + easyblocks_overview) if so.options.out_file: write_file(so.options.out_file, txt) print('%s updated' % so.options.out_file) else: print(txt)
DEFAULT_EXAMPLE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'examples') DEFAULT_MODULE = 'easybuild.easyblocks.generic' options = { 'out-file': ('Path to output file', 'string', 'store', None, 'o'), 'examples': ('Path to dir that contains example files', 'string', 'store', DEFAULT_EXAMPLE_PATH, 'e'), 'module': ('Name of module to load the easyblocks from', 'string', 'store', DEFAULT_MODULE, 'm') } so = simple_option(options) config.init_build_options({'validate': False, 'external_modules_metadata': {}}) autogen_comment = [ ".. This file is automatically generated using the %s script, " % os.path.basename(__file__), ".. and information and docstrings from easyblocks and the EasyBuild framework.", ".. Doo not edit this file manually, but update the docstrings and regenerate it.", '', ] easyblocks_overview = gen_easyblocks_overview_rst(so.options.module, so.options.examples, COMMON_PARAMS, DOC_FUNCTIONS) txt = '\n'.join(autogen_comment + easyblocks_overview) if so.options.out_file: write_file(so.options.out_file, txt) print '%s updated' % so.options.out_file else: print txt