示例#1
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_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)
示例#3
0
def make_methods(typ):
    version_method = {
    'en': """
.. c:function:: int {0}_get_version({1} *{0}, char ret_name[40], uint8_t ret_firmware_version[3], uint8_t ret_binding_version[3])

 Returns the name (including the hardware version), the firmware version 
 and the binding version of the device. The firmware and binding versions are
 given in arrays of size 3 with the syntax [major, minor, revision].
""",
    'de': """
.. c:function:: int {0}_get_version({1} *{0}, char ret_name[40], uint8_t ret_firmware_version[3], uint8_t ret_binding_version[3])

 Gibt den Namen (inklusive Hardwareversion), die Firmwareversion 
 und die Bindingsversion des Gerätes zurück. Die Firmware- und Bindingsversionen werden
 als Array der Größe 3 mit der Syntax [Major, Minor, Revision] zurückgegeben.
"""
    }

    methods = ''
    func_start = '.. c:function:: int '
    for packet in device.get_packets('function'):
        if packet.get_doc()[0] != typ:
            continue
        name = '{0}_{1}'.format(device.get_underscore_name(), packet.get_underscore_name())
        plist = make_parameter_list(packet)
        params = '{0} *{1}{2}'.format(device.get_camel_case_name(), device.get_underscore_name(), plist)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        func = '{0}{1}({2})\n{3}'.format(func_start, name, params, desc)
        methods += func + '\n'

    if typ == 'af':
        methods += version_method[lang].format(device.get_underscore_name(), device.get_camel_case_name())

    return methods
示例#4
0
def format_doc(packet, shift_right):
    text = common.select_lang(packet.get_doc()[1])
    cb_link = ":java:func:`{2}Listener <{0}{1}.{2}Listener>`"
    fu_link = ":java:func:`{2}() <{0}{1}::{2}>`"
    parameter = {"en": "parameter", "de": "Parameter"}
    parameters = {"en": "parameters", "de": "Parameter"}

    cls = device.get_camel_case_name()
    for other_packet in 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 = cb_link.format(device.get_category(), cls, name)
        else:
            name = other_packet.get_headless_camel_case_name()
            name_right = fu_link.format(device.get_category(), cls, name)

        text = text.replace(name_false, name_right)

    text = text.replace(":word:`parameter`", common.select_lang(parameter))
    text = text.replace(":word:`parameters`", common.select_lang(parameters))
    text = text.replace("Callback ", "Listener ")
    text = text.replace(" Callback", " Listener")
    text = text.replace("callback ", "listener ")
    text = text.replace(" callback", " listener")

    text = common.handle_rst_if(text, device)
    text = common.handle_since_firmware(text, device, packet)

    return common.shift_right(text, shift_right)
def format_doc(packet):
    text = common.select_lang(packet.get_doc()[1])
    parameter = {
    'en': 'response value',
    'de': 'Rückgabewert'
    }
    parameters = {
    'en': 'response values',
    'de': 'Rückgabewerte'
    }

    cls = device.get_camel_case_name()
    for other_packet in 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 = ':tcpip:func:`CALLBACK_{1} <{0}.CALLBACK_{1}>`'.format(cls, name_upper)
        else:
            name_right = ':tcpip:func:`{1} <{0}.{1}>`'.format(cls, other_packet.get_underscore_name())
        text = text.replace(name_false, name_right)

    text = text.replace(":word:`parameter`", common.select_lang(parameter))
    text = text.replace(":word:`parameters`", common.select_lang(parameters))

    text = common.handle_rst_if(text, device)
    text = common.handle_since_firmware(text, device, packet)

    return common.shift_right(text, 1)
示例#6
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_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_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)
示例#9
0
    def get_vbnet_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        text = self.get_device().specialize_vbnet_doc_function_links(text)

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

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

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

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

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

        return common.shift_right(text, 1)
