From d6b0f3712fe2f90c233e491ae89534d2fe500e1a Mon Sep 17 00:00:00 2001 From: Karl MacMillan Date: Thu, 9 Jun 2005 21:05:33 +0000 Subject: [PATCH] Fixed doc tool to order menus. --- refpolicy/support/sedoctool.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/refpolicy/support/sedoctool.py b/refpolicy/support/sedoctool.py index 614ecb40..1429762c 100755 --- a/refpolicy/support/sedoctool.py +++ b/refpolicy/support/sedoctool.py @@ -75,15 +75,23 @@ def gen_module_conf(doc, file): file.write("# %s\n" % line) file.write("#\n#%s\n\n" % mod_name) +def stupid_cmp(a, b): + return cmp(a[0], b[0]) + def gen_doc_menu(mod_layer, module_list): - menu = {} - for name, value in module_list.iteritems(): - if not menu.has_key(name): - menu[name] = {} - if name == mod_layer or mod_layer == None: + menu = [] + for layer, value in module_list.iteritems(): + cur_menu = (layer, []) + menu.append(cur_menu) + if layer != mod_layer and mod_layer != None: + continue #we are in our layer so fill in the other modules or we want them all - for mod, desc in value.iteritems(): - menu[name][mod] = desc + for mod, desc in value.iteritems(): + cur_menu[1].append((mod, desc)) + + menu.sort(stupid_cmp) + for x in menu: + x[1].sort(stupid_cmp) return menu def gen_docs(doc, dir, templatedir):