Ejemplo n.º 1
0
    def get_php_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        cls = self.get_device().get_php_class_name()
        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            if other_packet.get_type() == 'callback':
                name_upper = other_packet.get_upper_case_name()
                name_right = ':php:member:`CALLBACK_{1} <{0}::CALLBACK_{1}>`'.format(cls, name_upper)
            else:
                name = other_packet.get_headless_camel_case_name()
                name_right = ':php:func:`{1}() <{0}::{1}>`'.format(cls, name)
            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return '``${0}``'.format(name)

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = cls + '::'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 2
0
    def get_c_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        constants = {'en': 'defines', 'de': 'Defines'}

        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            if other_packet.get_type() == 'callback':
                name_upper = other_packet.get_upper_case_name()
                pre_upper = self.get_device().get_upper_case_name()
                name_right = ':c:data:`{0}_CALLBACK_{1}`'.format(pre_upper,
                                                                 name_upper)
            else:
                name_right = ':c:func:`{0}_{1}`'.format(self.get_device().get_underscore_name(),
                                                        other_packet.get_underscore_name())
            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_upper_case_name() + '_'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 3
0
    def get_delphi_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_delphi_doc_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = '{0}_{1}_'.format(self.get_device().get_category().upper,
                                   self.get_device().get_name().upper)

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(
                prefix, self.get_device())
        else:
            text += common.format_constants(
                prefix,
                self,
                bool_format_func=lambda value: str(value).lower())

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 4
0
    def get_mathematica_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        text = self.get_device().replace_mathematica_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_mathematica_class_name() + '`'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device()).replace('_', 'U')
        else:
            def constant_format(prefix, constant_group, constant_item, value):
                return '* {0}{1}U{2} = {3}\n'.format(prefix, constant_group.get_upper_case_name().replace('_', 'U'),
                                                     constant_item.get_upper_case_name().replace('_', 'U'), value)

            text += common.format_constants(prefix, self, char_format='``ToCharacterCode["{0}"][[0]]``',
                                            constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
    def get_mathematica_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_mathematica_doc_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_mathematica_class_name() + '`'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device()).replace('_', 'U')
        else:
            def constant_format(prefix, constant_group, constant, value):
                return '* {0}{1}U{2} = {3}\n'.format(prefix, constant_group.get_name().upper.replace('_', 'U'),
                                                     constant.get_name().upper.replace('_', 'U'), value)

            text += common.format_constants(prefix, self, char_format_func='``ToCharacterCode["{0}"][[0]]``'.format,
                                            constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 6
0
    def get_rust_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_rust_doc_function_links(text)

        constants = {'en': 'constants', 'de': 'Konstanten'}

        callback_parameter = {'en': 'received variable', 'de': 'empfangene Variable'}
        callback_parameters = {'en': 'members of the received struct', 'de': 'Felder der empfangenen Struktur'}

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        if self.get_type() == 'callback':
            text = common.handle_rst_word(text, parameter=callback_parameter, parameters=callback_parameters, constants=constants)
        else:
            text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_rust_module_name().upper() + '_'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants, bool_format_func=lambda value: str(value).lower())

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 7
0
    def get_mathematica_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        cls = self.get_device().get_mathematica_class_name()
        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            name = other_packet.get_camel_case_name()
            if other_packet.get_type() == 'callback':
                name_right = ':mathematica:func:`{1} <{0}@{1}>`'.format(cls, name)
            else:
                name_right = ':mathematica:func:`{1}[] <{0}@{1}>`'.format(cls, name)
            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = cls + '`'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device()).replace('_', 'U')
        else:
            def constant_format(prefix, constant_group, constant_item, value):
                return '* {0}{1}U{2} = {3}\n'.format(prefix, constant_group.get_upper_case_name().replace('_', 'U'),
                                                     constant_item.get_upper_case_name().replace('_', 'U'), value)

            text += common.format_constants(prefix, self, char_format='``ToCharacterCode["{0}"][[0]]``',
                                            constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 8
0
    def get_java_formatted_doc(self, shift_right):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_java_doc_function_links(text)

        text = text.replace('Callback ', 'Listener ')
        text = text.replace(' Callback', ' Listener')
        text = text.replace('callback ', 'listener ')
        text = text.replace(' callback', ' listener')

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_java_class_name() + '.'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(
                prefix, self.get_device())
        else:
            text += common.format_constants(
                prefix,
                self,
                bool_format_func=lambda value: str(value).lower())

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, shift_right)
Ejemplo n.º 9
0
    def get_vbnet_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_vbnet_doc_function_links(text)

        # FIXME: add something similar for :char:`c`
        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_vbnet_class_name() + '.'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(
                prefix, self.get_device())
        else:
            text += common.format_constants(prefix,
                                            self,
                                            char_format_func='"{0}"C'.format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 10
0
    def get_vbnet_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        cls = self.get_device().get_vbnet_class_name()
        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            name = other_packet.get_camel_case_name()
            if other_packet.get_type() == 'callback':
                name_right = ':vbnet:func:`{1} <{0}.{1}>`'.format(cls, name)
            else:
                name_right = ':vbnet:func:`{1}() <{0}.{1}>`'.format(cls, name)
            text = text.replace(name_false, name_right)

        # FIXME: add something similar for :char:`c`
        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = cls + '.'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self, char_format='"{0}"C')

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 11
0
    def get_tcpip_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        constants = {'en': 'meanings', 'de': 'Bedeutungen'}
        constants_intro = {
            'en':
            """
The following {0} are defined for the parameters of this function:

""",
            'de':
            """
Die folgenden {0} sind für die Parameter dieser Funktion definiert:

"""
        }
        parameter = {'en': 'response value', 'de': 'Rückgabewert'}
        parameters = {'en': 'response values', 'de': 'Rückgabewerte'}

        text = self.get_device().specialize_tcpip_doc_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, parameter, parameters)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant, value):
            c = '* {0}: {1}, '.format(value, constant.get_name().lower)

            for_ = {'en': 'for', 'de': 'für'}

            c += common.select_lang(for_) + ' '

            e = []

            for element in constant_group.get_elements():
                name = element.get_name().under
                e.append(name)

            if len(e) > 1:
                and_ = {'en': 'and', 'de': 'und'}

                c += ', '.join(
                    e[:-1]) + ' ' + common.select_lang(and_) + ' ' + e[-1]
            else:
                c += e[0]

            return c + '\n'

        text += common.format_constants('',
                                        self,
                                        constants_name=constants,
                                        char_format='{0}',
                                        constant_format_func=constant_format,
                                        constants_intro=constants_intro)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 12
