Skip to content

Commit d028b25

Browse files
committed
Revert doc.py changes to minimum...
Don't try to handle sectioning right now.
1 parent a54803e commit d028b25

1 file changed

Lines changed: 14 additions & 49 deletions

File tree

mathics/doc/doc.py

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# -*- coding: utf-8 -*-
22

3-
from html import escape as html_escape
43
import re
54
from os import getenv, listdir
65
import pickle
76
import importlib
8-
import pkgutil
97

108
from mathics import settings
9+
from html import escape as html_escape
1110

1211
from mathics import builtin
1312
from mathics.builtin import get_module_doc
@@ -111,15 +110,6 @@
111110
except IOError:
112111
xml_data = {}
113112

114-
def get_submodule_names(object):
115-
modpkgs = []
116-
if hasattr(object, '__path__'):
117-
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
118-
modpkgs.append(modname)
119-
modpkgs.sort()
120-
return modpkgs
121-
122-
123113

124114
def filter_comments(doc):
125115
return "\n".join(
@@ -252,23 +242,15 @@ def repl_list(match):
252242
[
253243
("$", r"\$"),
254244
("\u03c0", r"$\pi$"),
255-
(" ", r"$\ge$"),
256-
(" ", r"$\le$"),
257-
(" ", r"$\ne$"),
258-
245+
("≥", r"$\ge$"),
246+
("≤", r"$\le$"),
247+
("≠", r"$\ne$"),
259248
("ç", r"\c{c}"),
260249
("é", r"\'e"),
261250
("ê", r"\^e"),
262251
("ñ", r"\~n"),
263252
("∫", r"\int"),
264253
("", r"d"),
265-
# Redo above as something like:
266-
# ("\u00e7", r"\c{c}"),
267-
# ("\u00e9", r"\'e"),
268-
# ("\u00ea", r"\^e"),
269-
# ("\00f1", r"\~n"),
270-
# ("\u222b", r"\int"),
271-
# ("\uf74c", r"d"),
272254
],
273255
)
274256

@@ -495,7 +477,6 @@ def post_sub(text, post_substitutions):
495477
return text
496478

497479

498-
# FIXME: can we replace this with Python 3's html.escape ?
499480
def escape_html(text, verbatim_mode=False, counters=None, single_line=False):
500481
def repl_python(match):
501482
return (
@@ -636,7 +617,6 @@ def repl_subsection(match):
636617
text = text.replace("\\" + key, xml)
637618

638619
if not single_line:
639-
# FIXME: linebreaks() is not defined
640620
# text = linebreaks(text)
641621
text = text.replace("<br />", "\n").replace("<br>", "<br />")
642622

@@ -677,7 +657,7 @@ def get_prev_next(self):
677657
return prev, next
678658

679659
def get_title_html(self):
680-
return escape_html(self.title, single_line=True)
660+
return html_escape(self.title, single_line=True)
681661

682662

683663
class Documentation(DocElement):
@@ -811,36 +791,21 @@ def __init__(self):
811791
title, text = get_module_doc(module)
812792
chapter = DocChapter(builtin_part, title, Doc(text))
813793
builtins = builtins_by_module[module.__name__]
814-
815-
if module.__file__.endswith("__init__.py"):
816-
section_names = get_submodule_names(module)
817-
else:
818-
section_names = builtins
819-
820-
for instance in section_names:
794+
for instance in builtins:
821795
installed = True
822796
for package in getattr(instance, "requires", []):
823797
try:
824798
importlib.import_module(package)
825799
except ImportError:
826800
installed = False
827801
break
828-
if isinstance(instance, str):
829-
section = DocSection(
830-
chapter,
831-
instance,
832-
"",
833-
None,
834-
installed=installed,
835-
)
836-
else:
837-
section = DocSection(
838-
chapter,
839-
strip_system_prefix(instance.get_name()),
840-
instance.__doc__ or "",
841-
operator=instance.get_operator(),
842-
installed=installed,
843-
)
802+
section = DocSection(
803+
chapter,
804+
strip_system_prefix(instance.get_name()),
805+
instance.__doc__ or "",
806+
operator=instance.get_operator(),
807+
installed=installed,
808+
)
844809
chapter.sections.append(section)
845810
builtin_part.chapters.append(chapter)
846811
self.parts.append(builtin_part)
@@ -1205,7 +1170,7 @@ def latex(self, output):
12051170

12061171
def html(self):
12071172
counters = {}
1208-
return html_escape(
1173+
return escape_html(
12091174
"\n".join(
12101175
item.html(counters) for item in self.items if not item.is_private()
12111176
)

0 commit comments

Comments
 (0)