示例#1
0
class SimpleProgressSuiteReporterDocumentation(SuiteReporterDocumentation):
    def __init__(self):
        super().__init__(PROGRESS_REPORTER)
        format_map = {
        }
        self._parser = TextParser(format_map)

    def syntax_of_output(self) -> List[ParagraphItem]:
        return self._parser.fnap(_SYNTAX_OF_OUTPUT)

    def exit_code_description(self) -> List[ParagraphItem]:
        return (self._parser.fnap(_EXIT_CODE_DESCRIPTION_PRELUDE) +
                [self._exit_value_table(_exit_values_and_descriptions())])

    def _exit_value_table(self, exit_value_and_description_list: list) -> ParagraphItem:
        def _row(exit_value: ExitValue, description: str) -> List[TableCell]:
            return [
                cell(paras(str(exit_value.exit_code))),
                cell(paras(exit_value_text(exit_value))),
                cell(self._parser.fnap(description)),
            ]

        return first_row_is_header_table(
            [
                [
                    cell(paras(misc_texts.EXIT_CODE_TITLE)),
                    cell(paras(misc_texts.EXIT_IDENTIFIER_TITLE)),
                    cell(paras('When')),
                ]] +
            [_row(exit_value, description) for exit_value, description in exit_value_and_description_list],
            '  ')
示例#2
0
class CommandLineActorDocumentation(ActorDocumentation):
    def __init__(self):
        super().__init__(COMMAND_LINE_ACTOR)
        self._tp = TextParser({
            'phase': phase_names.PHASE_NAME_DICTIONARY,
            'LINE_COMMENT_MARKER': formatting.string_constant(LINE_COMMENT_MARKER),
        })

    def act_phase_contents(self) -> doc.SectionContents:
        return doc.SectionContents(self._tp.fnap(_ACT_PHASE_CONTENTS))

    def act_phase_contents_syntax(self) -> doc.SectionContents:
        documentation = ActPhaseDocumentationSyntax()
        initial_paragraphs = self._tp.fnap(SINGLE_LINE_PROGRAM_ACT_PHASE_CONTENTS_SYNTAX_INITIAL_PARAGRAPH)
        sub_sections = []
        synopsis_section = doc_utils.synopsis_section(
            invokation_variants_content(None,
                                        documentation.invokation_variants(),
                                        documentation.syntax_element_descriptions()))
        sub_sections.append(synopsis_section)
        return doc.SectionContents(initial_paragraphs, sub_sections)

    def _see_also_specific(self) -> List[SeeAlsoTarget]:
        return cross_reference_id_list([
            conf_params.HOME_ACT_DIRECTORY_CONF_PARAM_INFO,
            concepts.SHELL_SYNTAX_CONCEPT_INFO,
        ])
示例#3
0
class _TypeConcept(ConceptDocumentation):
    def __init__(self):
        super().__init__(concepts.TYPE_CONCEPT_INFO)
        self._parser = TextParser({
            'program_name': formatting.program_name(program_info.PROGRAM_NAME),
            'data': type_system.DATA_TYPE_CATEGORY_NAME,
            'logic': type_system.LOGIC_TYPE_CATEGORY_NAME,
        })

    def purpose(self) -> DescriptionWithSubSections:
        rest_paragraphs = self._parser.fnap(_REST_DESCRIPTION_1)
        rest_paragraphs += [
            _categories_list(self._list_header('{data} types'),
                             self._list_header('{logic} types'))
        ]
        rest_paragraphs += self._parser.fnap(_REST_DESCRIPTION_2)
        sub_sections = []
        return DescriptionWithSubSections(self.single_line_description(),
                                          SectionContents(rest_paragraphs,
                                                          sub_sections))

    def _list_header(self, template_string: str) -> str:
        return self._parser.format(template_string).capitalize()

    def see_also_targets(self) -> List[SeeAlsoTarget]:
        return list(map(lambda type_doc: type_doc.cross_reference_target(),
                        all_types.all_types()))
class FileInterpreterActorDocumentation(ActorDocumentation):
    CL_SYNTAX_RENDERER = cli_program_syntax.CommandLineSyntaxRenderer()

    ARG_SYNTAX_RENDERER = cli_program_syntax.ArgumentInArgumentDescriptionRenderer()

    def __init__(self):
        super().__init__(FILE_INTERPRETER_ACTOR)
        self._tp = TextParser({
            'shell_syntax_concept': formatting.concept_(concepts.SHELL_SYNTAX_CONCEPT_INFO),
            'LINE_COMMENT_MARKER': formatting.string_constant(LINE_COMMENT_MARKER),
        })

    def act_phase_contents(self) -> doc.SectionContents:
        return section_contents(self._tp.fnap(_ACT_PHASE_CONTENTS))

    def act_phase_contents_syntax(self) -> doc.SectionContents:
        documentation = ActPhaseDocumentationSyntax()
        initial_paragraphs = self._tp.fnap(SINGLE_LINE_PROGRAM_ACT_PHASE_CONTENTS_SYNTAX_INITIAL_PARAGRAPH)
        sub_sections = []
        synopsis_section = doc_utils.synopsis_section(
            invokation_variants_content(None,
                                        documentation.invokation_variants(),
                                        documentation.syntax_element_descriptions()))
        sub_sections.append(synopsis_section)
        return doc.SectionContents(initial_paragraphs, sub_sections)

    def _see_also_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.SHELL_SYNTAX_CONCEPT_INFO.cross_reference_target,
        ]
示例#5
0
class _HierarchyGenerator:
    def __init__(self, suite_help: TestSuiteHelp):
        self._suite_help = suite_help
        self._tp = TextParser({
            'program_name': formatting.program_name(program_info.PROGRAM_NAME),
            'conf_section': section_names.CONFIGURATION,
            'conf_phase': phase_names.CONFIGURATION,
        })

    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 _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 _cases_and_sub_suites_paragraphs(self) -> List[ParagraphItem]:
        ret_val = self._tp.fnap(_CASES_AND_SUB_SUITES)
        ret_val.append(sections_short_list(self._suite_help.test_cases_and_sub_suites_sections,
                                           default_section_name=section_names_plain.DEFAULT_SECTION_NAME,
                                           section_concept_name='section'))
        return ret_val

    def _common_tc_contents_paragraphs(self) -> List[ParagraphItem]:
        ret_val = self._tp.fnap(_COMMON_TC_CONTENTS)
        ret_val.append(sections_short_list(self._suite_help.test_case_phase_sections,
                                           default_section_name=section_names_plain.DEFAULT_SECTION_NAME,
                                           section_concept_name='section'))
        return ret_val
