def make_parameter_doc(packet):
    param = []
    for element in packet.get_elements():
        if element[3] == 'out' or packet.get_type() != 'function':
            continue

        php_type = php_common.get_php_type(element[1])
        if element[2] > 1 and element[1] != 'string':
            param.append('@param {0}[] ${1}'.format(php_type, element[0]))
        else:
            param.append('@param {0} ${1}'.format(php_type, element[0]))

    param.append('\n@return ' + php_common.get_return_type(packet))
    return '\n'.join(param)
Example #2
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
Example #3
0
def make_methods(typ):
    version_method = {
    'en': """
.. php:function:: array {0}::getVersion()

 Returns API version [major, minor, revision] used for this device.
""",
    'de': """
.. php:function:: array {0}::getVersion()

 Gibt die API Version [major, minor, revision] die benutzt
 wird zurück.
"""
    }

    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 = format_doc(packet)
        func = '{0}{1} {2}::{3}({4})\n{5}'.format(func_start,
                                                  ret_type,
                                                  cls,
                                                  name,
                                                  params,
                                                  desc)
        methods += func + '\n'

    if typ == 'af':
        methods += common.select_lang(version_method).format(cls)

    return methods
def make_methods(typ):
    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 = php_common.make_parameter_list(packet, True)
        desc = format_doc(packet)
        obj_desc = make_object_desc(packet)
        func = '{0}{1} {2}::{3}({4})\n{5}{6}'.format(func_start,
                                                     ret_type,
                                                     cls,
                                                     name,
                                                     params,
                                                     desc,
                                                     obj_desc)
        methods += func + '\n'

    return methods