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)
    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)
    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)
    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)
    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_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)
    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)
Exemple #8
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)
    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_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)
    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_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)
Exemple #13
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)
    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)
    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)
    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)
Exemple #17
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)
Exemple #18
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)
Exemple #19
0
    def get_go_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle links
        text = text.replace(":ref:", "")
        text = re.sub("`([^<]+) <([^>]+)>`__", r"\g<2>", text)

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False
        col_count = 0

        for line in lines:
            line = line.replace('"', '')

            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                line = line[len(':header: '):]
                col_count = line.count(",") + 1
                line = line.replace(",", "|")
                replaced_lines.append(line)
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append("|".join([" --- "] * col_count))
            elif in_table_head:
                replaced_lines.append(line.replace(",", "|"))
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            elif in_table_body:
                replaced_lines.append(line.replace(",", "|"))
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text = self.get_device().specialize_go_doc_function_links(text)

        text = text.replace('.. note::', 'Note')
        text = text.replace('.. warning::', 'Warning')

        def format_parameter(name):
            return '\\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        return '// ' + '\n// '.join(text.strip().split('\n'))
Exemple #20
0
    def get_go_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle links      
        text = text.replace(":ref:", "")       

        text = re.sub("`([^<]+) <([^>]+)>`__", r"\g<2>", text)


        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False
        col_count = 0
        for line in lines:  
            line = line.replace('"', '')          
            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                line = line[len(':header: '):]
                col_count = line.count(",") + 1
                line = line.replace(",", "|")
                replaced_lines.append(line)
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append("|".join([" --- "] * col_count))
            elif in_table_head:
                replaced_lines.append(line.replace(",", "|"))
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            elif in_table_body:
                replaced_lines.append(line.replace(",", "|"))
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text = self.get_device().specialize_go_doc_function_links(text)

        text = text.replace('.. note::', 'Note')
        text = text.replace('.. warning::', 'Warning')

        def format_parameter(name):
            return '\\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        return '// ' + '\n\t// '.join(text.strip().split('\n'))
    def get_ruby_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        link = '{0}#{1}'
        link_c = 'CALLBACK_{0}'

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)

        cls = self.get_device().get_ruby_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 = other_packet.get_upper_case_name()
                name_right = link_c.format(name)
            else:
                name = other_packet.get_underscore_name()
                name_right = link.format(cls, name)

            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return name  # FIXME

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

        return '\n    # '.join(text.strip().split('\n'))
    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)
Exemple #23
0
    def get_perl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        def format_parameter(name):
            return name # FIXME

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

        return text.strip()
    def get_javascript_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        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)
        text += common.format_since_firmware(self.get_device(), self)

        return "\n\t\t".join(text.strip().split("\n"))
Exemple #25
0
    def get_javascript_formatted_doc(self):
        text = common.select_lang(self.get_doc_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)
        text += common.format_since_firmware(self.get_device(), self)

        return '\n\t\t'.join(text.strip().split('\n'))
    def get_ruby_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        link = '{0}#{1}'
        link_c = 'CALLBACK_{0}'

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)

        cls = self.get_device().get_ruby_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 = other_packet.get_upper_case_name()
                name_right = link_c.format(name)
            else:
                name = other_packet.get_underscore_name()
                name_right = link.format(cls, name)

            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return name # FIXME

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

        return '\n    # '.join(text.strip().split('\n'))
    def get_python_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

        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)
        text += common.format_since_firmware(self.get_device(), self)

        return '\n        '.join(text.strip().split('\n'))
Exemple #28
0
    def get_java_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('\\verbatim')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('\\endverbatim')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        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')
        text = text.replace('.. note::', '\\note')
        text = text.replace('.. warning::', '\\warning')

        def format_parameter(name):
            return '\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        # escape HTML special chars
        text = escape(text)

        return '\n\t * '.join(text.strip().split('\n'))
Exemple #29
0
    def get_c_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('\\verbatim')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('\\endverbatim')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text = self.get_device().specialize_c_doc_function_links(text)

        if self.get_type() == 'callback':
            plist = self.get_c_parameter_list()[2:].replace('*ret_', '')
            if len(plist) > 0:
                plist += ', '
            text = 'Signature: \code void callback({0}void *user_data) \endcode\n'.format(plist) + text

        text = text.replace('.. note::', '\\note')
        text = text.replace('.. warning::', '\\warning')

        def format_parameter(name):
            return '\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        return '\n * '.join(text.strip().split('\n'))
