Skip to content

Commit c179d30

Browse files
authored
Merge pull request #1401 from mathics/test-to-docbuild
mathics/test.py -> docbuild.py and ...
2 parents c68ce87 + 056b5f3 commit c179d30

7 files changed

Lines changed: 38 additions & 20 deletions

File tree

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ omit =
1212
mathics/doc/*
1313
mathics/builtin/pymimesniffer/*
1414
mathics/manage.py
15-
mathics/test.py
15+
mathics/docpipeline.py

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RM ?= rm
1111

1212
.PHONY: all build \
1313
check clean \
14-
develop dist doc doc-data djangotest \
14+
develop dist doctest doc-data djangotest \
1515
gstest pytest \
1616
rmChangeLog \
1717
test
@@ -73,11 +73,11 @@ gstest:
7373

7474
#: Create data that is used to in Django docs and to build TeX PDF
7575
doc-data mathics/doc/tex/doc_tex_data.pcl: mathics/builtin/*.py mathics/doc/documentation/*.mdoc mathics/doc/documentation/images/*
76-
$(PYTHON) mathics/test.py -ot -k
76+
$(PYTHON) mathics/docpipeline.py -ot -k
7777

7878
#: Run tests that appear in docstring in the code.
7979
doctest:
80-
SANDBOX=$(SANDBOX) $(PYTHON) mathics/test.py $o
80+
SANDBOX=$(SANDBOX) $(PYTHON) mathics/docpipeline.py $o
8181

8282
#: Make Mathics PDF manual
8383
doc mathics.pdf: mathics/doc/tex/doc_tex_data.pcl

admin-tools/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# Clear directory build/
66
# python setup.py develop
77
# mathics/
8-
# python test.py -o
9-
# python test.py -t
8+
# python docpipeline.py -o
9+
# python docpipeline.py -t
1010
# mathics/doc/tex/
1111
# make latex
1212
# Then run this file.

mathics/doc/doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Running LaTeX, or the tests is done elsewhere.
88
9-
See also `../test.py` for a command-line interface that calls this.
9+
See also `../docpipeline.py` for a command-line interface that calls this.
1010
1111
FIXME: Note too much of this code is duplicated in Django. Code should
1212
be moved for both to a separate package. Also, this code should be

mathics/doc/tex/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ logo-heptatom.pdf logo-text-nodrop.pdf:
2222

2323
#: The build of the documentation which is derived from docstrings in the Python code
2424
documentation.tex:
25-
(cd ../.. && $(PYTHON) test.py -ot)
25+
(cd ../.. && $(PYTHON) docpipeline.py -ot)
2626

2727
#: Same as mathics.pdf
2828
latex: mathics.pdf

mathics/test.py renamed to mathics/docpipeline.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3+
"""
4+
Does 3 things which can either be done independently or
5+
as a pipeline:
6+
7+
1. Extracts tests from static mdoc files and docstrings from Mathics built-in functions
8+
2. Creates/updates internal documentation data
9+
3. It writes the LaTeX file containing the entire User Manual
10+
"""
311

412
import sys
513
import re
@@ -309,23 +317,24 @@ def test_all(
309317

310318

311319
def load_doc_data():
312-
print(f"Loading TeX from {settings.DOC_TEX_DATA_PATH}")
320+
print(f"Loading LaTeX internal data from {settings.DOC_TEX_DATA_PATH}")
313321
with open_ensure_dir(settings.DOC_TEX_DATA_PATH, "rb") as tex_data_file:
314322
return pickle.load(tex_data_file)
315323

316324

317325
def save_doc_data(output_tex):
318-
print(f"Writing TeX to {settings.DOC_TEX_DATA_PATH}")
326+
print(f"Writing LaTeX internal data to {settings.DOC_TEX_DATA_PATH}")
319327
with open_ensure_dir(settings.DOC_TEX_DATA_PATH, "wb") as output_file:
320328
pickle.dump(output_tex, output_file, 4)
321329

322330

323-
def make_doc(quiet=False, reload=False):
331+
def extract_doc_from_source(quiet=False, reload=False):
324332
"""
325-
Write TeX doc examples.
333+
Write internal (pickled) TeX doc mdoc files and example data in docstrings.
326334
"""
327335
if not quiet:
328-
print("Extracting doc %s" % version_string)
336+
print(f"Extracting internal doc data for {version_string}")
337+
print(f"This may take a while...")
329338

330339
try:
331340
output_tex = load_doc_data() if reload else {}
@@ -335,6 +344,7 @@ def make_doc(quiet=False, reload=False):
335344
print("\nAborted.\n")
336345
return
337346

347+
print("done.\n")
338348
save_doc_data(output_tex)
339349

340350

@@ -402,27 +412,33 @@ def main():
402412
"-o",
403413
dest="output",
404414
action="store_true",
405-
help="generate TeX and XML output data",
415+
help="generate LaTeX pickled internal data",
406416
)
407417
parser.add_argument(
408418
"--doc-only",
409419
dest="doc_only",
410420
action="store_true",
411-
help="generate TeX output data without running tests",
421+
help="generate LaTeX pickled internal data without running tests; Can't be used with --section or --reload.",
422+
)
423+
parser.add_argument(
424+
"--latex-only",
425+
dest="latex_only",
426+
action="store_true",
427+
help="generate LaTeX output from internal data without running tests; assumes --reload",
412428
)
413429
parser.add_argument(
414430
"--reload",
415431
"-r",
416432
dest="reload",
417433
action="store_true",
418-
help="reload TeX data",
434+
help="reload LaTeX pickled internal data, before possibly adding to it",
419435
)
420436
parser.add_argument(
421437
"--tex",
422438
"-t",
423439
dest="tex",
424440
action="store_true",
425-
help="generate TeX documentation file",
441+
help="include LaTeX document generation file at the end of other steps",
426442
)
427443
parser.add_argument(
428444
"--quiet", "-q", dest="quiet", action="store_true", help="hide passed tests"
@@ -473,10 +489,12 @@ def main():
473489
if args.pymathics:
474490
print("Building pymathics documentation object")
475491
documentation.load_pymathics_doc()
492+
elif args.latex_only:
493+
write_latex()
476494
elif args.doc_only:
477-
make_doc(
495+
extract_doc_from_source(
478496
quiet=args.quiet,
479-
reload=args.reload,
497+
reload=False,
480498
)
481499
else:
482500
start_at = args.skip + 1

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ deps =
1919

2020
commands =
2121
python setup.py test
22-
python mathics/test.py
22+
python mathics/docpipeline.py
2323

2424
install_command =
2525
pip install --pre {opts} {packages}

0 commit comments

Comments
 (0)