예제 #1
0
def to_jsca_event(event):
	return to_ordered_dict({
			"name": event.name,
			"description": "" if "summary" not in event.api_obj else to_jsca_description(event.api_obj["summary"], event),
			"deprecated": event.deprecated is not None and len(event.deprecated) > 0,
			"properties": to_jsca_properties(event.properties, for_event=True)
			}, ("name",))
예제 #2
0
def to_jsca_type(api):
	# Objects marked as external should be ignored
	if api.external:
		return None
	if api.name in not_real_titanium_types:
		return None
	log.trace("Converting %s to jsca" % api.name)
	result = {
			"name": clean_class_name(clean_namespace(api.name)),
			"isInternal": False,
			"description": "" if "summary" not in api.api_obj else to_jsca_description(api.api_obj["summary"], api),
			"deprecated": api.deprecated is not None and len(api.deprecated) > 0,
			"examples": to_jsca_examples(api),
			"properties": to_jsca_properties(api.properties),
			"functions": to_jsca_functions(api.methods),
			"events": to_jsca_events(api.events),
			"remarks": to_jsca_remarks(api),
			"userAgents": to_jsca_userAgents(api.platforms),
			"since": to_jsca_since(api.platforms),
			"inherits": to_jsca_inherits(api)
			}
	# TIMOB-7169. If it's a proxy (non-module) and it has no "class properties",
	# mark it as internal.  This avoids it being displayed in Code Assist.
	# TIDOC-860. Do not mark Global types as internal.
	if api.typestr == "proxy" and not (api.name).startswith('Global.'):
		can_hide = True
		for p in result["properties"]:
			if p["isClassProperty"]:
				can_hide = False
				break
		result["isInternal"] = can_hide
	return to_ordered_dict(result, ('name',))
예제 #3
0
def to_jsca_function(method):
	log.trace("%s.%s" % (method.parent.name, method.name))

	creatable = False;
	if dict_has_non_empty_member(method.parent.api_obj, "extends"):
		ancestor = method.parent.api_obj["extends"]
		if (ancestor == "Titanium.Proxy" or ancestor == "Titanium.UI.View"):
			creatable = True;
	if ("createable" in method.parent.api_obj):
		creatable = method.parent.api_obj["createable"]

	result = {
			"name": method.name,
			"deprecated": method.deprecated is not None and len(method.deprecated) > 0,
			"description": "" if "summary" not in method.api_obj else to_jsca_description(method.api_obj["summary"], method)
			}
	if dict_has_non_empty_member(method.api_obj, "returns") and method.api_obj["returns"] != "void":
		result["returnTypes"] = to_jsca_return_types(method.api_obj["returns"])
	if method.parameters is not None and len(method.parameters) > 0:
		result["parameters"] = [to_jsca_method_parameter(p) for p in method.parameters]
	result["since"] = to_jsca_since(method.platforms)
	result['userAgents'] = to_jsca_userAgents(method.platforms)
	result['isInstanceProperty'] = True if creatable else False
	result['isClassProperty'] = False if creatable else True
	result['isInternal'] = False # we don't make this distinction (yet anyway)
	result['examples'] = to_jsca_examples(method)
	result['references'] = [] # we don't use the notion of 'references' (yet anyway)
	result['exceptions'] = [] # we don't specify exceptions (yet anyway)
	result['isConstructor'] = False # we don't expose native class constructors
	result['isMethod'] = True # all of our functions are class instance functions, ergo methods
	return to_ordered_dict(result, ('name',))
예제 #4
0
def to_jsca_method_parameter(p):
	data_type = to_jsca_type_name(p.api_obj["type"])
	if data_type.lower() == "object" and p.parent.name.startswith("create"):
		if "returns" in p.parent.api_obj:
			method_return_type = p.parent.api_obj["returns"]["type"]
			if method_return_type in all_annotated_apis:
				type_in_method_name = p.parent.name.replace("create", "")
				if len(type_in_method_name) > 0 and type_in_method_name == method_return_type.split(".")[-1]:
					data_type = to_jsca_type_name(method_return_type)
	usage = "required"

	if "optional" in p.api_obj and p.api_obj["optional"]:
		usage = "optional"
	elif p.repeatable:
		usage = "one-or-more"

	result = {
			"name": p.name,
			"description": "" if "summary" not in p.api_obj else to_jsca_description(p.api_obj["summary"], p),
			"type": data_type,
			"usage": usage
			}
	if "constants" in p.api_obj:
		result["constants"] = to_jsca_constants(p.api_obj["constants"])
	return to_ordered_dict(result, ('name',))
