diff --git a/mathics/doc/gather.py b/mathics/doc/gather.py index 4951ca8b6..78268e1c6 100644 --- a/mathics/doc/gather.py +++ b/mathics/doc/gather.py @@ -16,7 +16,7 @@ from mathics.core.builtin import Builtin, check_requires_list from mathics.core.util import IS_PYPY from mathics.doc.doc_entries import DocumentationEntry -from mathics.doc.structure import DocChapter, DocGuideSection, DocSection, DocSubsection +from mathics.doc.structure import DocChapter, DocGuideSection, DocSection def check_installed(src: Union[ModuleType, Builtin]) -> bool: @@ -97,9 +97,10 @@ def doc_chapter(module, part, builtins_by_module): chapter = chapter_class(part, title, doc_class(text, title, None)) part.chapters.append(chapter) + symbol_sections = gather_sections(chapter, module, builtins_by_module) assert len(chapter.sections) == 0 - - # visited = set(sec.title for sec in symbol_sections) + chapter.sections.extend(symbol_sections) + visited = set(sec.title for sec in symbol_sections) # If the module is a package, add the guides and symbols from the submodules if module.__file__.endswith("__init__.py"): guide_sections, symbol_sections = gather_guides_and_sections( @@ -113,14 +114,10 @@ def doc_chapter(module, part, builtins_by_module): else: visited.add(sec.title) chapter.sections.append(sec) - else: - symbol_sections = gather_sections(chapter, module, builtins_by_module) - chapter.sections.extend(symbol_sections) - return chapter -def gather_sections(chapter, module, builtins_by_module, section_class=None) -> list: +def gather_sections(chapter, module, builtins_by_module) -> list: """Build a list of DocSections from a "top-level" module""" symbol_sections = [] if skip_module_doc(module): @@ -128,8 +125,7 @@ def gather_sections(chapter, module, builtins_by_module, section_class=None) -> part = chapter.part if chapter else None documentation = part.documentation if part else None - if section_class is None: - section_class = documentation.section_class if documentation else DocSection + section_class = documentation.section_class if documentation else DocSection # TODO: Check the reason why for the module # `mathics.builtin.numbers.constants` @@ -168,29 +164,6 @@ def gather_sections(chapter, module, builtins_by_module, section_class=None) -> return symbol_sections -def gather_subsections(chapter, section, module, builtins_by_module) -> list: - """Build a list of DocSubsections from a "top-level" module""" - - part = chapter.part if chapter else None - documentation = part.documentation if part else None - section_class = documentation.subsection_class if documentation else DocSubsection - - def section_function( - chapter, - title, - text, - operator=None, - installed=True, - in_guide=False, - summary_text="", - ): - return section_class( - chapter, section, title, text, operator, installed, in_guide, summary_text - ) - - return gather_sections(chapter, module, builtins_by_module, section_function) - - def gather_guides_and_sections(chapter, module, builtins_by_module): """ Look at the submodules in module, and produce the guide sections @@ -218,9 +191,26 @@ def gather_guides_and_sections(chapter, module, builtins_by_module): if skip_module_doc(sub_module): continue + submodule_symbol_sections = gather_sections( + chapter, sub_module, builtins_by_module + ) + symbol_sections.extend(submodule_symbol_sections) + title, text = get_module_doc(sub_module) installed = check_installed(sub_module) + if submodule_symbol_sections: + text = text + "\n\n