Exemple #1
0
class _HdsConcept(ConceptDocumentation):
    def __init__(self):
        super().__init__(concepts.HDS_CONCEPT_INFO)

        self._tp = TextParser({
            'HDS':
            concepts.HDS_CONCEPT_INFO.acronym,
            'hds_concept':
            formatting.concept_(concepts.HDS_CONCEPT_INFO),
            'phase':
            phase_names.PHASE_NAME_DICTIONARY,
            'program_name':
            formatting.program_name(program_info.PROGRAM_NAME),
            'symbol':
            formatting.concept_(concepts.SYMBOL_CONCEPT_INFO),
            'symbols':
            formatting.concept(concepts.SYMBOL_CONCEPT_INFO.plural_name),
            'conf_params':
            formatting.concept(
                concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.plural_name),
            'PATH':
            syntax_elements.PATH_SYNTAX_ELEMENT.singular_name,
            'Note':
            headers.NOTE_LINE_HEADER,
        })

    def purpose(self) -> DescriptionWithSubSections:
        sub_sections = [
            self._tp.section(
                concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.plural_name.
                capitalize(), _CONFIGURATION_PARAMETER),
            self._tp.section('Relative paths', _RELATIVITY),
            self._tp.section(
                self._tp.format(
                    BUILTIN_SYMBOL_ENTITY_TYPE_NAMES.name.plural.capitalize()),
                _BUILTIN_SYMBOL),
            docs.section('Directories', self._directory_listing()),
        ]
        return DescriptionWithSubSections(
            self.single_line_description(),
            SectionContents(self._tp.fnap(_MAIN_DESCRIPTION_REST),
                            sub_sections))

    def see_also_targets(self) -> List[SeeAlsoTarget]:
        ret_val = [
            concepts.TCDS_CONCEPT_INFO.cross_reference_target,
            concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.
            cross_reference_target,
            concepts.SYMBOL_CONCEPT_INFO.cross_reference_target,
            types.PATH_TYPE_INFO.cross_reference_target,
        ]
        ret_val += [
            dir_info.conf_param.cross_reference_target
            for dir_info in _ALL_DIRECTORIES
        ]
        ret_val += [
            phase_infos.CONFIGURATION.instruction_cross_reference_target(
                dir_info.instruction_name) for dir_info in _ALL_DIRECTORIES
        ]
        return ret_val

    def _directory_listing(self) -> List[docs.ParagraphItem]:
        items = [self._dir_item(d) for d in _ALL_DIRECTORIES]
        return [docs.simple_list(items, lists.ListType.VARIABLE_LIST)]

    def _dir_item(self, x: _DirInfo) -> HeaderContentListItem:
        def prop_row(header: str, value_str_or_text) -> List[docs.TableCell]:
            return [
                docs.text_cell(header),
                docs.text_cell(value_str_or_text),
            ]

        from exactly_lib.tcfs.relative_path_options import REL_HDS_OPTIONS_MAP
        properties_table = docs.first_column_is_header_table([
            prop_row('Default value', x.default_value_description),
            prop_row(
                concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.singular_name.
                capitalize(), x.conf_param.configuration_parameter_name_text),
            prop_row('Set by instruction',
                     instruction_name_text(x.instruction_name)),
            prop_row(
                BUILTIN_SYMBOL_ENTITY_TYPE_NAMES.name.singular.capitalize(),
                REL_HDS_OPTIONS_MAP[
                    x.relativity_option_type].directory_symbol_name_text),
            prop_row(
                'Path relativity option', REL_HDS_OPTIONS_MAP[
                    x.relativity_option_type].option_name_text),
        ])

        paras = [
            docs.para(x.conf_param.single_line_description_str),
            properties_table,
        ]
        return docs.list_item(self._tp.text(x.item_name), paras)
Exemple #2
0
class _Documentation(SyntaxElementDocumentation):
    def __init__(self):
        super().__init__(syntax_elements.STRING_SYNTAX_ELEMENT)
        the_string_type = 'the ' + types.STRING_TYPE_INFO.singular_name
        non_str_types_w_str_conversion = value_type.sorted_types(
            set(value_type.VALUE_TYPES_W_STR_RENDERING) -
            {value_type.ValueType.STRING})
        self._tp = TextParser({
            'symbol':
            concepts.SYMBOL_CONCEPT_INFO.name,
            'symbol_reference':
            syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT.singular_name,
            'type':
            concepts.TYPE_CONCEPT_INFO.name,
            'string_type':
            types.STRING_TYPE_INFO.name,
            'string_type_plain':
            types.STRING_TYPE_INFO.name,
            'list_type':
            types.LIST_TYPE_INFO.name,
            'path_type':
            types.PATH_TYPE_INFO.name,
            'A_ref_to_symbol_w_string_conversion':
            types.a_ref_to_a_symbol_w_string_conversion__sentence(),
            'non_str_types_w_str_rendering':
            types.types__and_list(non_str_types_w_str_conversion),
            'soft_quote':
            syntax_descriptions.SOFT_QUOTE_NAME,
            'hard_quote':
            syntax_descriptions.HARD_QUOTE_NAME,
            'SOFT_Q':
            token.SOFT_QUOTE_CHAR,
            'HARD_Q':
            token.HARD_QUOTE_CHAR,
            'CHR':
            'CHARACTER',
            'whitespace':
            misc_texts.WHITESPACE,
            'reserved_word':
            misc_texts.RESERVED_WORD_NAME,
            'reserved_word_list_str':
            ', '.join([
                formatting.keyword(x) for x in reserved_words.RESERVED_TOKENS
            ]),
            'Sym_refs_are_substituted':
            syntax_descriptions.symbols_are_substituted_in(the_string_type),
            'Sym_refs_are_not_substituted':
            syntax_descriptions.symbols_are_not_substituted_in(
                the_string_type),
            'REL_CD_OPTION':
            path.REL_CWD_OPTION,
        })

    def invokation_variants(self) -> List[InvokationVariant]:
        return [
            InvokationVariant(self._tp.format('{CHR}...'),
                              self._tp.fnap(_DESCRIPTION_OF_NAKED)),
            InvokationVariant(self._tp.format('{SOFT_Q}{CHR}...{SOFT_Q}'),
                              self._tp.fnap(_DESCRIPTION_OF_SOFT_Q)),
            InvokationVariant(self._tp.format('{HARD_Q}{CHR}...{HARD_Q}'),
                              self._tp.fnap(_DESCRIPTION_OF_HARD_Q)),
        ]

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

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

    def main_description_rest_sub_sections(self) -> List[SectionItem]:
        return [
            self._tp.section(
                'Concatenation',
                _DESCRIPTION__CONCATENATION,
            ),
            self._tp.section(
                misc_texts.RESERVED_WORD_NAME.plural.capitalize(),
                _RESERVED_WORDS_DESCRIPTION,
            ),
            self._tp.section(
                'Conversion of {non_str_types_w_str_rendering}',
                _DESCRIPTION__TYPE_CONVERSION,
            ),
        ]

    def see_also_targets(self) -> List[SeeAlsoTarget]:
        info_refs = cross_reference_id_list([
            syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT,
            types.STRING_TYPE_INFO,
            types.LIST_TYPE_INFO,
            types.PATH_TYPE_INFO,
            concepts.SYMBOL_CONCEPT_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,
            ]),
        ]