Ejemplo n.º 1
0
 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())
         )
     )
Ejemplo n.º 2
0
def _act_examples(tp: TextParser) -> sections.SectionConstructor:
    return sections.section(
        docs.text('Examples'),
        sections.constant_contents(
            docs.section_contents(tp.fnap(_ACT_EXAMPLES))
        )
    )
Ejemplo n.º 3
0
def _act_examples(tp: TextParser) -> sections.SectionConstructor:
    return sections.section(
        docs.text('Examples'),
        sections.constant_contents(
            docs.section_contents(tp.fnap(_ACT_EXAMPLES))
        )
    )
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
 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))])
Ejemplo n.º 7
0
 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))
Ejemplo n.º 8
0
 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))
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 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),
             ),
         ]))
Ejemplo n.º 11
0
 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)
     ])
Ejemplo n.º 12
0
 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))
         ]
     )
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
 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()])
     ])
Ejemplo n.º 15
0
 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)))
Ejemplo n.º 16
0
 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))
Ejemplo n.º 17
0
    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(),
                                 ])

                ]))
Ejemplo n.º 18
0
 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),
         ),
     ])
Ejemplo n.º 19
0
 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))))),
     ])
Ejemplo n.º 20
0
 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))
                         ))
                     ),
         ])
Ejemplo n.º 21
0
 def purpose(self) -> DescriptionWithSubSections:
     return DescriptionWithSubSections(self.single_line_description(),
                                       docs.section_contents(self._contents()))
Ejemplo n.º 22
0
 def purpose(self) -> DescriptionWithSubSections:
     return DescriptionWithSubSections(
         concepts.ACTION_TO_CHECK_CONCEPT_INFO.single_line_description,
         docs.section_contents(self._description()))
Ejemplo n.º 23
0
 def section_of_parsed(contents: str) -> SectionContentsConstructor:
     return sections.constant_contents(
         docs.section_contents(tp.fnap(contents))
     )
Ejemplo n.º 24
0
 def const_paragraphs(header_: StrOrStringText,
                      initial_paragraphs: List[docs.ParagraphItem]) -> generator.SectionHierarchyGenerator:
     return h.leaf(header_,
                   sections.constant_contents(docs.section_contents(initial_paragraphs)))
Ejemplo n.º 25
0
 def contents_description(self) -> doc.SectionContents:
     return docs.section_contents(
         self.__tp.fnap(_CONTENTS_GENERIC_DESCRIPTION) +
         self.instruction_purpose_description())
Ejemplo n.º 26
0
 def description(self) -> DescriptionWithSubSections:
     return DescriptionWithSubSections(_TP.text(misc_texts.SYMBOL_COMMAND_SINGLE_LINE_DESCRIPTION),
                                       docs.section_contents([]))
Ejemplo n.º 27
0
 def contents_description(self) -> doc.SectionContents:
     return docs.section_contents(
         docs.paras('initial paragraphs')
     )
Ejemplo n.º 28
0
 def description(self) -> DescriptionWithSubSections:
     return DescriptionWithSubSections(
         _TP.text(misc_texts.SYMBOL_COMMAND_SINGLE_LINE_DESCRIPTION),
         docs.section_contents([]))
Ejemplo n.º 29
0
 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()])])
Ejemplo n.º 30
0
 def contents_description(self) -> docs.SectionContents:
     return docs.section_contents(file_ref_contents_description('case'))
Ejemplo n.º 31
0
 def description(self) -> SectionContents:
     return docs.section_contents(self._tp.fnap(_MAIN_DESCRIPTION_REST))
Ejemplo n.º 32
0
 def contents_description(self) -> docs.SectionContents:
     return docs.section_contents(
         [docs.para('Consists of zero or more instructions.')] +
         self.instruction_purpose_description())
Ejemplo n.º 33
0
 def act_phase_contents(self) -> doc.SectionContents:
     return section_contents(self._tp.fnap(_ACT_PHASE_CONTENTS))
Ejemplo n.º 34
0
 def apply(self, environment: ConstructionEnvironment) -> docs.SectionContents:
     return docs.section_contents(self._paragraphs_constructor.apply(environment))
Ejemplo n.º 35
0
 def contents_description(self) -> docs.SectionContents:
     return docs.section_contents([docs.para('Consists of zero or more instructions.')] +
                                  self.instruction_purpose_description())
Ejemplo n.º 36
0
 def contents_description(self) -> docs.SectionContents:
     return docs.section_contents(path_contents_description('case'))
Ejemplo n.º 37
0
 def act_phase_contents_syntax(self) -> SectionContents:
     return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS_SYNTAX))
Ejemplo n.º 38
0
 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())))
Ejemplo n.º 39
0
 def _common_tc_contents(self, header: str) -> SectionHierarchyGenerator:
     return h.leaf(
         header,
         sections.constant_contents(
             docs.section_contents(self._common_tc_contents_paragraphs())))
Ejemplo n.º 40
0
def _section_contents():
    return docs.section_contents(_paragraphs(), _sections())
Ejemplo n.º 41
0
 def contents_description(self) -> doc.SectionContents:
     return docs.section_contents(docs.paras('initial paragraphs'))
Ejemplo n.º 42
0
def _section_contents():
    return docs.section_contents(_paragraphs(), _sections())
Ejemplo n.º 43
0
 def contents_description(self) -> doc.SectionContents:
     return docs.section_contents(self.__tp.fnap(_CONTENTS_GENERIC_DESCRIPTION) +
                                  self.instruction_purpose_description())
Ejemplo n.º 44
0
 def section_of_parsed(contents: str) -> SectionContentsConstructor:
     return sections.constant_contents(
         docs.section_contents(tp.fnap(contents)))
Ejemplo n.º 45
0
 def act_phase_contents(self) -> doc.SectionContents:
     return section_contents(self._tp.fnap(_ACT_PHASE_CONTENTS))
Ejemplo n.º 46
0
 def contents_description(self) -> doc.SectionContents:
     initial_paragraphs = self._tp.fnap(_CONTENTS_DESCRIPTION) + [_escape_sequence_table()]
     return docs.section_contents(initial_paragraphs)
Ejemplo n.º 47
0
 def contents_description(self) -> doc.SectionContents:
     initial_paragraphs = self._tp.fnap(_CONTENTS_DESCRIPTION) + [_escape_sequence_table()]
     return docs.section_contents(initial_paragraphs)
Ejemplo n.º 48
0
 def const_paragraphs(header_: StrOrStringText,
                      initial_paragraphs: List[docs.ParagraphItem]) -> generator.SectionHierarchyGenerator:
     return h.leaf(header_,
                   sections.constant_contents(docs.section_contents(initial_paragraphs)))
Ejemplo n.º 49
0
 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)
Ejemplo n.º 50
0
 def apply(self,
           environment: ConstructionEnvironment) -> docs.SectionContents:
     return docs.section_contents(
         self._paragraphs_constructor.apply(environment))
Ejemplo n.º 51
0
 def _common_tc_contents(self, header: str) -> SectionHierarchyGenerator:
     return h.leaf(
         header,
         sections.constant_contents(
             docs.section_contents(self._common_tc_contents_paragraphs())
         ))