tools/json_schema_compiler/js_util.py
def AppendObjectDefinition(self, c, namespace_name, properties,
                               new_line=True):
    """Given an OrderedDict of properties, returns a Code containing the
       description of an object.
    """
    if not properties:
      return

    c.Sblock('{', new_line=new_line)
    first = True
    for field, prop in properties.items():
      # Avoid trailing comma.
      # TODO(devlin): This will be unneeded, if/when
      # https://github.com/google/closure-compiler/issues/796 is fixed.
      if not first:
        c.Append(',', new_line=False)
      first = False
      js_type = self._TypeToJsType(namespace_name, prop.type_)
      if prop.optional:
        js_type = (Code().Append('(')
                         .Concat(js_type, new_line=False)
                         .Append('|undefined)', new_line=False))
      c.Append('%s: ' % field, strip_right=False)
      c.Concat(js_type, new_line=False)

    c.Eblock('}')
Given an OrderedDict of properties, returns a Code containing the
       description of an object.
    
Given an OrderedDict of properties, returns a Code containing the
description of an object.
Given an OrderedDict of properties returns a Code containing the description of an object .
def AppendObjectDefinition(self, c, namespace_name, properties,
                               new_line=True):
    if not properties:
      return
    c.Sblock('{', new_line=new_line)
    first = True
    for field, prop in properties.items():
      if not first:
        c.Append(',', new_line=False)
      first = False
      js_type = self._TypeToJsType(namespace_name, prop.type_)
      if prop.optional:
        js_type = (Code().Append('(')
                         .Concat(js_type, new_line=False)
                         .Append('|undefined)', new_line=False))
      c.Append('%s: ' % field, strip_right=False)
      c.Concat(js_type, new_line=False)
    c.Eblock('}')
def AppendObjectDefinition ( self , c , namespace_name , properties , new_line = True ) : if not properties : return c . Sblock ( '{' , new_line = new_line ) first = True for field , prop in properties . items ( ) : if not first : c . Append ( ',' , new_line = False ) first = False js_type = self . _TypeToJsType ( namespace_name , prop . type_ ) if prop . optional : js_type = ( Code ( ) . Append ( '(' ) . Concat ( js_type , new_line = False ) . Append ( '|undefined)' , new_line = False ) ) c . Append ( '%s: ' % field , strip_right = False ) c . Concat ( js_type , new_line = False ) c . Eblock ( '}' )
Given an OrderedDict of properties, returns a Code containing the
description of an object.
Given an OrderedDict of properties returns a Code containing the description of an object .
"""Given an OrderedDict of properties, returns a Code containing the
       description of an object.
    """ # Avoid trailing comma. # TODO(devlin): This will be unneeded, if/when # https://github.com/google/closure-compiler/issues/796 is fixed.
self
c
namespace_name
properties
new_line