예제 #1
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)
예제 #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)
예제 #3
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)
예제 #4
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)
    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)
예제 #6
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)
    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)
예제 #8
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)
    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)
예제 #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)
예제 #11
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)
예제 #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_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)
예제 #13
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)
예제 #14
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)
예제 #15
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)
예제 #16
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)
예제 #17
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)
예제 #18
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)
예제 #19
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)
예제 #20
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)
예제 #21
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)
예제 #22
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)
예제 #23
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)
예제 #24
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)
예제 #25
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)
    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)
예제 #27
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)
예제 #28
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)
예제 #29
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)