0
    def get_rust_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_rust_doc_function_links(text)

        constants = {'en': 'constants', 'de': 'Konstanten'}

        callback_parameter = {'en': 'received variable', 'de': 'empfangene Variable'}
        callback_parameters = {'en': 'members of the received struct', 'de': 'Felder der empfangenen Struktur'}

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        if self.get_type() == 'callback':
            text = common.handle_rst_word(text, parameter=callback_parameter, parameters=callback_parameters, constants=constants)            
        else:
            text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_name().upper + '_' + self.get_device().get_category().upper + '_'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants, bool_format_func=lambda value: str(value).lower())

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 13
0
    def get_delphi_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        cls = self.get_device().get_delphi_class_name()
        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            name = other_packet.get_camel_case_name()
            if other_packet.get_type() == 'callback':
                name_right = ':delphi:func:`On{1} <{0}.On{1}>`'.format(cls, name)
            else:
                name_right = ':delphi:func:`{1} <{0}.{1}>`'.format(cls, name)
            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = '{0}_{1}_'.format(self.get_device().get_category().upper(),
                                   self.get_device().get_upper_case_name())
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 14
0
    def get_csharp_formatted_doc(self, shift_right):
        text = common.select_lang(self.get_doc()[1])
        link = ':csharp:func:`{1}() <{0}::{1}>`'
        link_c = ':csharp:func:`{1} <{0}::{1}>`'

        cls = self.get_device().get_csharp_class_name()
        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            name = other_packet.get_camel_case_name()
            if other_packet.get_type() == 'callback':
                name_right = link_c.format(cls, name)
            else:
                name_right = link.format(cls, name)

            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = cls + '.'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, shift_right)
Ejemplo n.º 15
0
    def get_java_formatted_doc(self, shift_right):
        text = common.select_lang(self.get_doc()[1])

        text = self.get_device().replace_java_function_links(text)

        text = text.replace('Callback ', 'Listener ')
        text = text.replace(' Callback', ' Listener')
        text = text.replace('callback ', 'listener ')
        text = text.replace(' callback', ' listener')

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_java_class_name() + '.'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(
                prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, shift_right)
