本文整理汇总了Python中formatter.Formatter.add方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.add方法的具体用法?Python Formatter.add怎么用?Python Formatter.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formatter.Formatter
的用法示例。
在下文中一共展示了Formatter.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: formatProperties
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def formatProperties(namespace):
formatter = Formatter(METHOD_INDENTATION)
for property in namespace['properties']:
formatter.add(generatePropertyJSDoc(property))
formatter.addLine(convertKey(property['name']), ':null,')
formatter.newLine()
return formatter.getResult()
示例2: formatMethods
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def formatMethods(namespace):
formatter = Formatter(METHOD_INDENTATION)
for method in namespace['methods']:
formatter.add(generateMethodJSDoc(method))
formatter.addLine('this.', convertIds(method['name']), ' = function(', formatParams(method['parameters']), ") {")
formatter.addLine('};')
formatter.newLine()
return formatter.getResult()
示例3: extendGlobal
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def extendGlobal(name, namespace):
formatter = Formatter(METHOD_INDENTATION)
for method in namespace['methods']:
formatter.add(generateMethodJSDoc(method))
formatter.addLine(name, '.prototype.', convertKey(method['name']), ' = function(', formatParams(method['parameters']), ") {")
formatter.addLine('};')
formatter.newLine()
return formatter.getResult()
示例4: formatGlobal
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def formatGlobal(namespace):
formatter = Formatter(METHOD_INDENTATION)
for method in namespace['methods']:
formatter.add(generateMethodJSDoc(method))
formatter.addLine('function ', convertKey(method['name']), '(', formatParams(method['parameters']), ") {")
formatter.addLine('}')
formatter.newLine()
return formatter.getResult()
示例5: formatMethods
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def formatMethods(namespace):
formatter = Formatter(METHOD_INDENTATION)
key = 'methods' if 'methods' in namespace else 'method'
for method in namespace[key]:
formatter.add(generateMethodJSDoc(method))
formatter.addLine(convertKey(method['name']), ':function(', formatParams(method['parameters']), ") {")
formatter.addLine('},')
formatter.newLine()
return formatter.getResult()
示例6: formatNamespace
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def formatNamespace(namespace):
namespaceName = convertIds(namespace[0])
namespaceContent = namespace[1]
formatter = Formatter()
formatter.add(generateNamespaceJSDoc(namespaceContent))
formatter.addLine(namespaceName, ' = (function() {').newLine()
formatter.addLine(formatProperties(namespaceContent))
formatter.addLine(formatMethods(namespaceContent))
formatter.addLine('}());').newLine()
return formatter.getResult()
示例7: formatNamespace
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import add [as 别名]
def formatNamespace(namespace):
namespaceName = convertIds(namespace[0])
namespaceContent = namespace[1]
formatter = Formatter()
formatter.add(generateNamespaceJSDoc(namespaceContent))
if namespaceName.find('.') < 0:
if namespaceName == 'Global': # ie. Global.alert -> alert()
formatter.add(formatGlobal(namespaceContent))
return formatter.getResult();
formatter.add('var ')
if namespaceName == 'Titanium':
namespaceName = 'Ti'
elif namespaceName.startswith('Global.'): # ie. Global.String prototype extension
formatter.add(extendGlobal(namespaceName[7:], namespaceContent))
return formatter.getResult();
if 'subtype' in namespaceContent and namespaceContent['subtype'] == 'proxy':
formatter.addLine(namespaceName, ' = function() {').addLine('};')
formatter.addLine(namespaceName, '.prototype = {').newLine()
else:
formatter.addLine(namespaceName, ' = {').newLine()
formatter.addLine(formatProperties(namespaceContent))
formatter.addLine(formatMethods(namespaceContent))
formatter.addLine('};').newLine()
return formatter.getResult()