def examples_menu(root_dir=None, depth=<NUM_LIT:0>):
<EOL>examples_dir = ide_utils.get_example_dir()<EOL>if not examples_dir:<EOL><INDENT>return "<STR_LIT>", [], []<EOL><DEDENT>root_dir = root_dir or examples_dir<EOL>file_tmpl = '<STR_LIT>'<EOL>dir_tmpl = '<STR_LIT>'<EOL>file_actions = []<EOL>submenu_actions = []<EOL>xml = "<STR_LIT>"<EOL>for fn in sorted(os.listdir(root_dir)):<EOL><INDENT>path = os.path.join(root_dir, fn)<EOL>rel_path = path[len(examples_dir):]<EOL>if os.path.isdir(path):<EOL><INDENT>action = '<STR_LIT>'.format(rel_path)<EOL>label = fn.capitalize()<EOL>sm_xml, sm_file_actions, sm_menu_actions = examples_menu(os.path.join(root_dir, fn), depth+<NUM_LIT:1>)<EOL>submenu_actions.extend(sm_menu_actions)<EOL>file_actions.extend(sm_file_actions)<EOL>submenu_actions.append((action, label))<EOL>xml += dir_tmpl.format(name=fn, action=action, menu=sm_xml)<EOL><DEDENT>elif os.path.splitext(path)[<NUM_LIT:1>] in ['<STR_LIT>', '<STR_LIT>'] and not fn.startswith('<STR_LIT:_>'):<EOL><INDENT>action = '<STR_LIT>'.format(rel_path)<EOL>label = ide_utils.make_readable_filename(fn)<EOL>xml += file_tmpl.format(name=fn, action=action)<EOL>file_actions.append((action, label))<EOL><DEDENT><DEDENT>return xml, file_actions, submenu_actions<EOL>
:return: xml for menu, [(bot_action, label), ...], [(menu_action, label), ...]