Skip to content

Commit

Permalink
allowing load chapters for Pymathics modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Feb 5, 2024
1 parent 8170935 commit 738123e
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions mathics_django/web/controllers/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Controllers related to showing Mathics3 documentation inside Django
"""

import logging
from copy import copy
from typing import Union

Expand Down Expand Up @@ -31,12 +32,13 @@ def check_for_pymathics_load():
print("XXX refresh pymathics doc", pymathics_modules)
new_modules = pymathics_modules - seen_pymathics_modules
for new_module in new_modules:
title, _ = get_module_doc(new_module)
print("loading ", new_module)
mathics3_module_part = documentation.parts_by_slug.get(
"mathics3-modules", None
)
# If this is the first loaded module, we need to create the Part
if mathics3_module_part is None:
logging.warn("Mathics3 Module Part not loaded. Loading it")
mathics3_module_part = self.doc_part(
"Mathics3 Modules",
pymathics_modules,
Expand All @@ -46,25 +48,15 @@ def check_for_pymathics_load():
seen_pymathics_modules = copy(pymathics_modules)
return

# The part already exists. Lets add the new chapter.

chapter = mathics3_module_part.doc.gather_chapter_doc_fn(
mathics3_module_part,
title,
mathics3_module_part.doc,
)
from trepan.api import debug

debug()
submodule_names_seen = set()
chapter.doc.doc_chapter(
# The "Mathics3 modules" part already exists. Lets add the new chapter.
print("loading the new chapter")
chapter = documentation.doc_chapter(
new_module,
mathics3_module_part,
pymathics_builtins_by_module,
seen_pymathics_modules,
submodule_names_seen,
pymathics_builtins_by_module
)
chapter.get_tests()
mathics3_module_part.chapters.append(chapter)

seen_pymathics_modules = copy(pymathics_modules)
pass

Expand Down

0 comments on commit 738123e

Please sign in to comment.