class _EnvironmentVariableConcept(ConceptDocumentation):
    def __init__(self):
        super().__init__(ENVIRONMENT_VARIABLE_CONCEPT_INFO)
        self._tp = TextParser({
            'program_name': formatting.program_name(program_info.PROGRAM_NAME),

            'env_vars__plain': self.name().plural,
            'env_instruction': InstructionName(instruction_names.ENV_VAR_INSTRUCTION_NAME),
            'tcds_concept': formatting.concept_(concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO),
        })

    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 see_also_targets(self) -> List[SeeAlsoTarget]:
        ret_val = name_and_cross_ref.cross_reference_id_list([
            concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO,
            conf_params.HOME_CASE_DIRECTORY_CONF_PARAM_INFO,
            conf_params.HOME_ACT_DIRECTORY_CONF_PARAM_INFO,
        ])
        ret_val += [
            phase_infos.SETUP.instruction_cross_reference_target(instruction_names.ENV_VAR_INSTRUCTION_NAME)
        ]
        return ret_val

    def _variables_from_setup(self) -> docs.Section:
        return _variables_section(phase_names.SETUP,
                                  _variables_list_paragraphs([
                                      self._item(var_name)
                                      for var_name in map(operator.itemgetter(0),
                                                          environment_variables.ENVIRONMENT_VARIABLES_SET_BEFORE_ACT)
                                  ]))

    def _variables_from_before_assert(self) -> docs.Section:
        return _variables_section(phase_names.BEFORE_ASSERT,
                                  _variables_list_paragraphs([
                                      self._item(var_name)
                                      for var_name in map(operator.itemgetter(0),
                                                          environment_variables.ENVIRONMENT_VARIABLES_SET_AFTER_ACT)
                                  ]))

    def _item(self, var_name: str) -> lists.HeaderContentListItem:
        return docs.list_item(directory_variable_name_text(var_name),
                              environment_variables.ENVIRONMENT_VARIABLE_DESCRIPTION.as_description_paragraphs(
                                  var_name))
class _TcdsConcept(ConceptDocumentation):
    def __init__(self):
        super().__init__(concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO)

        self._tp = TextParser({
            'program_name': formatting.program_name(program_info.PROGRAM_NAME),
            'path_type': formatting.entity_(types.PATH_TYPE_INFO)
        })

    def purpose(self) -> DescriptionWithSubSections:
        rest_paragraphs = []
        sub_sections = []
        rest_paragraphs += self._tp.fnap(_MAIN_DESCRIPTION_REST)
        rest_paragraphs += self._dir_structure_list()
        rest_paragraphs += self._tp.fnap(_MAIN_DESCRIPTION_LAST)
        return DescriptionWithSubSections(self.single_line_description(),
                                          SectionContents(rest_paragraphs, sub_sections))

    def see_also_targets(self) -> List[SeeAlsoTarget]:
        return [
            concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.cross_reference_target,
            concepts.SANDBOX_CONCEPT_INFO.cross_reference_target,
            syntax_elements.PATH_SYNTAX_ELEMENT.cross_reference_target,
        ]

    def _dir_structure_list(self) -> List[docs.ParagraphItem]:
        items = [
            self._dir_structure_item(concept, tc_dir_infos)
            for concept, tc_dir_infos in _DIR_STRUCTURES
        ]
        return [
            docs.simple_list_with_space_between_elements_and_content(items, lists.ListType.ITEMIZED_LIST)
        ]

    def _dir_structure_item(self,
                            dir_structure: SingularAndPluralNameAndCrossReferenceId,
                            tc_dir_infos: List[TcDirInfo],
                            ) -> lists.HeaderContentListItem:
        contents = [
            docs.para(dir_structure.single_line_description),
            self._dirs_list(tc_dir_infos)
        ]
        return docs.list_item(dir_structure.singular_name.capitalize(),
                              contents)

    def _dirs_list(self, tc_dir_infos: List[TcDirInfo]) -> docs.ParagraphItem:
        return docs.first_column_is_header_table([
            self._dir_row(tc_dir_info)
            for tc_dir_info in tc_dir_infos
        ])

    def _dir_row(self, tc_dir_info: TcDirInfo) -> List[docs.TableCell]:
        return [
            docs.text_cell(tc_dir_info.informative_name),
            docs.text_cell(tc_dir_info.single_line_description_str),
        ]
class FileContentsCheckerHelp:
    def __init__(self,
                 instruction_name: str,
                 checked_file: str,
                 initial_args_of_invokation_variants: List[a.ArgumentUsage]):
        self._checked_file = checked_file
        self.instruction_name = instruction_name
        self.initial_args_of_invokation_variants = initial_args_of_invokation_variants
        self._tp = TextParser({
            'checked_file': checked_file,
            'contents_matcher': formatting.syntax_element_(syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT),
            'action_to_check': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO),
            'program_type': formatting.symbol_type_(types.PROGRAM_TYPE_INFO),
        })

    def invokation_variants__file(self, actual_file: a.Named) -> List[InvokationVariant]:
        actual_file_arg = a.Single(a.Multiplicity.MANDATORY,
                                   actual_file)
        return [
            invokation_variant_from_args(
                [actual_file_arg] + file_contents_checker_arguments__non_program(),
                self._tp.fnap(_MAIN_INVOKATION__FILE__SYNTAX_DESCRIPTION)),
        ]

    def invokation_variants__stdout_err(self, program_option: a.OptionName) -> List[InvokationVariant]:
        return [
            invokation_variant_from_args(
                file_contents_checker_arguments__non_program(),
                self._tp.fnap(_MAIN_INVOKATION__STDOUT_ERR_ACTION_TO_CHECK__SYNTAX_DESCRIPTION)
            ),
            invokation_variant_from_args(
                file_contents_checker_arguments__program(program_option),
                self._tp.fnap(_MAIN_INVOKATION__STDOUT_ERR_PROGRAM__SYNTAX_DESCRIPTION)
            ),
        ]

    @staticmethod
    def see_also_targets__file() -> List[SeeAlsoTarget]:
        return cross_reference_id_list([
            syntax_elements.PATH_SYNTAX_ELEMENT,
            syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT,
        ])

    @staticmethod
    def see_also_targets__std_out_err() -> List[SeeAlsoTarget]:
        return cross_reference_id_list([
            syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT,
            syntax_elements.PROGRAM_SYNTAX_ELEMENT,
            concepts.ACTION_TO_CHECK_CONCEPT_INFO,
        ])
示例#9
0
class IndividualActorConstructor(ArticleContentsConstructor):
    def __init__(self, actor: ActorDocumentation):
        self.actor = actor
        self.rendering_environment = None
        format_map = {
            'actor_concept': formatting.concept_(concepts.ACTOR_CONCEPT_INFO),
            'act_phase': phase_names.ACT.emphasis,
        }
        self._parser = TextParser(format_map)

    def apply(self, environment: ConstructionEnvironment) -> doc.ArticleContents:
        self.rendering_environment = environment

        initial_paragraphs = self._default_reporter_info()
        initial_paragraphs.extend(self.actor.main_description_rest())
        sub_sections = []
        append_sections_if_contents_is_non_empty(
            sub_sections,
            [(self._parser.format('{act_phase} phase contents'), self.actor.act_phase_contents()),
             (self._parser.format('Syntax of {act_phase} phase contents'), self.actor.act_phase_contents_syntax())])
        sub_sections += see_also_sections(self.actor.see_also_targets(), environment)
        return doc.ArticleContents(docs.paras(self.actor.single_line_description()),
                                   doc.SectionContents(initial_paragraphs,
                                                       sub_sections))

    def _default_reporter_info(self) -> List[ParagraphItem]:
        from exactly_lib.definitions.entity.actors import DEFAULT_ACTOR
        if self.actor.singular_name() == DEFAULT_ACTOR.singular_name:
            return self._parser.fnap('This is the default {actor_concept}.')
        else:
            return []