예제 #5
0
def to_jsca_type(api):
	if api.name in not_real_titanium_types:
		return None
	log.trace("Converting %s to jsca" % api.name)
	result = {
			"name": clean_namespace(api.name),
			"isInternal": False,
			"description": "" if "summary" not in api.api_obj else to_jsca_description(api.api_obj["summary"]),
			"deprecated": api.deprecated is not None and len(api.deprecated) > 0,
			"examples": to_jsca_examples(api),
			"properties": to_jsca_properties(api.properties),
			"functions": to_jsca_functions(api.methods),
			"events": to_jsca_events(api.events),
			"remarks": to_jsca_remarks(api),
			"userAgents": to_jsca_userAgents(api.platforms),
			"since": to_jsca_since(api.platforms)
			}
	# TIMOB-7169. If it's a proxy (non-module) and it has no "class properties",
	# mark it as internal.  This avoids it being displayed in Code Assist.
	if api.typestr == "proxy":
		can_hide = True
		for p in result["properties"]:
			if p["isClassProperty"]:
				can_hide = False
				break
		result["isInternal"] = can_hide
	return to_ordered_dict(result, ('name',))
예제 #6
0
def to_jsca_event(event):
	return to_ordered_dict({
			"name": event.name,
			"description": "" if "summary" not in event.api_obj else to_jsca_description(event.api_obj["summary"], event),
			"deprecated": event.deprecated is not None and len(event.deprecated) > 0,
			"properties": to_jsca_properties(event.properties, for_event=True)
			}, ("name",))
예제 #7
0
def to_jsca_function(method):
    log.trace("%s.%s" % (method.parent.name, method.name))
    result = {
        "name":
        method.name,
        "deprecated":
        method.deprecated is not None and len(method.deprecated) > 0,
        "description":
        "" if "summary" not in method.api_obj else to_jsca_description(
            method.api_obj["summary"], method)
    }
    if dict_has_non_empty_member(
            method.api_obj, "returns") and method.api_obj["returns"] != "void":
        result["returnTypes"] = to_jsca_return_types(method.api_obj["returns"])
    if method.parameters is not None and len(method.parameters) > 0:
        result["parameters"] = [
            to_jsca_method_parameter(p) for p in method.parameters
        ]
    result["since"] = to_jsca_since(method.platforms)
    result['userAgents'] = to_jsca_userAgents(method.platforms)
    result['isInstanceProperty'] = True  # we don't have class static methods
    result['isClassProperty'] = False  # we don't have class static methods
    result['isInternal'] = False  # we don't make this distinction (yet anyway)
    result['examples'] = to_jsca_examples(method)
    result['references'] = [
    ]  # we don't use the notion of 'references' (yet anyway)
    result['exceptions'] = []  # we don't specify exceptions (yet anyway)
    result[
        'isConstructor'] = False  # we don't expose native class constructors
    result[
        'isMethod'] = True  # all of our functions are class instance functions, ergo methods
    return to_ordered_dict(result, ('name', ))
예제 #8
0
def to_jsca_type(api):
    if api.name in not_real_titanium_types:
        return None
    log.trace("Converting %s to jsca" % api.name)
    result = {
        "name":
        clean_namespace(api.name),
        "description":
        "" if "summary" not in api.api_obj else to_jsca_description(
            api.api_obj["summary"]),
        "deprecated":
        api.deprecated is not None and len(api.deprecated) > 0,
        "examples":
        to_jsca_examples(api),
        "properties":
        to_jsca_properties(api.properties),
        "functions":
        to_jsca_functions(api.methods),
        "events":
        to_jsca_events(api.events),
        "remarks":
        to_jsca_remarks(api),
        "userAgents":
        to_jsca_userAgents(api.platforms),
        "since":
        to_jsca_since(api.platforms)
    }
    return to_ordered_dict(result, ('name', ))
예제 #9
0
def to_jsca_property(prop, for_event=False):
	result = {
			"name": prop.name,
			"description": "" if "summary" not in prop.api_obj else to_jsca_description(prop.api_obj["summary"], prop),
			"deprecated": prop.deprecated is not None and len(prop.deprecated) > 0,
			"type": "" if "type" not in prop.api_obj else to_jsca_type_name(prop.api_obj["type"])
			}
	if not for_event:

		creatable = False;
		if dict_has_non_empty_member(prop.parent.api_obj, "extends"):
			ancestor = prop.parent.api_obj["extends"]
			if (ancestor == "Titanium.Proxy" or ancestor == "Titanium.UI.View"):
				creatable = True
			if ("createable" in prop.parent.api_obj):
				creatable = prop.parent.api_obj["createable"]

		result["isClassProperty"] = False if (creatable and prop.name != prop.name.upper()) else True
		result["isInstanceProperty"] = True if (creatable and prop.name != prop.name.upper()) else False
		result["since"] = to_jsca_since(prop.platforms)
		result["userAgents"] = to_jsca_userAgents(prop.platforms)
		result["isInternal"] = False
		result["examples"] = to_jsca_examples(prop)
		result["availability"] = to_jsca_availability(prop)
		result["permission"] = to_jsca_permission(prop)
	if "constants" in prop.api_obj:
		result["constants"] = to_jsca_constants(prop.api_obj["constants"])
	return to_ordered_dict(result, ("name",))