Ejemplo n.º 16
0
    def get_java_formatted_doc(self, shift_right):
        text = common.select_lang(self.get_doc()[1])

        text = self.get_device().replace_java_function_links(text)

        text = text.replace('Callback ', 'Listener ')
        text = text.replace(' Callback', ' Listener')
        text = text.replace('callback ', 'listener ')
        text = text.replace(' callback', ' listener')

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_java_class_name() + '.'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, shift_right)
Ejemplo n.º 17
0
    def get_shell_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        device_name = self.get_device().get_shell_device_name()
        constants = {'en': 'symbols', 'de': 'Symbole'}

        for other_packet in self.get_device().get_packets():
            name_false = ':func:`{0}`'.format(other_packet.get_camel_case_name())
            name_right = ':sh:func:`{1} <{0} {1}>`'.format(device_name, other_packet.get_dash_name())
            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant_item, value):
            c = '* ``{0}`` = {1}, '.format(constant_item.get_dash_name(), value)

            for_ = {
            'en': 'for',
            'de': 'für'
            }

            c += common.select_lang(for_) + ' '

            e = []
            for element in constant_group.get_elements():
                name = element.get_dash_name()
                if element.get_direction() == 'in':
                    e.append('<{0}>'.format(name))
                else:
                    e.append(name)

            if len(e) > 1:
                and_ = {
                'en': 'and',
                'de': 'und'
                }

                c += ', '.join(e[:-1]) + ' ' + common.select_lang(and_) + ' ' + e[-1]
            else:
                c += e[0]

            return c + '\n'

        text += common.format_constants('', self, constants_name=constants,
                                        char_format='{0}',
                                        constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 18
0
    def get_mqtt_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_mqtt_doc_function_links(text)

        constants = {'en': 'symbols', 'de': 'Symbole'}

        callback_parameter = {'en': 'callback payload', 'de': 'Payload des Callbacks'}
        callback_parameters = {'en': 'callback payload members', 'de': 'Payload-Member des Callbacks'}

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        if self.get_type() == 'callback':
            text = common.handle_rst_word(text, parameter=callback_parameter, parameters=callback_parameters, constants=constants)            
        else:
            text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = ''

        const_fmt_func = lambda prefix, constant_group, constant, value: '* "{0}" = {1}\n'.format(
                                                                constant.get_name().camel, value)
        const_func_id_fmt_func = lambda prefix, func_name, value: '* {0}Function{1} = {2}\n'.format(
                                                                  prefix, func_name.camel, value)


        def constant_group_func(group):
            splt = group.get_name().under.split('_')

            found = None

            for elem in group.get_elements():
                if elem.get_packet().get_name().under == self.get_name().under:
                    return elem.get_name().under
                #to_search = []
                #for word in reversed(splt):
                #    to_search.append(word)
                #    if elem.get_name().under == '_'.join(to_search):
                #        return elem.get_name().under
            return group.get_name().under

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants, constant_format_func=const_func_id_fmt_func)
        else:
            _for = common.select_lang({'en': 'for', 'de': 'für'})
            text += common.format_constants(prefix, self, constants, constant_format_func=const_fmt_func, show_constant_group=True, group_format_func=lambda g: "\n" + _for + " " + constant_group_func(g) + ":\n\n")

        text += common.format_since_firmware(self.get_device(), self)

        text = text.replace('|device_identifier_constant|\n', '')

        return common.shift_right(text, 1)
