def run(self): ssn = session.Session() ssn.configClass = ssn.config = config = ConfigBucket() ssn.pluginargs = opts = OptBucket() plugin_name = self.arguments[0] parent, plugin = util.object_from_name(plugin_name) # FIXME this is too naive mod_name = plugin_name[0:plugin_name.index(plugin.__name__)-1] rst = ViewList() rst.append(u'.. automodule :: %s\n' % mod_name, AD) rst.append(u'', AD) obj = plugin(session=ssn) try: obj.pluginsLoaded(events.PluginsLoadedEvent([obj])) except AttributeError: pass # config options if config.vars: self.add_config(rst, config) # command-line options if opts.opts: self.headline(rst, u'Command-line options') for opt in opts: for line in opt.options(): rst.append(line, AD) rst.append('', AD) # class __doc__ self.headline(rst, u'Plugin class reference') rst.append(u'.. autoclass :: %s' % plugin_name, AD) rst.append(u' :members:', AD) rst.append(u'', AD) # parse rst and generate new nodelist state = self.state node = nodes.section() node.document = state.document surrounding_title_styles = state.memo.title_styles surrounding_section_level = state.memo.section_level state.memo.title_styles = [] state.memo.section_level = 0 state.nested_parse(rst, 0, node, match_titles=1) state.memo.title_styles = surrounding_title_styles state.memo.section_level = surrounding_section_level return node.children
def _from_names(self, names): by_feature = normalize_names(names) for (feature_package_name, feature_filename), scenario_indexes in sorted( by_feature.iteritems()): feature_module = object_from_name(feature_package_name)[1] feature_path = os.path.join( os.path.dirname(feature_module.__file__), feature_filename) suite = self.makeSuiteFromFeature( module=feature_module, feature_path=feature_path, scenario_indexes=scenario_indexes, ) yield suite
def _from_names(self, names): by_feature = normalize_names(names) for ( feature_package_name, feature_filename ), scenario_indexes in sorted(by_feature.iteritems()): feature_module = object_from_name(feature_package_name)[1] feature_path = os.path.join( os.path.dirname(feature_module.__file__), feature_filename ) suite = self.makeSuiteFromFeature( module=feature_module, feature_path=feature_path, scenario_indexes=scenario_indexes, ) yield suite
def handleFile(self, event): """Produce a FeatureTestSuite from a .feature file.""" feature_path = event.path if os.path.splitext(feature_path)[1] != '.feature': return event.handled = True try: feature_package_name = name_from_path( os.path.dirname(feature_path))[0] feature_module = object_from_name(feature_package_name)[1] except: return event.loader.failedImport(feature_path) return self.makeSuiteFromFeature( module=feature_module, feature_path=feature_path, )
def handleFile(self, event): """Produce a FeatureTestSuite from a .feature file.""" feature_path = event.path if os.path.splitext(feature_path)[1] != '.feature': return event.handled = True try: feature_package_name = name_from_path( os.path.dirname(feature_path)) feature_module = object_from_name(feature_package_name)[1] except: return event.loader.failedImport(feature_path) return self.makeSuiteFromFeature( module=feature_module, feature_path=feature_path, )
def run(self): plugin_name = self.arguments[0] parent, plugin = util.object_from_name(plugin_name) if isinstance(plugin, types.ModuleType): # document all plugins in module module = plugin mod_name = module.__name__ plugins = self.plugins(module) else: if 'module' in self.options: mod_name = self.options['module'] else: mod_name = plugin_name[ 0:plugin_name.index(plugin.__name__) - 1] plugins = [plugin] rst = ViewList() if mod_name: rst.append(u'.. automodule :: %s\n' % mod_name, AD) rst.append(u'', AD) for plug in plugins: self.document(rst, plug) # parse rst and generate new nodelist state = self.state node = nodes.section() node.document = state.document surrounding_title_styles = state.memo.title_styles surrounding_section_level = state.memo.section_level state.memo.title_styles = [] state.memo.section_level = 0 state.nested_parse(rst, 0, node, match_titles=1) state.memo.title_styles = surrounding_title_styles state.memo.section_level = surrounding_section_level return node.children
def run(self): plugin_name = self.arguments[0] parent, plugin = util.object_from_name(plugin_name) if isinstance(plugin, types.ModuleType): # document all plugins in module module = plugin mod_name = module.__name__ plugins = self.plugins(module) else: if "module" in self.options: mod_name = self.options["module"] else: mod_name = plugin_name[0:plugin_name.index(plugin.__name__) - 1] plugins = [plugin] rst = ViewList() if mod_name: rst.append(u".. automodule :: %s\n" % mod_name, AD) rst.append(u"", AD) for plug in plugins: self.document(rst, plug) # parse rst and generate new nodelist state = self.state node = nodes.section() node.document = state.document surrounding_title_styles = state.memo.title_styles surrounding_section_level = state.memo.section_level state.memo.title_styles = [] state.memo.section_level = 0 state.nested_parse(rst, 0, node, match_titles=1) state.memo.title_styles = surrounding_title_styles state.memo.section_level = surrounding_section_level return node.children