def _cases_and_sub_suites(self, header: str) -> SectionHierarchyGenerator: return h.leaf( header, sections.constant_contents( docs.section_contents(self._cases_and_sub_suites_paragraphs()) ) )
def _act_examples(tp: TextParser) -> sections.SectionConstructor: return sections.section( docs.text('Examples'), sections.constant_contents( docs.section_contents(tp.fnap(_ACT_EXAMPLES)) ) )
def test_hierarchy_with_sub_sections(self): # ARRANGE # target_factory = TargetInfoFactoryTestImpl(['target_component']) expected_section_contents_object1 = doc.empty_section_contents() expected_section_contents_object2 = docs.section_contents(docs.paras('testing testing')) expected_root_initial_para = docs.para('root initial paras') expected_root_initial_paras = [expected_root_initial_para] root_header = StringText('root header') sub_section_header_1 = 'sub1' sub_section_header_2 = 'sub2' sub_section_local_target_1 = 'sub-target1' sub_section_local_target_2 = 'sub-target2' object_to_test = sut.hierarchy( root_header, paragraphs.constant(expected_root_initial_paras), [sut.child(sub_section_local_target_1, sut.leaf(sub_section_header_1, section_contents(expected_section_contents_object1))), sut.child(sub_section_local_target_2, sut.leaf(sub_section_header_2, section_contents(expected_section_contents_object2))) ]) # EXPECTATION # expected_root_target_info = target_factory.root(root_header) sub1_target = target_factory.sub(sub_section_header_1, sub_section_local_target_1) sub2_target = target_factory.sub(sub_section_header_2, sub_section_local_target_2) target_info_node_assertion = equals_target_info_node( TargetInfoNode(expected_root_target_info, [ target_info_leaf(sub1_target), target_info_leaf(sub2_target), ]), mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl) section_assertion2 = section_matches( target=equals_custom_cross_ref_test_impl(expected_root_target_info.target), header=asrt_para.equals_text(expected_root_target_info.presentation_text), contents=section_contents_matches( initial_paragraphs=asrt.matches_sequence([asrt.Is(expected_root_initial_para)]), sections=asrt.matches_sequence([ section_matches( target=equals_custom_cross_ref_test_impl(sub1_target.target), header=asrt_para.equals_text(sub1_target.presentation_text), contents=asrt.Is(expected_section_contents_object1)), section_matches( target=equals_custom_cross_ref_test_impl(sub2_target.target), header=asrt_para.equals_text(sub2_target.presentation_text), contents=asrt.Is(expected_section_contents_object2)), ]))) # ACT & ASSERT # self._act_and_assert(object_to_test, target_factory, target_info_node_assertion, section_assertion2)
def contents_description(self) -> SectionContents: tp = TextParser({ 'default_suite_file_name': file_names.DEFAULT_SUITE_FILE, }) return docs.section_contents( path_contents_description('suite'), [docs.section('Default suite file', tp.fnap(_DIR_AS_SUITE))])
def section_contents( self, paragraphs_text: str, extra: Optional[Mapping[str, Any]] = None, ) -> docs.SectionContents: """ :param paragraphs_text: Parsed using `self.fnap`. """ return docs.section_contents(self.fnap(paragraphs_text, extra))
def purpose(self) -> DescriptionWithSubSections: parse = TextParser({ 'directive': concepts.DIRECTIVE_CONCEPT_INFO.name, 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'symbol': concepts.SYMBOL_CONCEPT_INFO.name, }) contents = parse.fnap(_DESCRIPTION) return DescriptionWithSubSections(self.single_line_description(), docs.section_contents(contents))
def test_with_non_empty_main_description(self): # ARRANGE # doc = TypeDocumentation(TypeCategory.DATA, A_TYPE_NAME_AND_CROSS_REFERENCE_ID, A_SYNTAX_ELEMENT_INFO, docs.section_contents(docs.paras('initial paragraphs of main description'))) renderer = sut.IndividualTypeConstructor(doc) # ACT # actual = renderer.apply(CONSTRUCTION_ENVIRONMENT) # ASSERT # struct_check.is_article_contents.apply(self, actual)
def purpose(self) -> DescriptionWithSubSections: return DescriptionWithSubSections( self.single_line_description(), docs.section_contents(self._tp.fnap(_DESCRIPTION_REST), [ docs.section('Semantics', self._tp.fnap(_SEMANTICS)), docs.section( 'Syntax', [FORMS_PARA] + self._invokation_variants_paragraphs() + self._tp.fnap(_SYNTAX), ), ]))
def files(self) -> Optional[docs.SectionContents]: list_items = [ docs.list_item(_TP.text(_FILES_WHEN_REPORTING_FOR_A_CASE_HEADER), _TP.fnap(FILES_DESCRIPTION_WITH_DEFAULT_SUITE)), docs.list_item(_TP.text(_FILES_WHEN_REPORTING_FOR_A_SUITE_HEADER), _TP.fnap(DEFAULT_SUITE_FILES_DESCRIPTION)), ] return docs.section_contents([ docs.simple_list_with_space_between_elements_and_content( list_items, docs.lists.ListType.ITEMIZED_LIST) ])
def contents_description(self) -> SectionContents: tp = TextParser({ 'default_suite_file_name': file_names.DEFAULT_SUITE_FILE, }) return docs.section_contents( file_ref_contents_description('suite'), [ docs.section('Default suite file', tp.fnap(_DIR_AS_SUITE)) ] )
def test_with_non_empty_main_description(self): # ARRANGE # for type_cat_case in SYNTAX_ELEM_TYPE_CATEGORY_CASES: doc = TypeDocumentation(A_TYPE_NAME_AND_CROSS_REFERENCE_ID, type_cat_case.value, docs.section_contents(docs.paras('initial paragraphs of main description'))) renderer = sut.IndividualTypeConstructor(doc) with self.subTest(type_cat_case.name): # ACT # actual = renderer.apply(CONSTRUCTION_ENVIRONMENT) # ASSERT # struct_check.is_article_contents.apply(self, actual)
def outcome( self, environment: ConstructionEnvironment ) -> Optional[docs.SectionContents]: paragraphs = case_outcome_help.TEXT_PARSER.fnap( case_outcome_help.REPORTING) paragraphs += _TP.fnap(_OUTCOME_INITIAL_PARAGRAPHS_EXTRA) paragraphs += exit_invalid_usage.paragraphs() return docs.section_contents(paragraphs, [ docs.section( case_outcome_help.ALL_EXIT_VALUES_SUMMARY_TABLE_HEADER, [case_outcome_help.all_exit_values_summary_table()]) ])
def purpose(self) -> DescriptionWithSubSections: parser = TextParser({ 'action_to_check': concepts.ACTION_TO_CHECK_CONCEPT_INFO.name, 'actor': concepts.ACTOR_CONCEPT_INFO.name, 'ATC': concepts.ACTION_TO_CHECK_CONCEPT_INFO.acronym, 'actor_option': formatting.cli_option(common_cli_options.OPTION_FOR_ACTOR), 'actor_instruction': formatting.InstructionName(ACTOR_INSTRUCTION_NAME), 'act': phase_infos.ACT.name, 'phase': PHASE_NAME_DICTIONARY, 'os_process': misc_texts.OS_PROCESS_NAME, }) return DescriptionWithSubSections(concepts.ACTION_TO_CHECK_CONCEPT_INFO.single_line_description, docs.section_contents(parser.fnap(_DESCRIPTION)))
def purpose(self) -> DescriptionWithSubSections: parse = TextParser({ 'action_to_check': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO), 'actor': self.name(), 'actor_option': formatting.cli_option(common_cli_options.OPTION_FOR_ACTOR), 'actor_instruction': formatting.InstructionName(instruction_names.ACTOR_INSTRUCTION_NAME), 'act': phase_infos.ACT.name, 'default_actor': actors.DEFAULT_ACTOR_SINGLE_LINE_VALUE, 'actor_conf_param': formatting.conf_param_(conf_params.ACTOR_CONF_PARAM_INFO), 'conf_param': concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.name, }) contents = parse.fnap(_AFTER_SINGLE_LINE_DESCRIPTION) return DescriptionWithSubSections(self.single_line_description(), docs.section_contents(contents))
def purpose(self) -> DescriptionWithSubSections: return DescriptionWithSubSections( self.single_line_description(), docs.section_contents( self._tp.fnap(_INITIAL_PARAGRAPHS), [ docs.section(self._tp.text('Environment variables set by {program_name}'), self._tp.fnap(_E_SETS_EXTRA_ENV_VARS), [ self._variables_from_setup(), self._variables_from_before_assert(), ]) ]))
def notes(self) -> SectionContents: return docs.section_contents(sub_sections=[ docs.section( self._tp.text('{path:/u} {relativity:s}'), self._notes_section_paragraphs(), ), docs.section( self._tp.text(misc_texts.STDIN.capitalize()), self._tp.fnap(_STDIN_DESCRIPTION), ), docs.section( self._tp.text('Transformations'), self._tp.fnap(_TRANSFORMATION_DESCRIPTION), ), ])
def generator(self, header: str) -> SectionHierarchyGenerator: return h.hierarchy(header, paragraphs.constant( self._tp.fnap(_PRELUDE) ), [ h.child('cases-and-sub-suites', self._cases_and_sub_suites(CASES_AND_SUB_SUITES_HEADER)), h.child('common-test-case-contents', self._common_tc_contents(COMMON_CASE_CONTENTS_HEADER)), h.child( 'additional-test-case-conf', h.leaf( ADDITIONAL_TEST_CASE_CONFIG_HEADER, sections.constant_contents( docs.section_contents( self._tp.fnap(_ADDITIONAL_TEST_CASE_CONFIG))))), ])
def generator(self, header: str) -> SectionHierarchyGenerator: return h.hierarchy( header, paragraphs.constant(self._tp.fnap(_PRELUDE)), [ h.child('cases-and-sub-suites', self._cases_and_sub_suites(CASES_AND_SUB_SUITES_HEADER) ), h.child('common-test-case-contents', self._common_tc_contents(COMMON_CASE_CONTENTS_HEADER) ), h.child('additional-test-case-conf', h.leaf( ADDITIONAL_TEST_CASE_CONFIG_HEADER, sections.constant_contents( docs.section_contents(self._tp.fnap(_ADDITIONAL_TEST_CASE_CONFIG)) )) ), ])
def purpose(self) -> DescriptionWithSubSections: return DescriptionWithSubSections(self.single_line_description(), docs.section_contents(self._contents()))
def purpose(self) -> DescriptionWithSubSections: return DescriptionWithSubSections( concepts.ACTION_TO_CHECK_CONCEPT_INFO.single_line_description, docs.section_contents(self._description()))
def section_of_parsed(contents: str) -> SectionContentsConstructor: return sections.constant_contents( docs.section_contents(tp.fnap(contents)) )
def const_paragraphs(header_: StrOrStringText, initial_paragraphs: List[docs.ParagraphItem]) -> generator.SectionHierarchyGenerator: return h.leaf(header_, sections.constant_contents(docs.section_contents(initial_paragraphs)))
def contents_description(self) -> doc.SectionContents: return docs.section_contents( self.__tp.fnap(_CONTENTS_GENERIC_DESCRIPTION) + self.instruction_purpose_description())
def description(self) -> DescriptionWithSubSections: return DescriptionWithSubSections(_TP.text(misc_texts.SYMBOL_COMMAND_SINGLE_LINE_DESCRIPTION), docs.section_contents([]))
def contents_description(self) -> doc.SectionContents: return docs.section_contents( docs.paras('initial paragraphs') )
def description(self) -> DescriptionWithSubSections: return DescriptionWithSubSections( _TP.text(misc_texts.SYMBOL_COMMAND_SINGLE_LINE_DESCRIPTION), docs.section_contents([]))
def outcome(self, environment: ConstructionEnvironment) -> Optional[docs.SectionContents]: paragraphs = case_outcome_help.TEXT_PARSER.fnap(case_outcome_help.REPORTING) paragraphs += _TP.fnap(_OUTCOME_INITIAL_PARAGRAPHS_EXTRA) return docs.section_contents(paragraphs, [docs.section(case_outcome_help.ALL_EXIT_VALUES_SUMMARY_TABLE_HEADER, [case_outcome_help.all_exit_values_summary_table()])])
def contents_description(self) -> docs.SectionContents: return docs.section_contents(file_ref_contents_description('case'))
def description(self) -> SectionContents: return docs.section_contents(self._tp.fnap(_MAIN_DESCRIPTION_REST))
def contents_description(self) -> docs.SectionContents: return docs.section_contents( [docs.para('Consists of zero or more instructions.')] + self.instruction_purpose_description())
def act_phase_contents(self) -> doc.SectionContents: return section_contents(self._tp.fnap(_ACT_PHASE_CONTENTS))
def apply(self, environment: ConstructionEnvironment) -> docs.SectionContents: return docs.section_contents(self._paragraphs_constructor.apply(environment))
def contents_description(self) -> docs.SectionContents: return docs.section_contents([docs.para('Consists of zero or more instructions.')] + self.instruction_purpose_description())
def contents_description(self) -> docs.SectionContents: return docs.section_contents(path_contents_description('case'))
def act_phase_contents_syntax(self) -> SectionContents: return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS_SYNTAX))
def _cases_and_sub_suites(self, header: str) -> SectionHierarchyGenerator: return h.leaf( header, sections.constant_contents( docs.section_contents( self._cases_and_sub_suites_paragraphs())))
def _common_tc_contents(self, header: str) -> SectionHierarchyGenerator: return h.leaf( header, sections.constant_contents( docs.section_contents(self._common_tc_contents_paragraphs())))
def _section_contents(): return docs.section_contents(_paragraphs(), _sections())
def contents_description(self) -> doc.SectionContents: return docs.section_contents(docs.paras('initial paragraphs'))
def contents_description(self) -> doc.SectionContents: return docs.section_contents(self.__tp.fnap(_CONTENTS_GENERIC_DESCRIPTION) + self.instruction_purpose_description())
def section_of_parsed(contents: str) -> SectionContentsConstructor: return sections.constant_contents( docs.section_contents(tp.fnap(contents)))
def contents_description(self) -> doc.SectionContents: initial_paragraphs = self._tp.fnap(_CONTENTS_DESCRIPTION) + [_escape_sequence_table()] return docs.section_contents(initial_paragraphs)
def runTest(self): for type_category in [None, TypeCategory.DATA]: nrt = name_and_ref_target('SE1', type_category, 'single line description of SE1') test_cases = [ ('minimal', syntax_element_documentation(nrt.type_category, nrt, [], (), [], [], [])), ('with main description rest', syntax_element_documentation(nrt.type_category, nrt, [docs.para('a paragraph')], (), [], [], [])), ('with main description rest sub sections', syntax_element_documentation(nrt.type_category, nrt, [], [ docs.section('a section header', docs.paras('section contents')) ], [], [], [])), ('with main description rest, and notes', syntax_element_documentation( nrt.type_category, nrt, [], [ docs.section('a section header', docs.paras('section contents')) ], [], [], [], docs.section_contents( docs.paras('notes section contents')), )), ('with invokation variants', syntax_element_documentation(nrt.type_category, nrt, [], (), syntax_parts.INVOKATION_VARIANTS, [], [])), ('with syntax element descriptions', syntax_element_documentation( nrt.type_category, nrt, [], (), [], syntax_parts.SYNTAX_ELEMENT_DESCRIPTIONS, [])), ('see also', syntax_element_documentation( nrt.type_category, nrt, [], (), [], [], [CustomCrossReferenceId('custom-target-name')], )), ('full', syntax_element_documentation( nrt.type_category, nrt, [docs.para('a paragraph')], [ docs.section('a section header', docs.paras('section contents')) ], [InvokationVariant('syntax', [docs.para('a paragraph')])], syntax_parts.SYNTAX_ELEMENT_DESCRIPTIONS, [CustomCrossReferenceId('custom-target-name')], docs.section_contents( docs.paras('notes section contents')))), ] for test_case_name, documentation in test_cases: with self.subTest(test_case_name=test_case_name, type_category=type_category): # ARRANGE # renderer = sut.IndividualSyntaxElementConstructor( documentation) # ACT # actual = renderer.apply(CONSTRUCTION_ENVIRONMENT) # ASSERT # struct_check.is_article_contents.apply(self, actual)
def apply(self, environment: ConstructionEnvironment) -> docs.SectionContents: return docs.section_contents( self._paragraphs_constructor.apply(environment))
def _common_tc_contents(self, header: str) -> SectionHierarchyGenerator: return h.leaf( header, sections.constant_contents( docs.section_contents(self._common_tc_contents_paragraphs()) ))