示例#10
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)
示例#11
0
def format_doc(packet):
    text = common.select_lang(packet.get_doc()[1])
    parameter = {
    'en': 'parameter',
    'de': 'Parameter'
    }
    parameters = {
    'en': 'parameters',
    'de': 'Parameter'
    }

    for other_packet in 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 = 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(device.get_underscore_name(),
                                                    other_packet.get_underscore_name())
        text = text.replace(name_false, name_right)

    text = text.replace(":word:`parameter`", common.select_lang(parameter))
    text = text.replace(":word:`parameters`", common.select_lang(parameters))

    text = common.handle_rst_if(text, device)
    text = common.handle_since_firmware(text, device, packet)

    return common.shift_right(text, 1)
示例#12
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)
    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)
示例#14
0
def make_callbacks():
    cb = {
    'en': """
.. csharp:function:: public delegate void {0}::{1}({2})

{3}
""",
    'de': """
.. csharp:function:: public delegate void {0}::{1}({2})

{3}
"""
    }

    cbs = ''
    cls = device.get_camel_case_name()
    for packet in device.get_packets('callback'):
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 2))
        params = csharp_common.make_parameter_list(packet)

        cbs += cb[lang].format(device.get_category() + device.get_camel_case_name(),
                               packet.get_camel_case_name(),
                               params,
                               desc)

    return cbs
示例#15
0
def make_callbacks():
    cb = {
    'en': """
.. java:function:: public class {0}{1}.{2}Listener()

 .. java:function:: public void {3}({4})
  :noindex:

{5}
""",
    'de': """
.. java:function:: public class {0}{1}.{2}Listener()

 .. java:function:: public void {3}({4})
  :noindex:

{5}
"""
    }

    cbs = ''
    cls = device.get_camel_case_name()
    for packet in device.get_packets('callback'):
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 2))
        params = make_parameter_list(packet)

        cbs += cb[lang].format(device.get_category(),
                               cls,
                               packet.get_camel_case_name(),
                               packet.get_headless_camel_case_name(),
                               params,
                               desc)

    return cbs
示例#16
0
def format_doc(packet, shift_right):
    text = common.select_lang(packet.get_doc()[1])
    parameter = {
    'en': 'parameter',
    'de': 'Parameter'
    }
    parameters = {
    'en': 'parameters',
    'de': 'Parameter'
    }
    link = ':csharp:func:`{2}() <{0}{1}::{2}>`'

    cls = device.get_camel_case_name()
    for other_packet in 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(device.get_category(), cls, name)

        text = text.replace(name_false, name_right)

    text = text.replace(":word:`parameter`", common.select_lang(parameter))
    text = text.replace(":word:`parameters`", common.select_lang(parameters))

    text = common.handle_rst_if(text, device)
    text = common.handle_since_firmware(text, device, packet)

    return common.shift_right(text, shift_right)