Exemple #30
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)
    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)
    def get_tcpip_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        parameter = {'en': 'response value', 'de': 'Rückgabewert'}
        parameters = {'en': 'response values', 'de': 'Rückgabewerte'}

        text = self.get_device().replace_tcpip_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)
        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
    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)
    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)
Exemple #35
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)
    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)
Exemple #37
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)
Exemple #38
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)
    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)
    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)
Exemple #41
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)
    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_tcpip_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        parameter = {
        'en': 'response value',
        'de': 'Rückgabewert'
        }
        parameters = {
        'en': 'response values',
        'de': 'Rückgabewerte'
        }

        text = self.get_device().replace_tcpip_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)
        text += common.format_since_firmware(self.get_device(), self)

        return common.shift_right(text, 1)
    def get_ruby_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text = self.get_device().specialize_ruby_doc_function_links(text)

        def format_parameter(name):
            return name # FIXME

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

        return '\n    # '.join(text.strip().split('\n'))
    def get_ruby_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text = self.get_device().specialize_ruby_doc_function_links(text)

        def format_parameter(name):
            return name  # FIXME

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

        return '\n    # '.join(text.strip().split('\n'))
    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)
    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)
    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)
Exemple #49
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)
Exemple #50
0
    def get_c_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        link = '{{@link {0}_{1}}}'
        link_c = '{{@link {0}_CALLBACK_{1}}}'

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('\\verbatim')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('\\endverbatim')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)

        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 = other_packet.get_upper_case_name()
                name_right = link_c.format(self.get_device().get_upper_case_name(), name)
            else:
                name = other_packet.get_underscore_name()
                name_right = link.format(self.get_device().get_underscore_name(), name)

            text = text.replace(name_false, name_right)

        if self.get_type() == 'callback':
            plist = self.get_c_parameter_list()[2:].replace('*ret_', '')
            if len(plist) > 0:
                plist += ', '
            text = 'Signature: \code void callback({0}void *user_data) \endcode\n'.format(plist) + text

        text = text.replace('.. note::', '\\note')
        text = text.replace('.. warning::', '\\warning')

        def format_parameter(name):
            return '\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        return '\n * '.join(text.strip().split('\n'))
Exemple #51
0
    def get_rust_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # handle links
        text = text.replace(":ref:", "")
        #text = text.replace(":func:", "")
        #if ":ref:" in text:
        #substitutions = {
        #    "device_identifier": "https://www.tinkerforge.com/en/doc/Software/Device_Identifier.html",
        #    "tutorial_authentication": "https://www.tinkerforge.com/en/doc/Tutorials/Tutorial_Authentication/Tutorial.html",
        #    "gps_bricklet_fix_led": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/GPS.html#fix-led",
        #    "gps_v2_bricklet_fix_led": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/GPS_V2.html#fix-led",
        #    "led_strip_bricklet_ram_constraints": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/LED_Strip.html#ram-constraints",
        #}
        #for match in  re.finditer(":ref:`([^<]+) <([^>]+)>`", text):
        #    link_text, url = match.groups()
        #    subst = substitutions[url]
        #    re.sub("`("+link_text+") <"+url+">`", "[\g<1>]("+subst+")", text)

        text = re.sub("`([^<]+) <([^>]+)>`", r"[\g<1>](\g<2>)", text)

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False
        col_count = 0
        for line in lines:
            line = line.replace('"', '')
            if line.strip() == '.. csv-table::':
                in_table_head = True
            elif line.strip().startswith(':header: ') and in_table_head:
                line = line[len(':header: '):]
                col_count = line.count(",") + 1
                line = line.replace(",", "|")
                replaced_lines.append(line)
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append("|".join([" --- "] * col_count))
            elif in_table_head:
                replaced_lines.append(line.replace(",", "|"))
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False
                replaced_lines.append('')
            elif in_table_body:
                replaced_lines.append(line.replace(",", "|"))
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text, links = self.get_device().specialize_rust_doc_function_links(
            text)
        text += '\n' + '\n'.join(links)

        text = text.replace('Callback ', 'Receiver ')
        text = text.replace(' Callback', ' Receiver')
        text = text.replace('callback ', 'receiver ')
        text = text.replace(' callback', ' receiver')
        text = text.replace('.. note::', '# Note')
        text = text.replace('.. warning::', '# Warning')

        def format_parameter(name):
            return '\\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        return '/// ' + '\n\t/// '.join(text.strip().split('\n'))
