@@ -54,6 +54,7 @@ class NeovimTypeVal:
5454 'String' : 'QByteArray' ,
5555 'Object' : 'QVariant' ,
5656 'Array' : 'QVariantList' ,
57+ 'Dictionary' : 'QVariantMap' ,
5758 }
5859 # msgpack extension types
5960 EXTTYPES = {
@@ -109,6 +110,9 @@ class Function:
109110 """
110111 Representation for a Neovim API Function
111112 """
113+
114+ # Attributes names that we support, see src/function.c for details
115+ __KNOWN_ATTRIBUTES = set (['name' , 'parameters' , 'return_type' , 'can_fail' , 'deprecated_since' , 'since' , 'method' , 'async' , 'impl_name' , 'noeval' , 'receives_channel_id' ])
112116 def __init__ (self , nvim_fun ):
113117 self .valid = False
114118 self .fun = nvim_fun
@@ -121,30 +125,41 @@ def __init__(self, nvim_fun):
121125 except UnsupportedType as ex :
122126 print ('Found unsupported type(%s) when adding function %s(), skipping' % (ex ,self .name ))
123127 return
128+
129+ u_attrs = self .unknown_attributes ()
130+ if u_attrs :
131+ print ('Found unknown attributes for function %s: %s' % (self .name , u_attrs ))
132+
124133 self .argcount = len (self .parameters )
125- self .can_fail = self .fun .get ('can_fail' , False )
126134
127135 # Build the argument string - makes it easier for the templates
128136 self .argstring = ', ' .join (['%s %s' % (tv .native_type , tv .name ) for tv in self .parameters ])
129137 self .valid = True
130138
139+ def is_method (self ):
140+ return self .fun .get ('method' , False )
141+ def is_async (self ):
142+ return self .fun .get ('async' , False )
143+ def deprecated (self ):
144+ return self .fun .get ('deprecated_since' , None )
145+
146+ def unknown_attributes (self ):
147+ attrs = set (self .fun .keys ()) - Function .__KNOWN_ATTRIBUTES
148+ return attrs
149+
131150 def real_signature (self ):
132151 params = ''
133152 for p in self .parameters :
134153 params += '%s %s' % (p .native_type , p .name )
135154 params += ', '
136155 notes = ''
137- if self .can_fail :
138- notes += '!fails'
139156 return '%s %s(%s) %s' % (self .return_type .native_type ,self .name ,params , notes )
140157 def signature (self ):
141158 params = ''
142159 for p in self .parameters :
143160 params += '%s %s' % (p .neovim_type , p .name )
144161 params += ', '
145162 notes = ''
146- if self .can_fail :
147- notes += '!fails'
148163 return '%s %s(%s) %s' % (self .return_type .neovim_type ,self .name ,params , notes )
149164
150165
@@ -160,8 +175,12 @@ def print_api(api):
160175 sig = fundef .signature ()
161176 realsig = fundef .real_signature ()
162177 print ('\t %s' % sig )
178+ deprecated = fundef .deprecated ()
179+ if deprecated :
180+ print ('\t - Deprecated: %d' % deprecated )
163181 if sig != realsig :
164- print ('\t [aka %s]\n ' % realsig )
182+ print ('\t - Native: %s\n ' % realsig )
183+
165184 print ('' )
166185 elif key == 'types' :
167186 print ('Data Types' )
@@ -176,7 +195,7 @@ def print_api(api):
176195 elif key == 'features' :
177196 pass
178197 else :
179- print ('Unknown API info attribute: %s' , key )
198+ print ('Unknown API info attribute: %s' % key )
180199
181200if __name__ == '__main__' :
182201
@@ -212,5 +231,5 @@ def print_api(api):
212231 generate_file (name , outpath , ** env )
213232
214233 else :
215- print ('Neovim api info:' )
234+ print ('API info for %s:' % nvim )
216235 print_api (api )
0 commit comments