Ejemplo n.º 19
0
    def get_shell_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_shell_doc_function_links(text)

        constants = {'en': 'symbols', 'de': 'Symbole'}

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant, value):
            c = '* ``{0}-{1}`` = {2}, '.format(constant_group.get_name().dash,
                                               constant.get_name().dash, value)

            for_ = {'en': 'for', 'de': 'für'}

            c += common.select_lang(for_) + ' '

            e = []

            for element in constant_group.get_elements(self):
                name = element.get_name().dash
                if element.get_direction() == 'in':
                    e.append('<{0}>'.format(name))
                else:
                    e.append(name)

            if len(e) > 1:
                and_ = {'en': 'and', 'de': 'und'}

                c += ', '.join(
                    e[:-1]) + ' ' + common.select_lang(and_) + ' ' + e[-1]
            else:
                c += e[0]

            return c + '\n'

        text += common.format_constants(
            '',
            self,
            constants_name=constants,
            char_format_func=str,
            bool_format_func=lambda value: str(value).lower(),
            constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 20
0
    def get_go_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_go_doc_function_links(text)

        constants = {'en': 'constants', 'de': 'Konstanten'}

        callback_parameter = {
            'en': 'callback parameter',
            'de': 'Parameter des Callbacks'
        }
        callback_parameters = {
            'en': 'callback parameters',
            'de': 'Parameter des Callbacks'
        }

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        if self.get_type() == 'callback':
            text = common.handle_rst_word(text,
                                          parameter=callback_parameter,
                                          parameters=callback_parameters,
                                          constants=constants)
        else:
            text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = ''

        const_fmt_func = lambda prefix, constant_group, constant, value: '* {0}{1}{2} = {3}\n'.format(
            prefix,
            constant_group.get_name().camel,
            constant.get_name().camel, value)
        const_func_id_fmt_func = lambda prefix, func_name, value: '* {0}Function{1} = {2}\n'.format(
            prefix, func_name.camel, value)

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(
                prefix,
                self.get_device(),
                constants,
                constant_format_func=const_func_id_fmt_func)
        else:
            text += common.format_constants(
                prefix, self, constants, constant_format_func=const_fmt_func)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 21
0
    def get_tvpl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        constants = {'en': 'symbols', 'de': 'Symbole'}

        text = self.get_device().replace_tvpl_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant, value):
            c = '* {0} = {1}, '.format(constant.get_name().space, value)

            for_ = {
                'en': 'for',
                'de': 'für'
            }

            c += common.select_lang(for_) + ' '

            e = []

            for element in constant_group.get_elements():
                e.append(element.get_name().space)

            if len(e) > 1:
                and_ = {
                    'en': 'and',
                    'de': 'und'
                }

                c += ', '.join(e[:-1]) + ' ' + common.select_lang(and_) + ' ' + e[-1]
            else:
                c += e[0]

            return c + '\n'

        text += common.format_constants('', self, constants_name=constants,
                                        char_format_func=str,
                                        bool_format_func=lambda value: str(value).lower(),
                                        constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 22
0
    def get_tvpl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        constants = {'en': 'symbols', 'de': 'Symbole'}

        text = self.get_device().replace_tvpl_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant, value):
            c = '* {0} = {1}, '.format(constant.get_name().space, value)

            for_ = {
                'en': 'for',
                'de': 'für'
            }

            c += common.select_lang(for_) + ' '

            e = []

            for element in constant_group.get_elements():
                e.append(element.get_name().space)

            if len(e) > 1:
                and_ = {
                    'en': 'and',
                    'de': 'und'
                }

                c += ', '.join(e[:-1]) + ' ' + common.select_lang(and_) + ' ' + e[-1]
            else:
                c += e[0]

            return c + '\n'

        text += common.format_constants('', self, constants_name=constants,
                                        char_format='{0}',
                                        constant_format_func=constant_format)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 23
0
    def get_shell_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_shell_doc_function_links(text)

        constants = {"en": "symbols", "de": "Symbole"}

        def format_parameter(name):
            return "``{0}``".format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant, value):
            c = "* ``{0}`` = {1}, ".format(constant.get_dash_name(), value)

            for_ = {"en": "for", "de": "für"}

            c += common.select_lang(for_) + " "

            e = []
            for element in constant_group.get_elements():
                name = element.get_dash_name()
                if element.get_direction() == "in":
                    e.append("<{0}>".format(name))
                else:
                    e.append(name)

            if len(e) > 1:
                and_ = {"en": "and", "de": "und"}

                c += ", ".join(e[:-1]) + " " + common.select_lang(and_) + " " + e[-1]
            else:
                c += e[0]

            return c + "\n"

        text += common.format_constants(
            "", self, constants_name=constants, char_format="{0}", constant_format_func=constant_format
        )

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 24
0
    def get_javascript_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_javascript_doc_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_javascript_class_name() + '.'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 25
0
    def get_delphi_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_delphi_doc_function_links(text)

        def format_parameter(name):
            return "``{0}``".format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = "{0}_{1}_".format(self.get_device().get_upper_case_category(), self.get_device().get_upper_case_name())
        if self.get_underscore_name() == "set_response_expected":
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 26
0
    def get_perl_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        text = self.get_device().replace_perl_function_links(text)

        def format_parameter(name):
            return "``{0}``".format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_perl_class_name() + "->"
        if self.get_underscore_name() == "set_response_expected":
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 27
0
    def get_perl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        text = self.get_device().replace_perl_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_perl_class_name() + '->'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 28
0
    def get_perl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_perl_doc_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_perl_class_name() + '->'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self, bool_format_func=lambda value: str(int(value)))

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 29
0
    def get_c_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        constants = {'en': 'defines', 'de': 'Defines'}

        text = self.get_device().replace_c_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_upper_case_name() + '_'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 30
0
    def get_go_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        constants = {'en': 'defines', 'de': 'Defines'}

        text = self.get_device().replace_c_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_upper_case_name() + '_'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 31
