def write_method_doc(self, doc, out, indent): """Write processed method documentation string into `out`. The method signature is appopriately massaged. Parameters ---------- - doc : `string` The documentation string. - out : file line object. - indent : `Indent` """ orig_name = doc[2:doc.find('(')] name = camel2enthought(orig_name) my_sig = self._rename_class(doc[:doc.find('\n\n')]) my_sig = self.cpp_method_re.sub('', my_sig) my_sig = my_sig.replace('V.' + orig_name, 'V.' + name) indent.incr() out.write(indent.format('"""')) out.write(indent.format(my_sig)) ret = self._remove_sig(doc) if ret: out.write('\n') out.write(indent.format('\n' + self.massage(ret))) out.write(indent.format('"""')) indent.decr()
def write_method_doc(self, doc, out, indent): """Write processed method documentation string into `out`. The method signature is appopriately massaged. Parameters ---------- - doc : `string` The documentation string. - out : file line object. - indent : `Indent` """ orig_name = doc[2:doc.find('(')] name = camel2enthought(orig_name) my_sig = self._rename_class(doc[:doc.find('\n\n')]) my_sig = self.cpp_method_re.sub('', my_sig) my_sig = my_sig.replace('V.'+orig_name, 'V.'+name) indent.incr() out.write(indent.format('"""')) out.write(indent.format(my_sig)) ret = self._remove_sig(doc) if ret: out.write('\n') out.write(indent.format('\n'+self.massage(ret))) out.write(indent.format('"""')) indent.decr()
def _get_unique_name(self, obj): """Return a unique object name (a string). Note that this does not cache the object, so if called with the same object 3 times you'll get three different names. """ cname = obj.__class__.__name__ nm = self._name_map result = '' builtin = False if cname in __builtin__.__dict__: builtin = True if hasattr(obj, '__name__'): cname = obj.__name__ else: cname = camel2enthought(cname) special_ids = self._special_ids while len(result) == 0 or result in special_ids: if cname in nm: id = nm[cname] + 1 nm[cname] = id result = '%s%d'%(cname, id) else: nm[cname] = 0 # The first id doesn't need a number if it isn't builtin. if builtin: result = '%s0'%(cname) else: result = cname return result
def _get_unique_name(self, obj): """Return a unique object name (a string). Note that this does not cache the object, so if called with the same object 3 times you'll get three different names. """ cname = obj.__class__.__name__ nm = self._name_map result = '' builtin = False if cname in __builtin__.__dict__: builtin = True if hasattr(obj, '__name__'): cname = obj.__name__ else: cname = camel2enthought(cname) special_ids = self._special_ids while len(result) == 0 or result in special_ids: if cname in nm: id = nm[cname] + 1 nm[cname] = id result = '%s%d' % (cname, id) else: nm[cname] = 0 # The first id doesn't need a number if it isn't builtin. if builtin: result = '%s0' % (cname) else: result = cname return result
def _write_wrapper_class(self, node, tvtk_name): """Write the wrapper code to a file.""" # The only reason this method is separate is to generate code # for an individual class when debugging. fname = camel2enthought(tvtk_name) + '.py' out = open(os.path.join(self.out_dir, fname), 'w') self.wrap_gen.generate_code(node, out) out.close()
def _rename_methods(self, doc): lines = doc.split('\n') nl = [] for line in lines: words = line.split(' ') nw = [] for word in words: if word[:3] == 'vtk': nw.append(word) else: if self.func_re.search(word): nw.append(camel2enthought(word)) else: nw.append(word) nl.append(' '.join(nw)) return '\n'.join(nl)
def get_method_doc(self, doc): """Return processed method documentation string from `doc`. The method signature is appopriately massaged. Parameters ---------- - doc : `string` The documentation string. """ orig_name = doc[2:doc.find('(')] name = camel2enthought(orig_name) my_sig = self._rename_class(doc[:doc.find('\n\n')]) my_sig = self.cpp_method_re.sub('', my_sig) my_sig = my_sig.replace('V.'+orig_name, 'V.'+name) ret = self.massage(self._remove_sig(doc)) if ret: return my_sig + '\n' + ret else: return my_sig
def get_method_doc(self, doc): """Return processed method documentation string from `doc`. The method signature is appopriately massaged. Parameters ---------- - doc : `string` The documentation string. """ orig_name = doc[2:doc.find('(')] name = camel2enthought(orig_name) my_sig = self._rename_class(doc[:doc.find('\n\n')]) my_sig = self.cpp_method_re.sub('', my_sig) my_sig = my_sig.replace('V.' + orig_name, 'V.' + name) ret = self.massage(self._remove_sig(doc)) if ret: return my_sig + '\n' + ret else: return my_sig