Skip to content

Commit

Permalink
Simplfy sorting chapters.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Feb 7, 2024
1 parent 1cd7ae3 commit d79a6e1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions mathics/doc/common_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit d79a6e1

Please sign in to comment.