-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compatibility with mathics-core PR 986 #201
Changes from all commits
bcd523c
9572a48
6e85fbe
2142048
8170935
48fc421
103ee46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
from django.core.handlers.wsgi import WSGIRequest | ||
from django.http import Http404, HttpResponse | ||
from django.shortcuts import render | ||
from mathics.eval.pymathics import pymathics_modules | ||
from mathics.doc.common_doc import get_module_doc | ||
from mathics.eval.pymathics import pymathics_builtins_by_module, pymathics_modules | ||
|
||
from mathics_django.doc import documentation | ||
from mathics_django.doc.django_doc import ( | ||
|
@@ -21,12 +22,37 @@ | |
|
||
DocResponse = Union[HttpResponse, JsonResponse] | ||
|
||
seen_pymathics_modules = copy(pymathics_modules) | ||
|
||
|
||
def check_for_pymathics_load(): | ||
global seen_pymathics_modules | ||
if seen_pymathics_modules != pymathics_modules: | ||
# print("XXX refresh pymathics doc") | ||
global documentation | ||
documentation = MathicsDjangoDocumentation() | ||
print("XXX refresh pymathics doc", pymathics_modules) | ||
new_modules = pymathics_modules - seen_pymathics_modules | ||
for new_module in new_modules: | ||
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't have to be in a for loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right. |
||
mathics3_module_part = self.doc_part( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have incorporated the good parts of this PR into #202 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, it was a cut-and-paste error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"Mathics3 Modules", | ||
pymathics_modules, | ||
pymathics_builtins_by_module, | ||
True, | ||
) | ||
seen_pymathics_modules = copy(pymathics_modules) | ||
return | ||
|
||
# The "Mathics3 modules" part already exists. Lets add the new chapter. | ||
chapter = documentation.doc_chapter( | ||
new_module, mathics3_module_part, pymathics_builtins_by_module | ||
) | ||
mathics3_module_part.chapters.append(chapter) | ||
|
||
seen_pymathics_modules = copy(pymathics_modules) | ||
pass | ||
|
||
|
||
def doc(request: WSGIRequest, ajax: bool = False) -> DocResponse: | ||
|
@@ -44,7 +70,9 @@ def doc(request: WSGIRequest, ajax: bool = False) -> DocResponse: | |
|
||
def doc_chapter(request: WSGIRequest, part, chapter, ajax: bool = False) -> DocResponse: | ||
""" | ||
Produces HTML via jinja templating for a chapter. Some examples of Chapters: | ||
Produces HTML via jinja templating for a chapter. Some examples of | ||
Chapters: | ||
|
||
* Introduction (in part Manual) | ||
* Procedural Programming (in part Reference of Built-in Symbols) | ||
""" | ||
|
@@ -87,9 +115,6 @@ def doc_part(request: WSGIRequest, part, ajax: bool = False) -> DocResponse: | |
) | ||
|
||
|
||
seen_pymathics_modules = copy(pymathics_modules) | ||
|
||
|
||
def doc_search(request: WSGIRequest) -> DocResponse: | ||
check_for_pymathics_load() | ||
query = request.GET.get("query", "") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about this. I forgot to comment it out again.