示例#10
0
 def purpose(self) -> DescriptionWithSubSections:
     parse = TextParser({
         'phase': phase_names.PHASE_NAME_DICTIONARY,
     })
     return from_simple_description(
         Description(self.single_line_description(),
                     parse.fnap(WHAT_THE_TIMEOUT_APPLIES_TO)))
示例#11
0
class IndividualActorConstructor(ArticleContentsConstructor):
    def __init__(self, actor: ActorDocumentation):
        self.actor = actor
        self.rendering_environment = None
        format_map = {
            'actor_concept': formatting.concept_(concepts.ACTOR_CONCEPT_INFO),
            'act_phase': phase_names.ACT.emphasis,
        }
        self._parser = TextParser(format_map)

    def apply(self, environment: ConstructionEnvironment) -> doc.ArticleContents:
        self.rendering_environment = environment

        initial_paragraphs = self._default_reporter_info()
        initial_paragraphs.extend(self.actor.main_description_rest())
        sub_sections = []
        append_sections_if_contents_is_non_empty(
            sub_sections,
            [
                (self._parser.format('{act_phase} phase contents'), self.actor.act_phase_contents()),
                (self._parser.format('Syntax of {act_phase} phase contents'), self.actor.act_phase_contents_syntax()),
                (headers.NOTES__HEADER__CAPITALIZED, self.actor.notes()),
            ]
        )
        sub_sections += see_also_sections(self.actor.see_also_targets(), environment)
        return doc.ArticleContents(docs.paras(self.actor.single_line_description()),
                                   doc.SectionContents(initial_paragraphs,
                                                       sub_sections))

    def _default_reporter_info(self) -> List[ParagraphItem]:
        from exactly_lib.definitions.entity.actors import DEFAULT_ACTOR
        if self.actor.singular_name() == DEFAULT_ACTOR.singular_name:
            return self._parser.fnap('This is the default {actor_concept}.')
        else:
            return []
class _SectionThatIsIdenticalToTestCasePhase(TestSuiteSectionDocumentationBaseForSectionWithoutInstructions):
    def __init__(self,
                 phase_name: str,
                 contents_is_inserted_before_case_contents: bool):
        super().__init__(phase_name)
        self._contents_is_inserted_before_case_contents = contents_is_inserted_before_case_contents
        self._tp = TextParser({
            'phase': self.section_info.name,
        })

    def contents_description(self) -> SectionContents:
        return self._tp.section_contents(_CONTENTS_DESCRIPTION)

    def purpose(self) -> Description:
        paragraphs = self._tp.fnap(_CORRESPONDENCE_DESCRIPTION)
        paragraphs += insertion_position_description(self.section_info.name,
                                                     self._contents_is_inserted_before_case_contents)

        return Description(self._tp.text(_SINGLE_LINE_DESCRIPTION),
                           paragraphs)

    @property
    def see_also_targets(self) -> List[SeeAlsoTarget]:
        return [
            TestCasePhaseCrossReference(self.name.plain)
        ]
示例#13
0
def _act_examples(tp: TextParser) -> sections.SectionConstructor:
    return sections.section(
        docs.text('Examples'),
        sections.constant_contents(
            docs.section_contents(tp.fnap(_ACT_EXAMPLES))
        )
    )
示例#14
0
class ConfigurationSectionDocumentation(TestSuiteSectionDocumentationForSectionWithInstructions):
    def __init__(self,
                 name: str,
                 instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)
        self._tp = TextParser({
            'conf_phase': phase_names.CONFIGURATION,
        })

    def instructions_section_header(self) -> docs.Text:
        return docs.text('Additional instructions')

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return []

    def contents_description(self) -> docs.SectionContents:
        return self._tp.section_contents(_CONTENTS_DESCRIPTION)

    def purpose(self) -> Description:
        paragraphs = self._tp.fnap(_PURPOSE_REST_TEXT)
        paragraphs += test_case_phase_sections.insertion_position_description(self.section_info.name, True)
        return Description(self._tp.text(_PURPOSE_SINGLE_LINE_DESCRIPTION_TEXT),
                           paragraphs)

    @property
    def see_also_targets(self) -> List[SeeAlsoTarget]:
        return [
            phase_infos.CONFIGURATION.cross_reference_target
        ]
示例#15
0
class BeforeAssertPhaseDocumentation(
        TestCasePhaseDocumentationForPhaseWithInstructions):
    def __init__(self, name: str, instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)
        self._tp = TextParser({
            'phase':
            phase_names.PHASE_NAME_DICTIONARY,
            'CWD':
            formatting.concept_(
                concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
        })

    def purpose(self) -> Description:
        return Description(self._tp.text(ONE_LINE_DESCRIPTION),
                           self._tp.fnap(REST_OF_DESCRIPTION))

    def sequence_info(self) -> PhaseSequenceInfo:
        return PhaseSequenceInfo(
            sequence_info__preceding_phase(phase_names.ACT),
            sequence_info__succeeding_phase(phase_names.ASSERT),
            prelude=sequence_info__not_executed_if_execution_mode_is_skip())

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return self._tp.fnap(INSTRUCTION_PURPOSE_DESCRIPTION)

    def execution_environment_info(self) -> ExecutionEnvironmentInfo:
        previous = '{setup} phase'.format(setup=phase_names.SETUP.emphasis)
        return ExecutionEnvironmentInfo(
            cwd_at_start_of_phase_is_same_as_at_end_of_the(previous),
            prologue=execution_environment_prologue_for_post_act_phase(),
            environment_variables_prologue=
            env_vars_prologue_for_inherited_from_previous_phase(),
            timeout_prologue=timeout_prologue_for_inherited_from_previous_phase(
            ),
        )

    @property
    def _see_also_targets_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.SDS_CONCEPT_INFO.cross_reference_target,
            concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO.
            cross_reference_target,
            concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.cross_reference_target,
            concepts.TIMEOUT_CONCEPT_INFO.cross_reference_target,
            phase_infos.ACT.cross_reference_target,
            phase_infos.ASSERT.cross_reference_target,
        ]