예제 #10
0
def to_jsca_method_parameter(p):
	data_type = to_jsca_type_name(p.api_obj["type"])
	if data_type.lower() == "object" and p.parent.name.startswith("create"):
		if "returns" in p.parent.api_obj:
			method_return_type = p.parent.api_obj["returns"]["type"]
			if method_return_type in all_annotated_apis:
				type_in_method_name = p.parent.name.replace("create", "")
				if len(type_in_method_name) > 0 and type_in_method_name == method_return_type.split(".")[-1]:
					data_type = to_jsca_type_name(method_return_type)
	usage = "required"

	if "optional" in p.api_obj and p.api_obj["optional"]:
		usage = "optional"
	elif p.repeatable:
		usage = "one-or-more"

	result = {
			"name": p.name,
			"description": "" if "summary" not in p.api_obj else to_jsca_description(p.api_obj["summary"], p),
			"type": data_type,
			"usage": usage
			}
	if "constants" in p.api_obj:
		result["constants"] = to_jsca_constants(p.api_obj["constants"])
	return to_ordered_dict(result, ('name',))
def to_jsca_since(platforms):
    return [
        to_ordered_dict(
            {
                "name": "Titanium Mobile SDK - %s" % platform["pretty_name"],
                "version": platform["since"]
            }, ("name", )) for platform in platforms
    ]
예제 #12
0
def to_jsca_event(event):
    return to_ordered_dict(
        {
            "name":
            event.name,
            "description":
            "" if "summary" not in event.api_obj else to_jsca_description(
                event.api_obj["summary"]),
            "properties":
            to_jsca_properties(event.properties, for_event=True)
        }, ("name", ))
예제 #13
0
def to_jsca_property(prop, for_event=False):
	result = {
			"name": prop.name,
			"description": "" if "summary" not in prop.api_obj else to_jsca_description(prop.api_obj["summary"]),
			"type": "" if "type" not in prop.api_obj else to_jsca_type_name(prop.api_obj["type"])
			}
	if not for_event:
		result["isClassProperty"] = (prop.name == prop.name.upper())
		result["isInstanceProperty"] = (prop.name != prop.name.upper())
		result["since"] = to_jsca_since(prop.platforms)
		result["userAgents"] = to_jsca_userAgents(prop.platforms)
		result["isInternal"] = False
		result["examples"] = to_jsca_examples(prop)
	return to_ordered_dict(result, ("name",))
예제 #14
0
def to_jsca_property(prop, for_event=False):
	result = {
			"name": prop.name,
			"description": "" if "summary" not in prop.api_obj else to_jsca_description(prop.api_obj["summary"]),
			"type": "" if "type" not in prop.api_obj else to_jsca_type_name(prop.api_obj["type"])
			}
	if not for_event:
		result["isClassProperty"] = (prop.name == prop.name.upper())
		result["isInstanceProperty"] = (prop.name != prop.name.upper())
		result["since"] = to_jsca_since(prop.platforms)
		result["userAgents"] = to_jsca_userAgents(prop.platforms)
		result["isInternal"] = False
		result["examples"] = to_jsca_examples(prop)
	return to_ordered_dict(result, ("name",))
예제 #15
0
def to_jsca_method_parameter(p):
	data_type = to_jsca_type_name(p.api_obj["type"])
	if data_type.lower() == "object" and p.parent.name.startswith("create"):
		if "returns" in p.parent.api_obj:
			method_return_type = p.parent.api_obj["returns"]["type"]
			if method_return_type in all_annotated_apis:
				type_in_method_name = p.parent.name.replace("create", "")
				if len(type_in_method_name) > 0 and type_in_method_name == method_return_type.split(".")[-1]:
					data_type = to_jsca_type_name(method_return_type)
	result = {
			"name": p.name,
			"description": to_jsca_description(p.api_obj["description"]),
			"type": data_type,
			"usage": "optional" if "optional" in p.api_obj and p.api_obj["optional"] else "required"
			}
	return to_ordered_dict(result, ('name',))
예제 #16
0
def to_jsca_type(api):
	if api.name in not_real_titanium_types:
		return None
	log.trace("Converting %s to jsca" % api.name)
	result = {
			"name": clean_namespace(api.name),
			"description": "" if "summary" not in api.api_obj else to_jsca_description(api.api_obj["summary"]),
			"deprecated": api.deprecated is not None and len(api.deprecated) > 0,
			"examples": to_jsca_examples(api),
			"properties": to_jsca_properties(api.properties),
			"functions": to_jsca_functions(api.methods),
			"events": to_jsca_events(api.events),
			"remarks": to_jsca_remarks(api),
			"userAgents": to_jsca_userAgents(api.platforms),
			"since": to_jsca_since(api.platforms)
			}
	return to_ordered_dict(result, ('name',))
