tools/json_schema_compiler/js_util.py
def AppendFunctionJsDoc(self, c, namespace_name, function):
    """Appends the documentation for a function as a Code.

    Returns an empty code object if the object has no documentation.
    """
    c.Sblock(line='/**', line_prefix=' * ')

    if function.description:
      c.Comment(function.description, comment_prefix='')

    def append_field(c, tag, js_type, name, optional, description):
      c.Append('@%s {' % tag)
      c.Concat(js_type, new_line=False)
      if optional:
        c.Append('=', new_line=False)
      c.Append('}', new_line=False)
      c.Comment(' %s' % name, comment_prefix='', wrap_indent=4, new_line=False)
      if description:
        c.Comment(' %s' % description, comment_prefix='',
                  wrap_indent=4, new_line=False)

    for i, param in enumerate(function.params):
      # Mark the parameter as optional, *only if* all following parameters are
      # also optional, to avoid JSC_OPTIONAL_ARG_AT_END errors thrown by Closure
      # Compiler.
      optional = (
          all(p.optional for p in function.params[i:]) and
          (function.returns_async is None or function.returns_async.optional))
      js_type = self._TypeToJsType(namespace_name, param.type_)

      # If the parameter was originally optional, but was followed by
      # non-optional parameters, allow it to be `null` or `undefined` instead.
      if not optional and param.optional:
        js_type_string = js_type.Render()

        # Remove the leading "!" from |js_type_string| if it exists, since "?!"
        # is not a valid type modifier.
        if js_type_string.startswith('!'):
          js_type_string = js_type_string[1:]
        js_type = Code().Append('?%s|undefined' % js_type_string)

      append_field(c, 'param', js_type, param.name, optional, param.description)

    if function.returns_async:
      append_field(
          c, 'param',
          self._ReturnsAsyncToJsFunction(namespace_name,
                                         function.returns_async),
          function.returns_async.name, function.returns_async.optional,
          function.returns_async.description)

    if function.returns:
      append_field(c, 'return',
                   self._TypeToJsType(namespace_name, function.returns),
                   '', False, function.returns.description)

    if function.deprecated:
      c.Append('@deprecated %s' % function.deprecated)

    self.AppendSeeLink(c, namespace_name, 'method', function.name)

    c.Eblock(' */')
Appends the documentation for a function as a Code.

    Returns an empty code object if the object has no documentation.
    
Appends the documentation for a function as a Code.
Returns an empty code object if the object has no documentation.
Appends the documentation for a function as a Code . Returns an empty code object if the object has no documentation .
def AppendFunctionJsDoc(self, c, namespace_name, function):
    c.Sblock(line='/**', line_prefix=' * ')
    if function.description:
      c.Comment(function.description, comment_prefix='')
    def append_field(c, tag, js_type, name, optional, description):
      c.Append('@%s {' % tag)
      c.Concat(js_type, new_line=False)
      if optional:
        c.Append('=', new_line=False)
      c.Append('}', new_line=False)
      c.Comment(' %s' % name, comment_prefix='', wrap_indent=4, new_line=False)
      if description:
        c.Comment(' %s' % description, comment_prefix='',
                  wrap_indent=4, new_line=False)
    for i, param in enumerate(function.params):
      optional = (
          all(p.optional for p in function.params[i:]) and
          (function.returns_async is None or function.returns_async.optional))
      js_type = self._TypeToJsType(namespace_name, param.type_)
      if not optional and param.optional:
        js_type_string = js_type.Render()
        if js_type_string.startswith('!'):
          js_type_string = js_type_string[1:]
        js_type = Code().Append('?%s|undefined' % js_type_string)
      append_field(c, 'param', js_type, param.name, optional, param.description)
    if function.returns_async:
      append_field(
          c, 'param',
          self._ReturnsAsyncToJsFunction(namespace_name,
                                         function.returns_async),
          function.returns_async.name, function.returns_async.optional,
          function.returns_async.description)
    if function.returns:
      append_field(c, 'return',
                   self._TypeToJsType(namespace_name, function.returns),
                   '', False, function.returns.description)
    if function.deprecated:
      c.Append('@deprecated %s' % function.deprecated)
    self.AppendSeeLink(c, namespace_name, 'method', function.name)
    c.Eblock(' */')
def AppendFunctionJsDoc ( self , c , namespace_name , function ) : c . Sblock ( line = '/**' , line_prefix = ' * ' ) if function . description : c . Comment ( function . description , comment_prefix = '' ) def append_field ( c , tag , js_type , name , optional , description ) : c . Append ( '@%s {' % tag ) c . Concat ( js_type , new_line = False ) if optional : c . Append ( '=' , new_line = False ) c . Append ( '}' , new_line = False ) c . Comment ( ' %s' % name , comment_prefix = '' , wrap_indent = 4 , new_line = False ) if description : c . Comment ( ' %s' % description , comment_prefix = '' , wrap_indent = 4 , new_line = False ) for i , param in enumerate ( function . params ) : optional = ( all ( p . optional for p in function . params [ i : ] ) and ( function . returns_async is None or function . returns_async . optional ) ) js_type = self . _TypeToJsType ( namespace_name , param . type_ ) if not optional and param . optional : js_type_string = js_type . Render ( ) if js_type_string . startswith ( '!' ) : js_type_string = js_type_string [ 1 : ] js_type = Code ( ) . Append ( '?%s|undefined' % js_type_string ) append_field ( c , 'param' , js_type , param . name , optional , param . description ) if function . returns_async : append_field ( c , 'param' , self . _ReturnsAsyncToJsFunction ( namespace_name , function . returns_async ) , function . returns_async . name , function . returns_async . optional , function . returns_async . description ) if function . returns : append_field ( c , 'return' , self . _TypeToJsType ( namespace_name , function . returns ) , '' , False , function . returns . description ) if function . deprecated : c . Append ( '@deprecated %s' % function . deprecated ) self . AppendSeeLink ( c , namespace_name , 'method' , function . name ) c . Eblock ( ' */' )
Appends the documentation for a function as a Code.
Appends the documentation for a function as a Code .
"""Appends the documentation for a function as a Code.

    Returns an empty code object if the object has no documentation.
    """ # Mark the parameter as optional, *only if* all following parameters are # also optional, to avoid JSC_OPTIONAL_ARG_AT_END errors thrown by Closure # Compiler. # If the parameter was originally optional, but was followed by # non-optional parameters, allow it to be `null` or `undefined` instead. # Remove the leading "!" from |js_type_string| if it exists, since "?!" # is not a valid type modifier.
self
c
namespace_name
function