示例#16
0
class NullActorDocumentation(ActorDocumentation):
    def __init__(self):
        super().__init__(actors.NULL_ACTOR)
        format_map = {
            'null': actors.NULL_ACTOR.singular_name,
            'actor': ACTOR_CONCEPT_INFO.name.singular,
        }
        self._parser = TextParser(format_map)

    def main_description_rest(self) -> List[ParagraphItem]:
        return self._parser.fnap(_MAIN_DESCRIPTION_REST)

    def act_phase_contents(self) -> SectionContents:
        return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS))

    def act_phase_contents_syntax(self) -> SectionContents:
        return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS_SYNTAX))
示例#17
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))])
示例#18
0
class ConfigurationPhaseDocumentation(
        TestCasePhaseDocumentationForPhaseWithInstructions):
    def __init__(self, name: str, instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)

        self._parser = TextParser({
            'configuration_parameters':
            formatting.concept(
                concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.plural_name),
            'execution_mode':
            formatting.conf_param_(
                conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO),
            'SKIP':
            NAME_SKIP,
            'setup':
            phase_names.SETUP,
        })

    def purpose(self) -> Description:
        first_line = self._parser.text(ONE_LINE_DESCRIPTION)
        remaining_lines = []
        return Description(first_line, remaining_lines)

    def sequence_info(self) -> PhaseSequenceInfo:
        preceding_phase = self._parser.fnap(SEQUENCE_INFO__PRECEDING_PHASE)
        succeeding_phase = self._parser.fnap(SEQUENCE_INFO__SUCCEEDING_PHASE)
        return PhaseSequenceInfo(preceding_phase, succeeding_phase)

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return self._parser.fnap(INSTRUCTION_PURPOSE_DESCRIPTION)

    def execution_environment_info(self) -> ExecutionEnvironmentInfo:
        return ExecutionEnvironmentInfo(
            cwd_at_start_of_phase_for_configuration_phase())

    @property
    def _see_also_targets_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.
            cross_reference_target,
            conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO.
            cross_reference_target,
            self.section_info.instruction_cross_reference_target(
                TEST_CASE_STATUS_INSTRUCTION_NAME),
            phase_infos.SETUP.cross_reference_target,
        ]
示例#19
0
class DocumentationElements:
    def __init__(
        self,
        format_map: Dict[str, str],
        src_rel_opt_conf: rel_opts_configuration.
        RelOptionArgumentConfiguration,
        src_description: str,
        dst_rel_opt_conf: rel_opts_configuration.
        RelOptionArgumentConfiguration,
        dst_description: str,
    ):
        self._src_rel_opt_conf = src_rel_opt_conf
        self._src_description = src_description
        self._dst_rel_opt_conf = dst_rel_opt_conf
        self._dst_description = dst_description
        self._tp = TextParser(format_map)

    def syntax_element_descriptions(self) -> List[SyntaxElementDescription]:
        return self._syntax_element_descriptions_for_src(
        ) + self._syntax_element_descriptions_for_dst()

    def _syntax_element_descriptions_for_src(
            self) -> List[SyntaxElementDescription]:
        return [
            rel_opts.path_element(
                instruction_arguments.SOURCE_PATH_ARGUMENT.name,
                self._src_rel_opt_conf.options,
                self._tp.fnap(self._src_description))
        ]

    def _syntax_element_descriptions_for_dst(
            self) -> List[SyntaxElementDescription]:
        return [
            rel_opts.path_element(
                instruction_arguments.DESTINATION_PATH_ARGUMENT.name,
                self._dst_rel_opt_conf.options,
                self._tp.fnap(self._dst_description))
        ]

    def see_also_targets(self) -> List[CrossReferenceId]:
        name_and_cross_refs = [syntax_elements.PATH_SYNTAX_ELEMENT]
        name_and_cross_refs += rel_opts.see_also_name_and_cross_refs(
            self._dst_rel_opt_conf.options)
        name_and_cross_refs += rel_opts.see_also_name_and_cross_refs(
            self._src_rel_opt_conf.options)
        return name_and_cross_ref.cross_reference_id_list(name_and_cross_refs)
示例#20
0
 def purpose(self) -> DescriptionWithSubSections:
     tp = TextParser({
         'reporter_option': formatting.cli_option(OPTION_FOR_REPORTER),
         'default_reporter': formatting.entity(reporters.DEFAULT_REPORTER.singular_name),
     })
     return from_simple_description(
         Description(self.single_line_description(),
                     tp.fnap(_DESCRIPTION_REST)))
示例#21
0
def abs_or_rel_path_of_existing(file_type: str, syntax_element: str,
                                relativity_root: str) -> List[ParagraphItem]:
    tp = TextParser({
        'file_type': file_type,
        'syntax_element': syntax_element,
        'relativity_root': relativity_root
    })
    return tp.fnap(_PATH_DESCRIPTION) + paths_uses_posix_syntax()
示例#22
0
def _what_outcome_depends_on(tp: TextParser) -> ParagraphItem:
    items = [
        list_item(tp.text(_OUTCOME_DEPENDENCE__STATUS),
                  tp.fnap(_OUTCOME_DEFAULT_STATUS)),
        list_item(tp.text(_OUTCOME_DEPENDENCE__ASSERT_PHASE)),
    ]
    return lists.HeaderContentList(items,
                                   lists.Format(lists.ListType.ORDERED_LIST,
                                                custom_separations=SEPARATION_OF_HEADER_AND_CONTENTS))
def cd_instruction_section_on_def_instruction() -> List[ParagraphItem]:
    tp = TextParser({
        'current_directory_concept': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
        'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME),
        'symbol_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.singular_name),
        'rel_cd_option': formatting.cli_option(path.REL_CWD_OPTION),
        'path_type': types.PATH_TYPE_INFO.name,
    })
    return tp.fnap(_CD_INSTRUCTION_SECTION_ON_DEF_INSTRUCTION)
def abs_or_rel_path_of_existing(file_type: str,
                                syntax_element: str,
                                relativity_root: str) -> List[ParagraphItem]:
    tp = TextParser({
        'file_type': file_type,
        'syntax_element': syntax_element,
        'relativity_root': relativity_root
    })
    return tp.fnap(_PATH_DESCRIPTION) + paths_uses_posix_syntax()
def def_instruction_rel_cd_description(path_arg_name: str) -> List[ParagraphItem]:
    tp = TextParser({
        'current_directory_concept': formatting.concept_(
            concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
        'path_arg': path_arg_name,
        'symbol_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.singular_name),
        'symbols_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.plural_name),
    })
    return tp.fnap(_DEF_INSTRUCTION_REL_CD_DESCRIPTION)
示例#26
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))
def cd_instruction_section_on_def_instruction() -> List[ParagraphItem]:
    tp = TextParser({
        'current_directory_concept': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
        'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME),
        'symbol_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.singular_name),
        'rel_cd_option': formatting.cli_option(file_ref.REL_CWD_OPTION),
        'path_type': formatting.keyword(types.PATH_TYPE_INFO.name.singular),
    })
    return tp.fnap(_CD_INSTRUCTION_SECTION_ON_DEF_INSTRUCTION)
