def document_actions(self, section): modeled_actions_list = self._resource_model.actions modeled_actions = {} for modeled_action in modeled_actions_list: modeled_actions[modeled_action.name] = modeled_action resource_actions = get_resource_public_actions( self._resource.__class__) self.member_map['actions'] = sorted(resource_actions) add_resource_type_overview( section=section, resource_type='Actions', description=( 'Actions call operations on resources. They may ' 'automatically handle the passing in of arguments set ' 'from identifiers and some attributes.'), intro_link='actions_intro') for action_name in sorted(resource_actions): action_section = section.add_new_section(action_name) if action_name in ['load', 'reload'] and self._resource_model.load: self._document_load_reload_action(action_section, action_name, self._resource_model.load) elif action_name in modeled_actions: self._document_modeled_action(action_section, modeled_actions[action_name]) else: document_custom_method(section, action_name, resource_actions[action_name])
def test_document_custom_signature(self): document_custom_method(self.doc_structure, 'my_method', self.custom_method) self.assert_contains_lines_in_order([ '.. py:method:: my_method(foo)', ' This is a custom method', ' :type foo: string', ' :param foo: The foo parameter' ])
def document_actions(self, section): modeled_actions_list = self._resource_model.actions modeled_actions = {} for modeled_action in modeled_actions_list: modeled_actions[modeled_action.name] = modeled_action resource_actions = get_resource_public_actions( self._resource.__class__) self.member_map['actions'] = sorted(resource_actions) add_resource_type_overview( section=section, resource_type='Actions', description=( 'Actions call operations on resources. They may ' 'automatically handle the passing in of arguments set ' 'from identifiers and some attributes.'), intro_link='actions_intro') for action_name in sorted(resource_actions): action_section = section.add_new_section(action_name) if action_name in ['load', 'reload'] and self._resource_model.load: self._document_load_reload_action( action_section, action_name, self._resource_model.load) elif action_name in modeled_actions: self._document_modeled_action( action_section, modeled_actions[action_name]) else: document_custom_method( section, action_name, resource_actions[action_name])
def test_document_custom_signature(self): document_custom_method( self.doc_structure, 'my_method', self.custom_method) self.assert_contains_lines_in_order([ '.. py:method:: my_method(foo)', ' This is a custom method', ' :type foo: string', ' :param foo: The foo parameter' ])
def _add_custom_method(self, section, method_name, method): document_custom_method(section, method_name, method)