From d79a6e1cb0cf103ca56d7b374a1b7e2efa20571e Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 7 Feb 2024 11:20:57 -0500 Subject: [PATCH] Simplfy sorting chapters. --- mathics/doc/common_doc.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mathics/doc/common_doc.py b/mathics/doc/common_doc.py index 2dbae0b60..89284c4cb 100644 --- a/mathics/doc/common_doc.py +++ b/mathics/doc/common_doc.py @@ -1131,7 +1131,7 @@ def doc_chapter(self, module, part, builtins_by_module) -> Optional[DocChapter]: def doc_part(self, title, modules, builtins_by_module, start): """ Build documentation structure for a "Part" - Reference - section or colleciton of Mathics3 Modules. + section or collection of Mathics3 Modules. """ builtin_part = self.part_class(self, title, is_reference=start) @@ -1143,14 +1143,6 @@ def doc_part(self, title, modules, builtins_by_module, start): # packages inside ``mathics.builtin``. modules_seen = set([]) - def module_collection_fn(_) -> list: - return sorted( - modules, - key=lambda module: module.sort_order - if hasattr(module, "sort_order") - else module.__name__, - ) - def filter_toplevel_modules(module_list): """ Keep just the modules at the top level. @@ -1173,7 +1165,12 @@ def filter_toplevel_modules(module_list): # which can be decomposed in the way proposed in #984. modules = filter_toplevel_modules(modules) - for module in module_collection_fn(modules): + for module in sorted( + modules, + key=lambda module: module.sort_order + if hasattr(module, "sort_order") + else module.__name__, + ): if skip_module_doc(module, modules_seen): continue chapter = self.doc_chapter(module, builtin_part, builtins_by_module)