示例#28
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     tp = TextParser({
         'STRING_SOURCE':
         formatting.syntax_element_(
             syntax_elements.STRING_SOURCE_SYNTAX_ELEMENT),
         'model':
         matcher_model.TEXT_MODEL,
     })
     return tp.fnap(_DESCRIPTION)
示例#29
0
    def _contents(self) -> Sequence[ParagraphItem]:
        tp = 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,
            'null_actor': formatting.entity(actors.NULL_ACTOR.singular_name),
            'actor_conf_param': formatting.conf_param_(conf_params.ACTOR_CONF_PARAM_INFO),
            'conf_param': concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.name,
            'space': misc_texts.WHITESPACE,
        })
        ret_val = list(tp.fnap(_AFTER_SLD__BEFORE_EXAMPLES))
        ret_val += atc.atc_examples()
        ret_val += tp.fnap(_AFTER_SLD__AFTER_EXAMPLES)

        return ret_val
示例#30
0
def _types_categories_list(tp: TextParser) -> ParagraphItem:
    return docs.simple_list_with_space_between_elements_and_content(
        [
            docs.list_item(type_system.TYPE_CATEGORY_NAME[category],
                           tp.fnap(_TYPE_CATEGORY_DESCRIPTION[category]))
            for category in type_system.TypeCategory
        ],
        ListType.ITEMIZED_LIST,
    )
示例#31
0
class Documentation(SectionContentsConstructor):
    def __init__(self):
        self._tp = TextParser({
            'test_case_file':
            'helloworld.case',
            'EXECUTABLE_PROGRAM':
            PROGRAM_NAME,
            'program_name':
            formatting.program_name(PROGRAM_NAME),
            'action_to_check':
            'helloworld',
            'ATC':
            formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO),
            'CONTENTS_EQUALS_ARGUMENT':
            EQUALS_ARGUMENT,
            'INT_EQUALS_OPERATOR':
            comparators.EQ.name,
            'act':
            phase_names.ACT,
            'assert':
            phase_names.ASSERT,
            'PASS':
            exit_values.EXECUTION__PASS.exit_identifier,
            'FAIL':
            exit_values.EXECUTION__FAIL.exit_identifier,
            'stdout_instruction':
            instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME,
            'exit_code_instruction':
            instruction_names.EXIT_CODE_INSTRUCTION_NAME,
            'executable_file':
            formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE),
            'console_style':
            std_tags.CONSOLE_TEXT,
            'HERE_DOCUMENT_MARKER_PREFIX':
            string.HERE_DOCUMENT_MARKER_PREFIX,
            'MARKER':
            'EOF',
        })

    def apply(self,
              environment: ConstructionEnvironment) -> doc.SectionContents:
        return doc.SectionContents(
            self._tp.fnap(_INITIAL_DESCRIPTION),
            [docs.section('File structure', self._tp.fnap(_FILE_STRUCTURE))])
示例#32
0
 def purpose(self) -> DescriptionWithSubSections:
     tp = TextParser({
         'reporter_option':
         formatting.cli_option(OPTION_FOR_REPORTER),
         'default_reporter':
         formatting.entity(reporters.DEFAULT_REPORTER.singular_name),
     })
     return from_simple_description(
         Description(self.single_line_description(),
                     tp.fnap(_DESCRIPTION_REST)))
示例#33
0
 def purpose(self) -> DescriptionWithSubSections:
     tp = TextParser({
         'the_concept': formatting.concept(self.name().singular),
         'preprocessor_option': formatting.cli_option(OPTION_FOR_PREPROCESSOR),
         'is_a_shell_cmd': misc_texts.IS_A_SHELL_CMD,
         'an_exit_code': misc_texts.EXIT_CODE.singular_determined.capitalize(),
     })
     return from_simple_description(
         Description(self.single_line_description(),
                     tp.fnap(_DESCRIPTION_REST)))
示例#34
0
class JunitSuiteReporterDocumentation(SuiteReporterDocumentation):
    def __init__(self):
        super().__init__(JUNIT_REPORTER)
        format_map = {
            'EXIT_CODE': str(junit.UNCONDITIONAL_EXIT_CODE),
            'test_suite_element': junit.TEST_SUITE_ELEMENT_NAME,
            'test_suites_element': junit.TEST_SUITES_ELEMENT_NAME,
            'url': JUNIT_XML_SYNTAX_SEE_ALSO_URL_INFO.url,
        }
        self._parser = TextParser(format_map)

    def syntax_of_output(self) -> List[ParagraphItem]:
        return self._parser.fnap(_SYNTAX_OF_OUTPUT)

    def exit_code_description(self) -> List[ParagraphItem]:
        return self._parser.fnap(_EXIT_CODE_DESCRIPTION)

    def _see_also_targets__specific(self) -> List[SeeAlsoTarget]:
        return [JUNIT_XML_SYNTAX_SEE_ALSO_URL_INFO]
示例#35
0
def _what_outcome_depends_on(tp: TextParser) -> ParagraphItem:
    items = [
        list_item(tp.text(_OUTCOME_DEPENDENCE__STATUS),
                  tp.fnap(_OUTCOME_DEFAULT_STATUS)),
        list_item(tp.text(_OUTCOME_DEPENDENCE__ASSERT_PHASE)),
    ]
    return lists.HeaderContentList(
        items,
        lists.Format(lists.ListType.ORDERED_LIST,
                     custom_separations=SEPARATION_OF_HEADER_AND_CONTENTS))
示例#36
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     tp = TextParser({
         'program': types.PROGRAM_TYPE_INFO.name,
         'PROGRAM': syntax_elements.PROGRAM_SYNTAX_ELEMENT.singular_name,
         'stdin': misc_texts.STDIN,
         'stdout': misc_texts.STDOUT,
         'model': matcher_model.TEXT_MODEL,
     })
     return tp.fnap(_DESCRIPTION_REST
                    ) + texts.run_outcome__with_ignored_exit_code_option()
示例#37
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     tp = TextParser({
         'model':
         matcher_model.INTEGER_MATCHER_MODEL,
         'operator':
         self._operator.description,
         'LHS':
         syntax_elements.INTEGER_SYNTAX_ELEMENT.singular_name,
     })
     return tp.fnap(_COMPARISON_DESCRIPTION)
