Skip to content

Commit ccc6848

Browse files
authored
Merge pull request #1410 from mathics/administrivia
Sync docpipeline
2 parents a6ec8da + e9ccd98 commit ccc6848

5 files changed

Lines changed: 41 additions & 17 deletions

File tree

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ before_install:
2020
- python travis.py
2121
- pip install cython
2222
install:
23-
- sed -i "s/'sympy==[0-9]\.[0-9]\.[0-9]', //" setup.py
24-
- make develop
23+
- make develop-full
2524
script:
2625
- make -j3 doc
2726
notifications:

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ gstest:
7575
doc-data mathics/doc/tex/doc_tex_data.pcl: mathics/builtin/*.py mathics/doc/documentation/*.mdoc mathics/doc/documentation/images/*
7676
$(PYTHON) mathics/docpipeline.py -ot -k
7777

78+
#: Run tests that appear in docstring in the code.
79+
doctest-workaround:
80+
SANDBOX=$(SANDBOX) $(PYTHON) mathics/docpipeline.py --exclude=NIntegrate,MaxRecursion
81+
SANDBOX=$(SANDBOX) $(PYTHON) mathics/docpipeline.py --sections=NIntegrate,MaxRecursion
82+
7883
#: Run tests that appear in docstring in the code.
7984
doctest:
8085
SANDBOX=$(SANDBOX) $(PYTHON) mathics/docpipeline.py $o

mathics/docpipeline.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Does 3 things which can either be done independently or
55
as a pipeline:
66
7-
1. Extracts tests from static mdoc files and docstrings from Mathics built-in functions
7+
1. Extracts tests and runs them from static mdoc files and docstrings from Mathics built-in functions
88
2. Creates/updates internal documentation data
99
3. It writes the LaTeX file containing the entire User Manual
1010
"""
@@ -148,12 +148,20 @@ def fail(why):
148148

149149

150150
def test_tests(
151-
tests, index, quiet=False, stop_on_failure=False, start_at=0, max_tests=MAX_TESTS
151+
tests,
152+
index,
153+
quiet=False,
154+
stop_on_failure=False,
155+
start_at=0,
156+
max_tests=MAX_TESTS,
157+
excludes=[],
152158
):
153159
definitions.reset_user_definitions()
154160
total = failed = skipped = 0
155161
failed_symbols = set()
156162
section = tests.section
163+
if section in excludes:
164+
return total, failed, len(tests.tests), failed_symbols, index
157165
count = 0
158166
for subindex, test in enumerate(tests.tests):
159167
index += 1
@@ -177,21 +185,22 @@ def test_tests(
177185
return total, failed, skipped, failed_symbols, index
178186

179187

180-
def create_output(tests, output_tex):
188+
# FIXME: move this to common routine
189+
def create_output(tests, output, format="tex"):
181190
definitions.reset_user_definitions()
182191
for test in tests.tests:
183192
if test.private:
184193
continue
185194
key = test.key
186195
evaluation = Evaluation(
187-
definitions, format="tex", catch_interrupt=False, output=TestOutput()
196+
definitions, format=format, catch_interrupt=False, output=TestOutput()
188197
)
189198
result = evaluation.parse_evaluate(test.test)
190199
if result is None:
191200
result = []
192201
else:
193202
result = [result.get_data()]
194-
output_tex[key] = {
203+
output[key] = {
195204
"query": test.test,
196205
"results": result,
197206
}
@@ -245,13 +254,13 @@ def test_all(
245254
stop_on_failure=False,
246255
start_at=0,
247256
count=MAX_TESTS,
248-
xmldatafolder=None,
249257
texdatafolder=None,
250258
doc_even_if_error=False,
259+
excludes=[],
251260
):
252261
global documentation
253262
if not quiet:
254-
print("Testing %s" % version_string)
263+
print(f"Testing {version_string}")
255264

256265
if generate_output:
257266
if texdatafolder is None:
@@ -260,7 +269,6 @@ def test_all(
260269
index = 0
261270
total = failed = skipped = 0
262271
failed_symbols = set()
263-
output_xml = {}
264272
output_tex = {}
265273
for tests in documentation.get_tests():
266274
sub_total, sub_failed, sub_skipped, symbols, index = test_tests(
@@ -270,6 +278,7 @@ def test_all(
270278
stop_on_failure=stop_on_failure,
271279
start_at=start_at,
272280
max_tests=count,
281+
excludes=excludes,
273282
)
274283
if generate_output:
275284
create_output(tests, output_tex)
@@ -334,7 +343,7 @@ def extract_doc_from_source(quiet=False, reload=False):
334343
"""
335344
if not quiet:
336345
print(f"Extracting internal doc data for {version_string}")
337-
print(f"This may take a while...")
346+
print("This may take a while...")
338347

339348
try:
340349
output_tex = load_doc_data() if reload else {}
@@ -385,6 +394,15 @@ def main():
385394
help="only test SECTION(s). "
386395
"You can list multiple sections by adding a comma (and no space) in between section names.",
387396
)
397+
parser.add_argument(
398+
"--exclude",
399+
"-X",
400+
default="",
401+
dest="exclude",
402+
metavar="SECTION",
403+
help="excude SECTION(s). "
404+
"You can list multiple sections by adding a comma (and no space) in between section names.",
405+
)
388406
parser.add_argument(
389407
"--logfile",
390408
"-f",
@@ -497,6 +515,7 @@ def main():
497515
reload=False,
498516
)
499517
else:
518+
excludes = set(args.exclude.split(","))
500519
start_at = args.skip + 1
501520
start_time = datetime.now()
502521
test_all(
@@ -506,6 +525,7 @@ def main():
506525
start_at=start_at,
507526
count=args.count,
508527
doc_even_if_error=args.keep_going,
528+
excludes=excludes,
509529
)
510530
end_time = datetime.now()
511531
print("Tests took ", end_time - start_time)

mathics/formatter/svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def polygonbox(self, **options):
308308
" ".join("%f,%f" % coords.pos() for coords in line),
309309
style,
310310
)
311-
# print("XXX PolygonBox", svg)
311+
print("XXX PolygonBox", svg)
312312
return svg
313313

314314

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ def read(*rnames):
5656
# stores __version__ in the current namespace
5757
exec(compile(open("mathics/version.py").read(), "mathics/version.py", "exec"))
5858

59-
extra_requires = []
59+
extras_require = []
6060
for line in open("requirements-extra.txt").read().split("\n"):
6161
if line and not line.startswith("#"):
6262
requires = re.sub(r"([^#]+)(\s*#.*$)?", r"\1", line)
63-
extra_requires.append(requires)
63+
extras_require.append(requires)
6464

65-
EXTRA_REQUIRES = {
66-
"full": extra_requires
65+
EXTRAS_REQUIRE = {
66+
"full": extras_require
6767
}
6868

6969
DEPENDENCY_LINKS = [
@@ -151,7 +151,7 @@ def subdirs(root, file="*.*", depth=10):
151151
"mathics.formatter",
152152
],
153153
install_requires=INSTALL_REQUIRES,
154-
extra_requires=EXTRA_REQUIRES,
154+
extras_require=EXTRAS_REQUIRE,
155155
dependency_links=DEPENDENCY_LINKS,
156156
package_data={
157157
"mathics": [

0 commit comments

Comments
 (0)