def process_type_name(type_node): decl = CL.jump_to_declaration(type_node) def decay(s) : for tok in ['const ', 'const&', '&&', '&'] : s = re.sub(tok,'',s) return s.strip() def clean_ns(s): for x in global_vars.process_type_name_ns_to_clean: s = re.sub(x, '', s) return s # Remove the namespace # replace const A & by A const & t_name = clean_ns(type_node.spelling) t_name = re.sub(r'const ([^&]*) &', r'\1 const &', t_name) # try to see if decl is in the known list class_list = global_vars.synopsis_class_list if decl in class_list: cls_idx = class_list.index(decl) cls = class_list[cls_idx] part_to_labelize = clean_ns(decay(t_name)) label = cls.name_for_label # First version is just the full name, with namespace # t_name = t_name.replace(part_to_labelize,":ref:`%s`"%(label)) t_name = t_name.replace(part_to_labelize,":ref:`%s <%s>`"%(escape_lg(part_to_labelize),label)) return t_name
def process_type_name(type_node): decl = CL.jump_to_declaration(type_node) def decay(s): for tok in ['const ', 'const&', '&&', '&']: s = re.sub(tok, '', s) return s.strip() def clean_ns(s): for x in global_vars.process_type_name_ns_to_clean: s = re.sub(x, '', s) return s # Remove the namespace # replace const A & by A const & t_name = clean_ns(type_node.spelling) t_name = re.sub(r'const ([^&]*) &', r'\1 const &', t_name) # try to see if decl is in the known list class_list = global_vars.synopsis_class_list if decl in class_list: cls_idx = class_list.index(decl) cls = class_list[cls_idx] part_to_labelize = clean_ns(decay(t_name)) label = cls.name_for_label # First version is just the full name, with namespace # t_name = t_name.replace(part_to_labelize,":ref:`%s`"%(label)) t_name = t_name.replace( part_to_labelize, ":ref:`%s <%s>`" % (escape_lg(part_to_labelize), label)) return t_name
def get_decl_param_class(f): """ Given a node f of a function, returns the node of declaration of the param class or None""" if 'use_parameter_class' not in CL.get_annotations(f) : return None p = list(CL.get_params(f)) assert len(p) == 1, "A function/method with PARAM technique must have exacly one parameter" return CL.jump_to_declaration(p[0].type)
def get_decl_param_class(f): """ Given a node f of a function, returns the node of declaration of the param class or None""" if 'use_parameter_class' not in CL.get_annotations(f): return None p = list(CL.get_params(f)) assert len( p ) == 1, "A function/method with PARAM technique must have exacly one parameter" return CL.jump_to_declaration(p[0].type)