def def_instruction_rel_cd_description(path_arg_name: str) -> List[ParagraphItem]:
    tp = TextParser({
        'current_directory_concept': formatting.concept_(
            concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
        'path_arg': path_arg_name,
        'symbol_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.singular_name),
        'symbols_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.plural_name),
        'Note': headers.NOTE_LINE_HEADER,
    })
    return tp.fnap(_DEF_INSTRUCTION_REL_CD_DESCRIPTION)
示例#39
0
 def purpose(self) -> DescriptionWithSubSections:
     parser = TextParser({
         'phase': phase_names.PHASE_NAME_DICTIONARY,
         'the_concept': formatting.conf_param_(conf_params.HOME_ACT_DIRECTORY_CONF_PARAM_INFO),
         'home_dir_env_var': ENV_VAR_HOME_ACT,
         'rel_option': formatting.cli_option(REL_HOME_ACT_OPTION)
     })
     return from_simple_description(
         Description(self.single_line_description(),
                     parser.fnap(_REST_DESCRIPTION)))
示例#40
0
class JunitSuiteReporterDocumentation(SuiteReporterDocumentation):
    def __init__(self):
        super().__init__(JUNIT_REPORTER)
        format_map = {
            'EXIT_CODE': str(junit.UNCONDITIONAL_EXIT_CODE),
            'test_suite_element': junit.TEST_SUITE_ELEMENT_NAME,
            'test_suites_element': junit.TEST_SUITES_ELEMENT_NAME,
            'url': JUNIT_XML_SYNTAX_SEE_ALSO_URL_INFO.url,
        }
        self._parser = TextParser(format_map)

    def syntax_of_output(self) -> List[ParagraphItem]:
        return self._parser.fnap(_SYNTAX_OF_OUTPUT)

    def exit_code_description(self) -> List[ParagraphItem]:
        return self._parser.fnap(_EXIT_CODE_DESCRIPTION)

    def _see_also_targets__specific(self) -> List[SeeAlsoTarget]:
        return [JUNIT_XML_SYNTAX_SEE_ALSO_URL_INFO]
示例#41
0
class SetupPhaseDocumentation(TestCasePhaseDocumentationForPhaseWithInstructions):
    def __init__(self,
                 name: str,
                 instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)
        self._tp = TextParser({
            'phase': phase_names.PHASE_NAME_DICTIONARY,
            'ATC': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO),
            'env_var': concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.name,
            'env_vars_default': concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.default,
            'timeout_default': concepts.TIMEOUT_CONCEPT_INFO.default,
            'stdin': misc_texts.STDIN,
            'SDS': concepts.SDS_CONCEPT_INFO.name,
        })

    def purpose(self) -> Description:
        return Description(self._tp.text(ONE_LINE_DESCRIPTION),
                           self._tp.fnap(REST_OF_DESCRIPTION))

    def sequence_info(self) -> PhaseSequenceInfo:
        return PhaseSequenceInfo(self._tp.fnap(SEQUENCE_INFO__PRECEDING_PHASE),
                                 sequence_info__succeeding_phase(phase_names.ACT),
                                 prelude=sequence_info__not_executed_if_execution_mode_is_skip())

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return self._tp.fnap(INSTRUCTION_PURPOSE_DESCRIPTION)

    def execution_environment_info(self) -> ExecutionEnvironmentInfo:
        return ExecutionEnvironmentInfo(cwd_at_start_of_phase_first_phase_executed_in_the_sandbox(),
                                        environment_variables_prologue=self._tp.fnap(ENV_VARS_PROLOGUE),
                                        timeout_prologue=self._tp.fnap(TIMEOUT_PROLOGUE))

    @property
    def _see_also_targets_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.SDS_CONCEPT_INFO.cross_reference_target,
            concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO.cross_reference_target,
            concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.cross_reference_target,
            concepts.TIMEOUT_CONCEPT_INFO.cross_reference_target,
            phase_infos.CONFIGURATION.cross_reference_target,
            phase_infos.ACT.cross_reference_target,
        ]
示例#42
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     from exactly_lib.impls.types.matcher import help_texts
     from exactly_lib.util.textformat.textformat_parser import TextParser
     tp = TextParser({
         'MODEL': matcher_model.TEXT_MODEL,
         'PROGRAM': syntax_elements.PROGRAM_SYNTAX_ELEMENT.singular_name,
         'stdin': misc_texts.STDIN,
     })
     return help_texts.run_program_matcher_description(
         tp.fnap(_EXE_ENV_DESCRIPTION)
     )
示例#43
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     tp = TextParser({
         'REGEX':
         syntax_elements.REGEX_SYNTAX_ELEMENT.singular_name,
         'full_regex_match':
         option_syntax.option_syntax(
             matcher_options.FULL_MATCH_ARGUMENT_OPTION),
         'model':
         matcher_model.TEXT_MODEL,
     })
     return tp.fnap(_DESCRIPTION)
示例#44
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))
         ]
     )
    def description_rest(self) -> Sequence[ParagraphItem]:
        tp = TextParser({
            'quantifier_description': logic.QUANTIFIER_ARGUMENTS[self._quantifier],
            'element': self._element_name,
            'element_matcher': self._element_matcher_syntax_info.singular_name,
        })

        ret_val = tp.fnap(_DESCRIPTION_OF_QUANTIFICATION)
        ret_val += texts.type_expression_has_syntax_of_primitive([
            self._element_matcher_syntax_info.singular_name,
        ])
        return ret_val
def transformation_syntax_element_description(the_tested_file: str) -> SyntaxElementDescription:
    text_parser = TextParser({
        'the_tested_file': the_tested_file,
        'transformer': syntax_elements.STRING_TRANSFORMER_SYNTAX_ELEMENT.singular_name,
    })
    return cli_argument_syntax_element_description(
        instruction_arguments.STRING_TRANSFORMATION_ARGUMENT,
        text_parser.fnap(_TRANSFORMATION_DESCRIPTION),
        [
            InvokationVariant(cl_syntax.arg_syntax(instruction_arguments.TRANSFORMATION_OPTION)),
        ]
    )
示例#47
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)))
示例#48
0
class CleanupPhaseDocumentation(TestCasePhaseDocumentationForPhaseWithInstructions):
    def __init__(self,
                 name: str,
                 instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)
        self._tp = TextParser({
            'phase': phase_names.PHASE_NAME_DICTIONARY,
            'SKIP': NAME_SKIP,
            'execution_mode': formatting.conf_param_(conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO),
            'ATC': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO),
        })

    def purpose(self) -> Description:
        return Description(self._tp.text(ONE_LINE_DESCRIPTION),
                           self._tp.fnap(REST_OF_DESCRIPTION))

    def sequence_info(self) -> PhaseSequenceInfo:
        return PhaseSequenceInfo(self._tp.fnap(_SEQUENCE_INFO__PRECEDING_PHASE),
                                 self._tp.fnap(_SEQUENCE_INFO__SUCCEEDING_PHASE),
                                 prelude=sequence_info__not_executed_if_execution_mode_is_skip())

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return self._tp.fnap(INSTRUCTION_PURPOSE_DESCRIPTION)

    def execution_environment_info(self) -> ExecutionEnvironmentInfo:
        return ExecutionEnvironmentInfo(
            cwd_at_start_of_phase_for_non_first_phases(),
            EXISTS_AT_BEFORE_ASSERT_MAIN,
            environment_variables_prologue=env_vars_prologue_for_inherited_from_previous_phase())

    @property
    def _see_also_targets_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.SANDBOX_CONCEPT_INFO.cross_reference_target,
            concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.cross_reference_target,
            conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO.cross_reference_target,
            phase_infos.ASSERT.cross_reference_target,
            phase_infos.CONFIGURATION.instruction_cross_reference_target(TEST_CASE_STATUS_INSTRUCTION_NAME),
        ]
