From aaa46a93da9dca512708908334ffcab4c0a4bf24 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Wed, 21 Oct 2020 12:25:57 +0200 Subject: [PATCH] tools: Sort menu content in Kconfig option reference --- tools/kconfig_new/gen_kconfig_doc.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/kconfig_new/gen_kconfig_doc.py b/tools/kconfig_new/gen_kconfig_doc.py index df1920e022..63aacc6f61 100644 --- a/tools/kconfig_new/gen_kconfig_doc.py +++ b/tools/kconfig_new/gen_kconfig_doc.py @@ -271,19 +271,18 @@ def write_menu_item(f, node, visibility): if is_menu: # enumerate links to child items - first = True + child_list = [] child = node.list while child: - try: - if not is_choice(child) and child.prompt and visibility.visible(child): - if first: - f.write("Contains:\n\n") - first = False - f.write('- :ref:`%s`\n' % get_link_anchor(child)) - except AttributeError: - pass + if not is_choice(child) and child.prompt and visibility.visible(child): + child_list.append((child.prompt[0], get_link_anchor(child))) child = child.next - f.write('\n') + if len(child_list) > 0: + f.write("Contains:\n\n") + sorted_child_list = sorted(child_list, key=lambda pair: pair[0].lower()) + ref_list = ['- :ref:`{}`'.format(anchor) for _, anchor in sorted_child_list] + f.write('\n'.join(ref_list)) + f.write('\n\n') if __name__ == '__main__':