Skip to content

Commit

Permalink
Merge branch 'more_docpipeline_fixes' into RsT_urls
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera authored Mar 30, 2024
2 parents bbb19cd + ceb48c0 commit b0bb40c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
4 changes: 3 additions & 1 deletion mathics/builtin/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,9 @@ class RealValuedNumberQ(Builtin):
# No docstring since this is internal and it will mess up documentation.
# FIXME: Perhaps in future we will have a more explicite way to indicate not
# to add something to the docs.
no_doc = True
context = "Internal`"

summary_text = "test whether an expression is a real number"
rules = {
"Internal`RealValuedNumberQ[x_Real]": "True",
"Internal`RealValuedNumberQ[x_Integer]": "True",
Expand All @@ -639,6 +640,7 @@ class RealValuedNumericQ(Builtin):
# No docstring since this is internal and it will mess up documentation.
# FIXME: Perhaps in future we will have a more explicite way to indicate not
# to add something to the docs.
no_doc = True
context = "Internal`"

rules = {
Expand Down
4 changes: 3 additions & 1 deletion mathics/doc/doc_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ def get_results_by_test(test_expr: str, full_test_key: list, doc_data: dict) ->
if result_candidate["query"] == test_expr:
if result:
# Already found something
print(f"Warning, multiple results appear under {search_key}.")
logging.warning(
f"Warning, multiple results appear under {search_key}."
)
return {}

result = result_candidate
Expand Down
2 changes: 1 addition & 1 deletion mathics/doc/documentation/1-Manual.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ The relative uncertainty of '3.1416`3' is 10^-3. It is numerically equivalent, i
>> 3.1416`3 == 3.1413`4
= True

We can get the precision of the number by using the \Mathics Built-in function <url>:'Precision': /doc/reference-of-built-in-symbols/atomic-elements-of-expressions/representation-of-numbers/precision/</url>:
We can get the precision of the number by using the \Mathics Built-in function <url>:'Precision': /doc/reference-of-built-in-symbols/atomic-elements-of-expressions/precision</url>:

>> Precision[3.1413`4]
= 4.
Expand Down
18 changes: 15 additions & 3 deletions mathics/doc/latex_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def repl_hypertext(match) -> str:
# then is is a link to a section
# in this manual, so use "\ref" rather than "\href'.
if content.find("/doc/") == 0:
slug = "/".join(content.split("/")[2:]).rstrip("/")
return "%s \\ref{%s}" % (text, latex_label_safe(slug))
slug = "/".join(content.split("/")[2:]).rstrip("/")
return "%s of section~\\ref{%s}" % (text, latex_label_safe(slug))
else:
Expand Down Expand Up @@ -647,6 +649,16 @@ def latex(
("\n\n\\chapter{%(title)s}\n\\chapterstart\n\n%(intro)s")
% {"title": escape_latex(self.title), "intro": intro},
"\\chaptersections\n",
# ####################
"\n\n".join(
section.latex(doc_data, quiet)
# Here we should use self.all_sections, but for some reason
# guidesections are not properly loaded, duplicating
# the load of subsections.
for section in sorted(self.guide_sections)
if not filter_sections or section.title in filter_sections
),
# ###################
"\n\n".join(
section.latex(doc_data, quiet)
# Here we should use self.all_sections, but for some reason
Expand Down Expand Up @@ -725,11 +737,11 @@ def latex(self, doc_data: dict, quiet=False) -> str:
sections = "\n\n".join(section.latex(doc_data) for section in self.subsections)
slug = f"{self.chapter.part.slug}/{self.chapter.slug}/{self.slug}"
section_string = (
"\n\n\\section*{%s}{%s}\n" % (title, index)
"\n\n\\section{%s}{%s}\n" % (title, index)
+ "\n\\label{%s}" % latex_label_safe(slug)
+ "\n\\sectionstart\n\n"
+ f"{content}"
+ ("\\addcontentsline{toc}{section}{%s}" % title)
# + ("\\addcontentsline{toc}{section}{%s}" % title)
+ sections
+ "\\sectionend"
)
Expand Down Expand Up @@ -788,7 +800,7 @@ def latex(self, doc_data: dict, quiet=False) -> str:
guide_sections = [
(
"\n\n\\section{%(title)s}\n\\sectionstart\n\n%(intro)s"
"\\addcontentsline{toc}{section}{%(title)s}"
# "\\addcontentsline{toc}{section}{%(title)s}"
)
% {"title": escape_latex(self.title), "intro": intro},
"\n\n".join(section.latex(doc_data) for section in self.subsections),
Expand Down
11 changes: 6 additions & 5 deletions test/doc/test_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_load_latex_documentation():
).strip() == "Let's sketch the function\n\\begin{tests}"
assert (
first_section.latex(doc_data)[:30]
).strip() == "\\section*{Curve Sketching}{}"
).strip() == "\\section{Curve Sketching}{}"
assert (
third_chapter.latex(doc_data)[:38]
).strip() == "\\chapter{Further Tutorial Examples}"
Expand All @@ -102,10 +102,11 @@ def test_chapter():
chapter = part.chapters_by_slug["testing-expressions"]
print(chapter.sections_by_slug.keys())
section = chapter.sections_by_slug["numerical-properties"]
latex_section_head = section.latex({})[:63].strip()
assert (
latex_section_head
== "\section*{Numerical Properties}{\index{Numerical Properties}}"
latex_section_head = section.latex({})[:90].strip()
assert latex_section_head == (
"\\section{Numerical Properties}\n"
"\\sectionstart\n\n\n\n"
"\\subsection*{CoprimeQ}\index{CoprimeQ}"
)
print(60 * "@")
latex_chapter = chapter.latex({}, quiet=False)
Expand Down

0 comments on commit b0bb40c

Please sign in to comment.