예제 #17
0
def to_jsca_property(prop, for_event=False):
	result = {
			"name": prop.name,
			"description": "" if "summary" not in prop.api_obj else to_jsca_description(prop.api_obj["summary"], prop),
			"deprecated": prop.deprecated is not None and len(prop.deprecated) > 0,
			"type": "" if "type" not in prop.api_obj else to_jsca_type_name(prop.api_obj["type"])
			}
	if not for_event:
		result["isClassProperty"] = (prop.name == prop.name.upper())
		result["isInstanceProperty"] = (prop.name != prop.name.upper())
		result["since"] = to_jsca_since(prop.platforms)
		result["userAgents"] = to_jsca_userAgents(prop.platforms)
		result["isInternal"] = False
		result["examples"] = to_jsca_examples(prop)
		result["availability"] = to_jsca_availability(prop)
		result["permission"] = to_jsca_permission(prop)
	if "constants" in prop.api_obj:
		result["constants"] = to_jsca_constants(prop.api_obj["constants"])
	return to_ordered_dict(result, ("name",))
예제 #18
0
def to_jsca_function(method):
	log.trace("%s.%s" % (method.parent.name, method.name))
	result = {
			"name": method.name,
			"description": "" if "description" not in method.api_obj else to_jsca_description(method.api_obj["description"])
			}
	if dict_has_non_empty_member(method.api_obj, "returns") and method.api_obj["returns"] != "void":
		result["returnTypes"] = to_jsca_return_types(method.api_obj["returns"])
	if method.parameters is not None and len(method.parameters) > 0:
		result["parameters"] = [to_jsca_method_parameter(p) for p in method.parameters]
	result["since"] = to_jsca_since(method.platforms)
	result['userAgents'] = to_jsca_userAgents(method.platforms)
	result['isInstanceProperty'] = True # we don't have class static methods
	result['isClassProperty'] = False # we don't have class static methods
	result['isInternal'] = False # we don't make this distinction (yet anyway)
	result['examples'] = to_jsca_examples(method)
	result['references'] = [] # we don't use the notion of 'references' (yet anyway)
	result['exceptions'] = [] # we don't specify exceptions (yet anyway)
	result['isConstructor'] = False # we don't expose native class constructors
	result['isMethod'] = True # all of our functions are class instance functions, ergo methods
	return to_ordered_dict(result, ('name',))
def to_jsca_property(prop, for_event=False):
    result = {
        "name":
        prop.name,
        "description":
        "" if "summary" not in prop.api_obj else to_jsca_description(
            prop.api_obj["summary"], prop),
        "deprecated":
        prop.deprecated is not None and len(prop.deprecated) > 0,
        "type":
        "" if "type" not in prop.api_obj else to_jsca_type_name(
            prop.api_obj["type"])
    }
    if not for_event:

        creatable = False
        if dict_has_non_empty_member(prop.parent.api_obj, "extends"):
            ancestor = prop.parent.api_obj["extends"]
            if (ancestor == "Titanium.Proxy"
                    or ancestor == "Titanium.UI.View"):
                creatable = True
            if ("createable" in prop.parent.api_obj):
                creatable = prop.parent.api_obj["createable"]

        result["isClassProperty"] = False if (
            creatable and prop.name != prop.name.upper()) else True
        result["isInstanceProperty"] = True if (
            creatable and prop.name != prop.name.upper()) else False
        result["since"] = to_jsca_since(prop.platforms)
        result["userAgents"] = to_jsca_userAgents(prop.platforms)
        result["isInternal"] = False
        result["examples"] = to_jsca_examples(prop)
        result["availability"] = to_jsca_availability(prop)
        result["permission"] = to_jsca_permission(prop)
    if "constants" in prop.api_obj:
        result["constants"] = to_jsca_constants(prop.api_obj["constants"])
    return to_ordered_dict(result, ("name", ))
예제 #20
0
def to_jsca_since(platforms):
	return [to_ordered_dict({
		"name": "Titanium Mobile SDK - %s" % platform["pretty_name"],
		"version": platform["since"]
		}, ("name",)) for platform in platforms]
예제 #21
0
def to_jsca_event(event):
	return to_ordered_dict({
			"name": event.name,
			"description": "" if "summary" not in event.api_obj else to_jsca_description(event.api_obj["summary"]),
			"properties": to_jsca_properties(event.properties, for_event=True)
			}, ("name",))