示例#49
0
def with_replaced_env_vars_help() -> SectionContents:
    text_parser = TextParser({
        'checked_file': 'checked file',
        'program_name': program_info.PROGRAM_NAME,
        'home_act_env_var': environment_variables.ENV_VAR_HOME_ACT,
        'home_case_env_var': environment_variables.ENV_VAR_HOME_CASE,
        'home_env_var_with_replacement_precedence': HOME_ENV_VAR_WITH_REPLACEMENT_PRECEDENCE,
    })
    prologue = text_parser.fnap(_WITH_REPLACED_TCDS_PATHS_PROLOGUE)
    variables_list = [docs.simple_header_only_list(map(directory_variable_name_text,
                                                       sorted(environment_variables.ALL_REPLACED_ENV_VARS)),
                                                   docs.lists.ListType.ITEMIZED_LIST)]
    return SectionContents(prologue + variables_list)
示例#50
0
class _Documentation(SyntaxElementDocumentation):
    def __init__(self):
        super().__init__(TypeCategory.DATA,
                         syntax_elements.LIST_SYNTAX_ELEMENT)

        self._tp = TextParser({
            'string_type': formatting.keyword(types.STRING_TYPE_INFO.name.singular),
            'list_type': formatting.keyword(types.LIST_TYPE_INFO.name.singular),
            'symbol': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO),
        })

    def invokation_variants(self) -> list:
        return [
            InvokationVariant(
                cl_syntax.cl_syntax_for_args(self._cl_arguments())
            )
        ]

    def syntax_element_descriptions(self) -> list:
        return [
            self._symbol_reference_sed(),
        ]

    def main_description_rest_paragraphs(self) -> list:
        return []

    def see_also_targets(self) -> list:
        info_refs = cross_reference_id_list([
            syntax_elements.STRING_SYNTAX_ELEMENT,
            syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT,
            concepts.SYMBOL_CONCEPT_INFO,
            types.LIST_TYPE_INFO,
        ])
        plain_refs = [
            define_symbol.DEFINE_SYMBOL_INSTRUCTION_CROSS_REFERENCE,
        ]
        return info_refs + plain_refs

    def _symbol_reference_sed(self) -> SyntaxElementDescription:
        return SyntaxElementDescription(syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT.argument.name,
                                        self._tp.fnap(_SYMBOL_REFERENCE_DESCRIPTION))

    @staticmethod
    def _cl_arguments() -> list:
        return [
            a.Choice(a.Multiplicity.ZERO_OR_MORE,
                     [
                         syntax_elements.STRING_SYNTAX_ELEMENT.argument,
                         syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT.argument,
                     ]),
        ]
示例#51
0
class ConfigurationPhaseDocumentation(TestCasePhaseDocumentationForPhaseWithInstructions):
    def __init__(self,
                 name: str,
                 instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)

        self._parser = TextParser({
            'configuration_parameters': formatting.concept(concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.plural_name),
            'execution_mode': formatting.conf_param_(conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO),
            'SKIP': NAME_SKIP,
            'setup': phase_names.SETUP,
        })

    def purpose(self) -> Description:
        first_line = self._parser.text(ONE_LINE_DESCRIPTION)
        remaining_lines = []
        return Description(first_line, remaining_lines)

    def sequence_info(self) -> PhaseSequenceInfo:
        preceding_phase = self._parser.fnap(SEQUENCE_INFO__PRECEDING_PHASE)
        succeeding_phase = self._parser.fnap(SEQUENCE_INFO__SUCCEEDING_PHASE)
        return PhaseSequenceInfo(preceding_phase, succeeding_phase)

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return self._parser.fnap(INSTRUCTION_PURPOSE_DESCRIPTION)

    def execution_environment_info(self) -> ExecutionEnvironmentInfo:
        return ExecutionEnvironmentInfo(cwd_at_start_of_phase_for_configuration_phase(),
                                        env_vars_for_configuration_phase())

    @property
    def _see_also_targets_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.cross_reference_target,
            conf_params.TEST_CASE_STATUS_CONF_PARAM_INFO.cross_reference_target,
            self.section_info.instruction_cross_reference_target(TEST_CASE_STATUS_INSTRUCTION_NAME),
            phase_infos.SETUP.cross_reference_target,
        ]
示例#52
0
class BeforeAssertPhaseDocumentation(TestCasePhaseDocumentationForPhaseWithInstructions):
    def __init__(self,
                 name: str,
                 instruction_set: SectionInstructionSet):
        super().__init__(name, instruction_set)
        self._tp = TextParser({
            'phase': phase_names.PHASE_NAME_DICTIONARY,
            'CWD': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
        })

    def purpose(self) -> Description:
        return Description(self._tp.text(ONE_LINE_DESCRIPTION),
                           self._tp.fnap(REST_OF_DESCRIPTION))

    def sequence_info(self) -> PhaseSequenceInfo:
        return PhaseSequenceInfo(sequence_info__preceding_phase(phase_names.ACT),
                                 sequence_info__succeeding_phase(phase_names.ASSERT),
                                 prelude=sequence_info__not_executed_if_execution_mode_is_skip())

    def instruction_purpose_description(self) -> List[ParagraphItem]:
        return self._tp.fnap(INSTRUCTION_PURPOSE_DESCRIPTION)

    def execution_environment_info(self) -> ExecutionEnvironmentInfo:
        previous = '{setup} phase'.format(setup=phase_names.SETUP.emphasis)
        return ExecutionEnvironmentInfo(
            cwd_at_start_of_phase_is_same_as_at_end_of_the(previous),
            EXISTS_AT_BEFORE_ASSERT_MAIN,
            prologue=execution_environment_prologue_for_post_act_phase(),
            environment_variables_prologue=env_vars_prologue_for_inherited_from_previous_phase())

    @property
    def _see_also_targets_specific(self) -> List[SeeAlsoTarget]:
        return [
            concepts.SANDBOX_CONCEPT_INFO.cross_reference_target,
            concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.cross_reference_target,
            phase_infos.ACT.cross_reference_target,
            phase_infos.ASSERT.cross_reference_target,
        ]
示例#53
0
 def purpose(self) -> DescriptionWithSubSections:
     tp = TextParser({
         'the_concept':
         formatting.concept(self.name().singular),
         'preprocessor_option':
         formatting.cli_option(OPTION_FOR_PREPROCESSOR),
         'is_a_system_cmd':
         misc_texts.IS_A_SYSTEM_CMD,
         'exit_code':
         misc_texts.EXIT_CODE,
     })
     return from_simple_description(
         Description(self.single_line_description(),
                     tp.fnap(_DESCRIPTION_REST)))
