Skip to content

Commit 98bb52f

Browse files
mmaterarocky
andauthored
Fixing JS search (#205)
* Bump copyright * Changes to go track changes in core PR #984 * Get Mathics3 Modules to loading properly ... This needs the doc-code-rebased-rebased branch of Mathics core. * improving_guide_handling * last fixes * black * fixes * black * windows workflow * init for DjangoDocGuideSection * black * documentation.doc_chapter -> mathics.doc.gather.doc_chapter * pointing now to master * mathics-core.master docpipeline compatibility * black * increasing python version in workflow * llvm in osx workflow * not load modules chapter twice * cleaning unused libraries. Automatic reload docs when the window is open. * fix typos found by rocky and codespell. * redirecting mathics-core branch in workflows * workflows * adding comments. More docstrings * fix search * restore unchanged files... * Add guide section to search... (#208) and other small tweaks --------- Co-authored-by: rocky <rb@dustyfeet.com> Co-authored-by: R. Bernstein <rocky@users.noreply.github.com>
1 parent 413ae76 commit 98bb52f

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

mathics_django/doc/django_doc.py

+7
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ def search_sections(section, result):
148148
result.append((True, section))
149149
continue
150150
search_sections(section, result)
151+
for section in chapter.guide_sections:
152+
if matches(section.title):
153+
result.append((section.title == query, section))
154+
elif query == section.operator:
155+
result.append((True, section))
156+
continue
157+
search_sections(section, result)
151158

152159
sorted_results = sorted(result, key=name_compare_goodness)
153160
return sorted_results

mathics_django/web/controllers/doc.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ def check_for_new_load_modules():
3939
MATHICS3_MODULES_SLUG, None
4040
)
4141
if mathics3_module_part is None:
42-
print("Something is wrong: mathics3_module variable should not be None")
42+
print(
43+
"Something is wrong: mathics3_module_part variable should not be None"
44+
)
4345

4446
# The "Mathics3 modules" part already exists; add the new chapters.
4547
new_modules = pymathics_modules - seen_pymathics_modules
4648
for new_module in new_modules:
47-
chapter = gather_doc_chapter(
49+
gather_doc_chapter(
4850
new_module, mathics3_module_part, pymathics_builtins_by_module
4951
)
50-
# mathics3_module_part.chapters.append(chapter)
5152
seen_pymathics_modules = copy(pymathics_modules)
5253
return
5354

@@ -65,7 +66,9 @@ def doc(request: WSGIRequest, ajax: bool = False) -> DocResponse:
6566
)
6667

6768

68-
def doc_chapter(request: WSGIRequest, part, chapter, ajax: bool = False) -> DocResponse:
69+
def doc_chapter(
70+
request: WSGIRequest, part: str, chapter: str, ajax: bool = False
71+
) -> DocResponse:
6972
"""
7073
Produces HTML via jinja templating for a chapter. Some examples of
7174
Chapters:
@@ -89,7 +92,7 @@ def doc_chapter(request: WSGIRequest, part, chapter, ajax: bool = False) -> DocR
8992
)
9093

9194

92-
def doc_part(request: WSGIRequest, part, ajax: bool = False) -> DocResponse:
95+
def doc_part(request: WSGIRequest, part: str, ajax: bool = False) -> DocResponse:
9396
"""
9497
Produces HTML via jinja templating for a Part - the top-most
9598
subdivision of the document. Some examples of Parts:

mathics_django/web/media/js/doc.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ let docLoaded = false, lastSearchValue = '';
22

33
function showPage(response) {
44
const doc = document.getElementById('doc');
5-
65
if (doc) {
76
doc.innerHTML = response.content;
87
}
@@ -61,7 +60,6 @@ function loadDoc(page) {
6160

6261
function showDoc() {
6362
const docLink = document.getElementById('doclink');
64-
loadDoc('');
6563

6664
document.getElementById('doc').style.display = 'block';
6765

@@ -98,6 +96,7 @@ function toggleDoc() {
9896
if (document.getElementById('doc').style.display !== 'none') {
9997
hideDoc();
10098
} else {
99+
loadDoc("/");
101100
showDoc();
102101
}
103102

0 commit comments

Comments
 (0)