Exemple #52
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)
Exemple #53
0
    def get_java_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        link = '{{@link {0}#{1}({2})}}'
        link_c = '{{@link {0}.{1}Listener}}'

        # handle tables
        lines = text.split('\n')
        replaced_lines = []
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('\\verbatim')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('\\endverbatim')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)

        cls = self.get_device().get_java_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 = other_packet.get_camel_case_name()
                name_right = link_c.format(cls, name)
            else:
                name = other_packet.get_headless_camel_case_name()
                name_right = link.format(
                    cls, name,
                    other_packet.get_java_parameter_list(just_types=True))

            text = text.replace(name_false, name_right)

        text = text.replace('Callback ', 'Listener ')
        text = text.replace(' Callback', ' Listener')
        text = text.replace('callback ', 'listener ')
        text = text.replace(' callback', ' listener')
        text = text.replace('.. note::', '\\note')
        text = text.replace('.. warning::', '\\warning')

        def format_parameter(name):
            return '\c {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)
        text += common.format_since_firmware(self.get_device(), self)

        # escape HTML special chars
        text = escape(text)

        return '\n\t * '.join(text.strip().split('\n'))
Exemple #54
0
    def get_php_formatted_doc(self, suffix):
        text = common.select_lang(self.get_doc()[1])
        link = '{0}::{1}()'
        link_c = '{0}::CALLBACK_{1}'

        # handle notes and warnings
        lines = text.split('\n')
        replaced_lines = []
        in_note = False
        in_warning = False
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. note::':
                in_note = True
                replaced_lines.append('<note>')
            elif line.strip() == '.. warning::':
                in_warning = True
                replaced_lines.append('<warning>')
            elif len(line.strip()) == 0 and in_note:
                in_note = False
                replaced_lines.append('</note>')
                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_warning:
                in_warning = False
                replaced_lines.append('</warning>')
                replaced_lines.append('')
            elif line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('<code>')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('</code>')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)

        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 = other_packet.get_upper_case_name()
                name_right = link_c.format(cls, name)
            else:
                name = other_packet.get_headless_camel_case_name()
                name_right = link.format(cls, name)

            text = text.replace(name_false, name_right)

        text = text.replace('.. note::', '\\note')
        text = text.replace('.. warning::', '\\warning')

        def format_parameter(name):
            return name  # FIXME

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

        return '\n     * '.join(text.strip().split('\n') + suffix)
    def get_csharp_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())

        # escape XML special chars
        text = escape(text)

        # handle notes and warnings
        lines = text.split('\n')
        replaced_lines = []
        in_note = False
        in_warning = False
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. note::':
                in_note = True
                replaced_lines.append('<note>')
            elif line.strip() == '.. warning::':
                in_warning = True
                replaced_lines.append('<note type="caution">')
            elif len(line.strip()) == 0 and (in_note or in_warning):
                if in_note:
                    in_note = False
                if in_warning:
                    in_warning = False

                replaced_lines.append('</note>')
                replaced_lines.append('')
            elif line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('<code>')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('</code>')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)
        text = self.get_device().specialize_csharp_doc_function_links(text)

        def format_parameter(name):
            return name  # FIXME

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

        return '\n\t\t///  '.join(text.strip().split('\n'))
Exemple #56
0
    def get_csharp_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        link = '<see cref="Tinkerforge.{0}.{1}"/>'

        # escape XML special chars
        text = escape(text)

        # handle notes and warnings
        lines = text.split('\n')
        replaced_lines = []
        in_note = False
        in_warning = False
        in_table_head = False
        in_table_body = False

        for line in lines:
            if line.strip() == '.. note::':
                in_note = True
                replaced_lines.append('<note>')
            elif line.strip() == '.. warning::':
                in_warning = True
                replaced_lines.append('<note type="caution">')
            elif len(line.strip()) == 0 and (in_note or in_warning):
                if in_note:
                    in_note = False
                if in_warning:
                    in_warning = False

                replaced_lines.append('</note>')
                replaced_lines.append('')
            elif line.strip() == '.. csv-table::':
                in_table_head = True
                replaced_lines.append('<code>')
            elif line.strip().startswith(':header: ') and in_table_head:
                replaced_lines.append(line[len(':header: '):])
            elif line.strip().startswith(':widths:') and in_table_head:
                pass
            elif len(line.strip()) == 0 and in_table_head:
                in_table_head = False
                in_table_body = True

                replaced_lines.append('')
            elif len(line.strip()) == 0 and in_table_body:
                in_table_body = False

                replaced_lines.append('</code>')
                replaced_lines.append('')
            else:
                replaced_lines.append(line)

        text = '\n'.join(replaced_lines)

        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()
            name_right = link.format(cls, name)
            text = text.replace(name_false, name_right)

        def format_parameter(name):
            return name  # FIXME

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

        return '\n\t\t///  '.join(text.strip().split('\n'))