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
412import sys
513import re
@@ -309,23 +317,24 @@ def test_all(
309317
310318
311319def 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
317325def 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 ("\n Aborted.\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
0 commit comments