示例#17
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)
示例#18
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)
示例#19
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)
示例#20
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 format_doc(packet):
    text = common.select_lang(packet.get_doc()[1])
    parameter = {
    'en': 'parameter',
    'de': 'Parameter'
    }
    parameters = {
    'en': 'parameters',
    'de': 'Parameter'
    }

    cls = device.get_category() + device.get_camel_case_name()
    for other_packet in 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} <T{0}.On{1}>`'.format(cls, name)
        else:
            name_right = ':delphi:func:`{1} <T{0}.{1}>`'.format(cls, name)
        text = text.replace(name_false, name_right)

    text = text.replace(":word:`parameter`", common.select_lang(parameter))
    text = text.replace(":word:`parameters`", common.select_lang(parameters))

    text = common.handle_rst_if(text, device)
    prefix = '{0}_{1}_'.format(device.get_category().upper(), 
                               device.get_upper_case_name())
    text = common.handle_constants(text, 
                                   prefix, 
                                   packet)
    text = common.handle_since_firmware(text, device, packet)

    return common.shift_right(text, 1)
示例#22
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)
示例#23
0
def make_callbacks():
    param_format = {
    'en': """
 .. code-block:: c

  void callback({0})
""",
    'de': """
 .. code-block:: c

  void callback({0})
"""
    }

    cbs = ''
    func_start = '.. c:var:: '
    for packet in device.get_packets('callback'):
        plist = make_parameter_list(packet)[2:].replace('*ret_', '')
        if not plist:
            plist = 'void'
        params = param_format[lang].format(plist)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        name = '{0}_{1}'.format(device.get_upper_case_name(),
                                packet.get_upper_case_name())

        func = '{0}{1}_CALLBACK_{2}\n{3}\n{4}'.format(func_start,
                                                      device.get_upper_case_name(),
                                                      packet.get_upper_case_name(),
                                                      params,
                                                      desc)
        cbs += func + '\n'

    return cbs
示例#24
0
    def get_mathematica_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])

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

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

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

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

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

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

        return common.shift_right(text, 1)
def format_doc(packet):
    text = common.select_lang(packet.get_doc()[1])
    parameter = {
    'en': 'parameter',
    'de': 'Parameter'
    }
    parameters = {
    'en': 'parameters',
    'de': 'Parameter'
    }

    cls = device.get_camel_case_name()
    for other_packet in 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 = ':py:attr:`CALLBACK_{1} <{0}.CALLBACK_{1}>`'.format(cls, name_upper)
        else:
            name_right = ':py:func:`{1}() <{0}.{1}>`'.format(cls, other_packet.get_underscore_name())
        text = text.replace(name_false, name_right)

    text = text.replace(":word:`parameter`", common.select_lang(parameter))
    text = text.replace(":word:`parameters`", common.select_lang(parameters))

    text = common.handle_rst_if(text, device)
    text = common.handle_constants(text, 
                                   device.get_category() + device.get_camel_case_name() + '.', 
                                   packet)
    text = common.handle_since_firmware(text, device, packet)

    return common.shift_right(text, 1)
示例#26
0
def make_callbacks():
    signature_str = {
    'en':  """
 .. code-block:: php

  void callback({0})
""",
    'de':  """
 .. code-block:: php

  void callback({0})
"""
    }

    cbs = ''
    func_start = '.. php:member:: int '
    cls = device.get_category() + device.get_camel_case_name()
    for packet in device.get_packets('callback'):
        params = make_parameter_list(packet)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        signature = signature_str[lang].format(params)
        func = '{0}{1}::CALLBACK_{2}\n{3}{4}'.format(func_start,
                                                     cls,
                                                     packet.get_upper_case_name(),
                                                     signature,
                                                     desc)
        cbs += func + '\n'

    return cbs
    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)
示例#28
0
    def get_shell_formatted_doc(self):
        text = common.select_lang(self.get_doc()[1])
        device_name = self.get_device().get_shell_device_name()
        constants = {'en': 'symbols', 'de': 'Symbole'}

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

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

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

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

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

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

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

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

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

            return c + '\n'

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

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

        return common.shift_right(text, 1)
示例#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():
                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)
示例#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)
示例#31
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)
示例#32
0
def make_methods(typ):
    version_method = {
    'en': """
.. java:function:: public {0}.Version {0}::getVersion()

 Returns the name (including the hardware version), the firmware version 
 and the binding version of the device. The firmware and binding versions are
 given in arrays of size 3 with the syntax [major, minor, revision].

 The returned object has the public member variables ``String name``, 
 ``short[3] firmwareVersion`` and ``short[3] bindingVersion``.
""",
    'de': """
.. java:function:: public {0}.Version {0}::getVersion()

 Gibt den Namen (inklusive Hardwareversion), die Firmwareversion 
 und die Bindingsversion des Gerätes zurück. Die Firmware- und Bindingsversionen werden
 als Array der Größe 3 mit der Syntax [Major, Minor, Revision] zurückgegeben.

 Das zurückgegebene Objekt hat die Public Member Variablen ``String name``, 
 ``short[3] firmwareVersion`` und ``short[3] bindingVersion``.
"""
    }

    methods = ''
    func_start = '.. java:function:: '
    cls = device.get_category() + device.get_camel_case_name()
    for packet in device.get_packets('function'):
        if packet.get_doc()[0] != typ:
            continue

        ret_type = get_return_type(packet)
        name = packet.get_headless_camel_case_name()
        params = make_parameter_list(packet)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        obj_desc = make_obj_desc(packet)
        func = '{0}public {1} {2}::{3}({4})\n{5}{6}'.format(func_start, 
                                                            ret_type,
                                                            cls, 
                                                            name, 
                                                            params, 
                                                            desc,
                                                            obj_desc)
        methods += func + '\n'

    if typ == 'af':
        methods += version_method[lang].format(cls)

    return methods
示例#33
0
def make_methods(typ):
    method_version = {
    'en': """
.. csharp:function:: public void {0}::GetVersion(out string name, out byte[] firmwareVersion, out byte[] bindingVersion)

 Returns the name (including the hardware version), the firmware version 
 and the binding version of the device. The firmware and binding versions are
 given in arrays of size 3 with the syntax [major, minor, revision].
""",
    'de': """
.. csharp:function:: public void {0}::GetVersion(out string name, out byte[] firmwareVersion, out byte[] bindingVersion)

 Gibt den Namen (inklusive Hardwareversion), die Firmwareversion 
 und die Bindingsversion des Gerätes zurück. Die Firmware- und Bindingsversionen werden
 als Array der Größe 3 mit der Syntax [Major, Minor, Revision] zurückgegeben.
"""
    }
    version_changed = {
    'en': """
 .. versionchanged:: 1.1.0
    Result is returned. Previously it was passed as ``out`` parameter.
""",
    'de': """
 .. versionchanged:: 1.1.0
    Das Ergebnis wird zurückgegeben. In vorherigen Versionen wurde es als ``out`` Parameter übergeben.
"""
    }

    methods = ''
    func_start = '.. csharp:function:: '
    cls = device.get_category() + device.get_camel_case_name()
    for packet in device.get_packets('function'):
        if packet.get_doc()[0] != typ:
            continue

        signature = csharp_common.make_method_signature(packet, True, device)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        func = '{0}{1}\n{2}'.format(func_start, 
                                    signature, 
                                    desc)
        methods += func + '\n'

        if len(packet.get_elements('out')) == 1:
            methods += version_changed[lang] + '\n'

    if typ == 'af':
        methods += method_version[lang].format(cls)

    return methods
示例#34
0
def make_callbacks():
    cbs = ""
    func_start = ".. tcpip:function:: "
    cls = device.get_camel_case_name()
    for packet in device.get_packets("callback"):
        fid = "\n :functionid: {0}".format(packet.get_function_id())
        response = make_response_desc(packet)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))

        func = "{0}{1}.CALLBACK_{2}\n{3}\n{4}\n{5}".format(
            func_start, cls, packet.get_upper_case_name(), fid, response, desc
        )
        cbs += func + "\n"

    return cbs
示例#35
0
    def get_tvpl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        constants = {'en': 'symbols', 'de': 'Symbole'}

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

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

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

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

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

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

            e = []

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

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

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

            return c + '\n'

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

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

        return common.shift_right(text, 1)
示例#36
0
def make_callbacks():
    cbs = ''
    func_start = '.. py:attribute:: '
    cls = device.get_camel_case_name()
    for packet in device.get_packets('callback'):
        param_desc = make_parameter_desc(packet, 'out')
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))

        func = '{0}{1}.CALLBACK_{2}\n{3}\n{4}'.format(func_start,
                                                      cls,
                                                      packet.get_upper_case_name(),
                                                      param_desc,
                                                      desc)
        cbs += func + '\n'

    return cbs
    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)
示例#38
0
    def get_tvpl_formatted_doc(self):
        text = common.select_lang(self.get_doc_text())
        constants = {'en': 'symbols', 'de': 'Symbole'}

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

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

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

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

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

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

            e = []

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

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

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

            return c + '\n'

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

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

        return common.shift_right(text, 1)
示例#39
0
def make_methods(typ):
    methods = ""
    func_start = ".. tcpip:function:: "
    cls = device.get_camel_case_name()
    for packet in device.get_packets("function"):
        if packet.get_doc()[0] != typ:
            continue
        name = packet.get_underscore_name()
        fid = "\n :functionid: {0}".format(packet.get_function_id())
        request = make_request_desc(packet)
        response = make_response_desc(packet)
        d = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        desc = "{0}{1}{2}{3}".format(fid, request, response, d)
        func = "{0}{1}.{2}\n{3}".format(func_start, cls, name, desc)
        methods += func + "\n"

    return methods
示例#40
0
def make_methods(typ):
    version_method = {
    'en': """
.. py:function:: {0}.get_version()

 :rtype: (str, [int, int, int], [int, int, int])

 Returns the name (including the hardware version), the firmware version 
 and the binding version of the device. The firmware and binding versions are
 given in arrays of size 3 with the syntax [major, minor, revision].
""",
    'de': """
.. py:function:: {0}.get_version()

 :rtype: (str, [int, int, int], [int, int, int])
 
 Gibt den Namen (inklusive Hardwareversion), die Firmwareversion 
 und die Bindingsversion des Gerätes zurück. Die Firmware- und Bindingsversionen werden
 als Array der Größe 3 mit der Syntax [Major, Minor, Revision] zurückgegeben.
"""
    }

    methods = ''
    func_start = '.. py:function:: '
    cls = device.get_camel_case_name()
    for packet in device.get_packets('function'):
        if packet.get_doc()[0] != typ:
            continue
        name = packet.get_underscore_name()
        params = make_parameter_list(packet)
        pd = make_parameter_desc(packet, 'in')
        r = make_return_desc(packet)
        d = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        desc = '{0}{1}{2}'.format(pd, r, d)
        func = '{0}{1}.{2}({3})\n{4}'.format(func_start, 
                                             cls, 
                                             name, 
                                             params, 
                                             desc)
        methods += func + '\n'

    if typ == 'af':
        methods += version_method[lang].format(cls)

    return methods 
示例#41
0
def make_methods(typ):
    version_method = {
    'en': """
.. php:function:: array {0}::getVersion()

 Returns the name (including the hardware version), the firmware version
 and the binding version of the device. The firmware and binding versions
 are given in arrays of size 3 with the syntax (major, minor, revision).

 The returned array contains ``name``, ``firmwareVersion`` and ``bindingVersion``.
""",
    'de': """
.. php:function:: array {0}::getVersion()

 Gibt den Namen (inklusive Hardwareversion), die Firmwareversion 
 und die Bindingsversion des Gerätes zurück. Die Firmware- und Bindingsversionen werden
 als Feld der Größe 3 mit der Syntax [Major, Minor, Revision] zurückgegeben.

 Das zurückgegebene Array enthält ``name``, ``firmwareVersion`` und ``bindingVersion``.
"""
    }

    methods = ''
    func_start = '.. php:function:: '
    cls = device.get_category() + device.get_camel_case_name()
    for packet in device.get_packets('function'):
        if packet.get_doc()[0] != typ:
            continue

        ret_type = php_common.get_return_type(packet)
        name = packet.get_headless_camel_case_name()
        params = make_parameter_list(packet)
        desc = fix_links(common.shift_right(packet.get_doc()[1][lang], 1))
        func = '{0}{1} {2}::{3}({4})\n{5}'.format(func_start, 
                                                            ret_type,
                                                            cls, 
                                                            name, 
                                                            params, 
                                                            desc)
        methods += func + '\n'

    if typ == 'af':
        methods += version_method[lang].format(cls)

    return methods
示例#42
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)
示例#43
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)
示例#44
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)
示例#45
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)
示例#46
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)