0
    def get_vbnet_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        text = self.get_device().replace_vbnet_function_links(text)

        # FIXME: add something similar for :char:`c`
        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_vbnet_class_name() + '.'
        if self.get_underscore_name() == 'set_response_expected':
            text += common.format_function_id_constants(prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self, char_format='"{0}"C')

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 32
0
    def get_php_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_php_doc_function_links(text)

        def format_parameter(name):
            return '``${0}``'.format(name)

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_php_class_name() + '::'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(
                prefix, self.get_device())
        else:
            text += common.format_constants(prefix, self)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 33
0
    def get_c_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_c_doc_function_links(text)

        constants = {'en': 'defines', 'de': 'Defines'}

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_name().upper + '_'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants, bool_format_func=lambda value: str(value).lower())

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 34
0
    def get_c_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_c_doc_function_links(text)

        constants = {'en': 'defines', 'de': 'Defines'}

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = self.get_device().get_name().upper + '_'

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(prefix, self.get_device(), constants)
        else:
            text += common.format_constants(prefix, self, constants, bool_format_func=lambda value: str(value).lower())

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 35
0
    def get_tcpip_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        constants = {'en': 'meanings', 'de': 'Bedeutungen'}
        constants_intro = {
        'en': """
The following {0} are defined for the parameters of this function:

""",
        'de': """
Die folgenden {0} sind für die Parameter dieser Funktion definiert:

"""
        }
        parameter = {
        'en': 'response value',
        'de': 'Rückgabewert'
        }
        parameters = {
        'en': 'response values',
        'de': 'Rückgabewerte'
        }

        text = self.get_device().specialize_tcpip_doc_function_links(text)

        def format_parameter(name):
            return '``{0}``'.format(name) # FIXME

        text = common.handle_rst_param(text, format_parameter)
        text = common.handle_rst_word(text, parameter, parameters)
        text = common.handle_rst_substitutions(text, self)

        def constant_format(prefix, constant_group, constant, value):
            c = '* {0}: {1}, '.format(value, constant.get_name().lower())

            for_ = {
            'en': 'for',
            'de': 'für'
            }

            c += common.select_lang(for_) + ' '

            e = []
            for element in constant_group.get_elements():
                name = element.get_underscore_name()
                e.append(name)

            if len(e) > 1:
                and_ = {
                'en': 'and',
                'de': 'und'
                }

                c += ', '.join(e[:-1]) + ' ' + common.select_lang(and_) + ' ' + e[-1]
            else:
                c += e[0]

            return c + '\n'

        text += common.format_constants('', self, constants_name=constants,
                                        char_format='{0}',
                                        constant_format_func=constant_format,
                                        constants_intro=constants_intro)

        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
Ejemplo n.º 36
0
    def get_mqtt_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_mqtt_doc_function_links(text)

        constants = {'en': 'symbols', 'de': 'Symbole'}

        callback_parameter = {
            'en': 'callback payload',
            'de': 'Payload des Callbacks'
        }
        callback_parameters = {
            'en': 'callback payload members',
            'de': 'Payload-Member des Callbacks'
        }

        def format_parameter(name):
            return '``{0}``'.format(name)  # FIXME

        text = common.handle_rst_param(text, format_parameter)
        if self.get_type() == 'callback':
            text = common.handle_rst_word(text,
                                          parameter=callback_parameter,
                                          parameters=callback_parameters,
                                          constants=constants)
        else:
            text = common.handle_rst_word(text, constants=constants)
        text = common.handle_rst_substitutions(text, self)

        prefix = ''

        const_fmt_func = lambda prefix, constant_group, constant, value: '* "{0}" = {1}\n'.format(
            constant.get_name().camel, value)
        const_func_id_fmt_func = lambda prefix, func_name, value: '* {0}Function{1} = {2}\n'.format(
            prefix, func_name.camel, value)

        def constant_group_func(group):
            splt = group.get_name().under.split('_')

            found = None

            for elem in group.get_elements(self):
                if elem.get_packet().get_name().under == self.get_name().under:
                    return elem.get_name().under

            return group.get_name().under

        if self.get_name().space == 'Set Response Expected':
            text += common.format_function_id_constants(
                prefix,
                self.get_device(),
                constants,
                constant_format_func=const_func_id_fmt_func)
        else:
            _for = common.select_lang({'en': 'for', 'de': 'für'})
            text += common.format_constants(
                prefix,
                self,
                constants,
                constant_format_func=const_fmt_func,
                show_constant_group=True,
                group_format_func=lambda g: "\n" + _for + " " +
                constant_group_func(g) + ":\n\n")

        text += common.format_since_firmware(self.get_device(), self)
        text = text.replace('|device_identifier_constant|\n', '')

        return common.shift_right(text, 1)