Beispiel #1
0
def parse_function(reader):
    obj = QmlFunction()
    token = reader.consume_expecting(lexer.ELEMENT)
    obj.name = token.value

    reader.consume_expecting(lexer.CHAR, "(")
    obj.args = parse_arguments(reader)
    return obj
Beispiel #2
0
def parse_function(reader):
    obj = QmlFunction()
    token = reader.consume_expecting(lexer.ELEMENT)
    obj.name = token.value

    reader.consume_expecting(lexer.CHAR, "(")
    obj.args = parse_arguments(reader)
    return obj
Beispiel #3
0
    def _test_post_process_doc(self, doc):
        fcn = QmlFunction()
        fcn.args = [
            QmlArgument("firstname"),
            QmlArgument("lastname"),
            QmlArgument("age"),
            QmlArgument("misc"),
            ]
        fcn.doc = doc
        fcn.post_process_doc()

        self.assertEqual(fcn.args[0].type, "string")
        self.assertEqual(fcn.args[1].type, "string")
        self.assertEqual(fcn.args[2].type, "int")
        self.assertEqual(fcn.args[3].type, "")
        self.assertEqual(fcn.type, "User")

        # "[@\]param type:..." are turned into "@param"
        expected_doc = re.sub(r"[@\\]param type:\w+", r"@param", doc)
        # "[@\]return type:..." are turned into "[@\]return"
        expected_doc = re.sub(r"([@\\])return type:\w+", r"\1return", expected_doc)
        self.assertMultiLineEqual(fcn.doc, expected_doc)