示例#54
0
def list_syntax_description(
        list_type: NameWithGenderWithFormatting) -> List[ParagraphItem]:
    tp = TextParser({
        'list_type':
        list_type,
        'r_paren':
        formatting.keyword(reserved_words.PAREN_END),
        'line_continuation':
        formatting.keyword(_list_defs.CONTINUATION_TOKEN),
        'end_of_line':
        defs.END_OF_LINE,
    })

    return tp.fnap(_DESCRIPTION)
示例#55
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     tp = TextParser({
         'MATCHER':
         syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT.singular_name,
         'TRANSFORMER':
         syntax_elements.STRING_TRANSFORMER_SYNTAX_ELEMENT.singular_name,
         'MODEL':
         matcher_model.TEXT_MODEL,
     })
     ret_val = tp.fnap(_DESCRIPTION__ON_TRANSFORMED)
     ret_val += texts.type_expression_has_syntax_of_primitive([
         syntax_elements.STRING_TRANSFORMER_SYNTAX_ELEMENT.singular_name,
         syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT.singular_name,
     ])
     return ret_val
class FileInterpreterActorDocumentation(ActorDocumentation):
    def __init__(self):
        super().__init__(FILE_INTERPRETER_ACTOR)
        self._tp = TextParser({
            'shell_syntax_concept':
            formatting.concept_(concepts.SHELL_SYNTAX_CONCEPT_INFO),
            'LINE_COMMENT_MARKER':
            formatting.string_constant(LINE_COMMENT_MARKER),
            'ACT_INTERPRETER':
            formatting.syntax_element(
                syntax_elements.ACT_INTERPRETER_SYNTAX_ELEMENT.singular_name),
        })

    def act_phase_contents(self) -> doc.SectionContents:
        return section_contents(self._tp.fnap(_ACT_PHASE_CONTENTS))

    def act_phase_contents_syntax(self) -> doc.SectionContents:
        documentation = ActPhaseDocumentationSyntax()
        initial_paragraphs = self._tp.fnap(
            SINGLE_LINE_PROGRAM_ACT_PHASE_CONTENTS_SYNTAX_INITIAL_PARAGRAPH)
        sub_sections = []
        synopsis_section = doc_utils.synopsis_section(
            invokation_variants_content(
                None, documentation.invokation_variants(),
                documentation.syntax_element_descriptions()))
        sub_sections.append(synopsis_section)
        return doc.SectionContents(initial_paragraphs, sub_sections)

    def _see_also_specific(self) -> List[SeeAlsoTarget]:
        return [
            syntax_elements.ACT_INTERPRETER_SYNTAX_ELEMENT.
            cross_reference_target,
            syntax_elements.PATH_SYNTAX_ELEMENT.cross_reference_target,
            syntax_elements.PROGRAM_ARGUMENT_SYNTAX_ELEMENT.
            cross_reference_target,
        ]
示例#57
0
    def description_rest(self) -> Sequence[ParagraphItem]:
        matcher_type = self._documentation.names.contents_matcher_syntax_element.singular_name
        tp = TextParser({
            '_file_type_':
            file_properties.TYPE_INFO[
                self._documentation.names.accepted_file_type].name,
            '_matcher_type_':
            matcher_type,
            'HARD_ERROR':
            exit_values.EXECUTION__HARD_ERROR.exit_identifier,
            'MODEL':
            matcher_model.FILE_MATCHER_MODEL,
            'SYMBOLIC_LINKS_ARE_FOLLOWED':
            misc_texts.SYMBOLIC_LINKS_ARE_FOLLOWED,
        })

        ret_val = tp.fnap(_FILE_CONTENTS_MATCHER_HEADER_DESCRIPTION)
        if self._documentation.additional_description is not None:
            ret_val += self._documentation.additional_description()
        ret_val += tp.fnap(MATCHER_FILE_HANDLING_DESCRIPTION)
        ret_val += texts.type_expression_has_syntax_of_primitive(
            [matcher_type])

        return ret_val
class InterpreterActorDocumentation(ActorDocumentation):
    def __init__(self):
        super().__init__(SOURCE_INTERPRETER_ACTOR)
        format_map = {
            'phase': phase_names.PHASE_NAME_DICTIONARY,
            'actor_option': formatting.cli_option(common_cli_options.OPTION_FOR_ACTOR),
            'actor_instruction': formatting.InstructionName(ACTOR_INSTRUCTION_NAME),
            'shell_command': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND),
        }
        self._parser = TextParser(format_map)

    def main_description_rest(self) -> List[ParagraphItem]:
        return self._parser.fnap(_MAIN_DESCRIPTION_REST)

    def act_phase_contents(self) -> SectionContents:
        return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS))

    def act_phase_contents_syntax(self) -> SectionContents:
        return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS_SYNTAX))

    def _see_also_specific(self) -> List[SeeAlsoTarget]:
        return [
            syntax_elements.ACT_INTERPRETER_SYNTAX_ELEMENT.cross_reference_target,
        ]
示例#59
0
class _Documentation(SyntaxElementDocumentation):
    def __init__(self):
        super().__init__(syntax_elements.LIST_SYNTAX_ELEMENT)

        self._tp = TextParser({
            'list_type': types.LIST_TYPE_INFO.name,
            'A_ref_to_symbol_w_string_conversion': types.a_ref_to_a_symbol_w_string_conversion__sentence(),
        })

    def invokation_variants(self) -> List[InvokationVariant]:
        return [
            invokation_variant_from_args(self._cl_arguments())
        ]

    def syntax_element_descriptions(self) -> List[SyntaxElementDescription]:
        return [
            self._symbol_reference_sed(),
        ]

    def main_description_rest_paragraphs(self) -> List[ParagraphItem]:
        return list_syntax_description(types.LIST_TYPE_INFO.name)

    def see_also_targets(self) -> List[SeeAlsoTarget]:
        info_refs = cross_reference_id_list([
            syntax_elements.STRING_SYNTAX_ELEMENT,
            syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT,
            concepts.SYMBOL_CONCEPT_INFO,
            types.LIST_TYPE_INFO,
        ])
        plain_refs = [
            define_symbol.DEFINE_SYMBOL_INSTRUCTION_CROSS_REFERENCE,
        ]
        return info_refs + plain_refs

    def _symbol_reference_sed(self) -> SyntaxElementDescription:
        return SyntaxElementDescription(syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT.argument.name,
                                        self._tp.fnap(_SYMBOL_REFERENCE_DESCRIPTION))

    @staticmethod
    def _cl_arguments() -> List[a.ArgumentUsage]:
        return [
            a.Choice.of_single_argument_choices(
                a.Multiplicity.ZERO_OR_MORE,
                [
                    syntax_elements.STRING_SYNTAX_ELEMENT.argument,
                    syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT.argument,
                ]),
        ]