Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/sphinx-docs/build_sphinx.py

    r6e546f8 r4abc05d8  
    1818from distutils.dir_util import copy_tree 
    1919from distutils.util import get_platform 
    20 from distutils.spawn import find_executable 
    21  
    2220from shutil import copy 
    2321from os import listdir 
     
    326324        print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 
    327325 
     326 
    328327def retrieve_bumps_docs(): 
    329328    """ 
     
    361360                     SASVIEW_BUILD]) 
    362361 
    363 def build_pdf(): 
    364     """ 
    365     Runs sphinx-build for pdf.  Reads in all .rst files and spits out the final html. 
    366     """ 
    367     print("=== Build PDF Docs from ReST Files ===") 
    368     subprocess.call(["sphinx-build", 
    369                      "-b", "latex", # Builder name. TODO: accept as arg to setup.py. 
    370                      "-d", os.path.join(SPHINX_BUILD, "doctrees"), 
    371                      SPHINX_SOURCE, 
    372                      os.path.join(SPHINX_BUILD, "latex")]) 
    373  
    374     LATEXDIR = os.path.join(SPHINX_BUILD, "latex") 
    375     #TODO: Does it need to be done so many time? 
    376     def pdflatex(): 
    377         subprocess.call(["pdflatex", "SasView.tex"], cwd=LATEXDIR) 
    378     pdflatex() 
    379     pdflatex() 
    380     pdflatex() 
    381     subprocess.call(["makeindex", "-s", "python.ist", "SasView.idx"], cwd=LATEXDIR) 
    382     pdflatex() 
    383     pdflatex() 
    384  
    385     print("=== Copy PDF to HTML Directory ===") 
    386     source = os.path.join(LATEXDIR, "SasView.pdf") 
    387     target = os.path.join(SASVIEW_DOCS, "SasView.pdf") 
    388     shutil.copyfile(source, target) 
    389  
    390362def build(): 
    391363    """ 
    392364    Runs sphinx-build.  Reads in all .rst files and spits out the final html. 
    393365    """ 
    394     print("=== Build HTML Docs from ReST Files ===") 
     366    print("=== Build HTML Docs from Rest Files ===") 
    395367    subprocess.call(["sphinx-build", 
    396368                     "-b", "html", # Builder name. TODO: accept as arg to setup.py. 
     
    403375    copy_tree(html, SASVIEW_DOCS) 
    404376 
    405 def fetch_katex(version, destination="_static"): 
    406     from zipfile import ZipFile 
    407     import urllib2 
    408     url = "https://github.com/Khan/KaTeX/releases/download/%s/katex.zip" % version 
    409     cache_path = "katex_%s.zip" % version 
    410     if not os.path.exists(cache_path): 
    411         try: 
    412             fd_in = urllib2.urlopen(url) 
    413             with open(cache_path, "wb") as fd_out: 
    414                 fd_out.write(fd_in.read()) 
    415         finally: 
    416             fd_in.close() 
    417     with ZipFile(cache_path) as zip: 
    418         zip.extractall(destination) 
    419  
    420 def convert_katex(): 
    421     print("=== Preprocess HTML, converting latex to html ===") 
    422     subprocess.call(["node", "convertKaTex.js", SASVIEW_DOCS]) 
    423  
    424 def convert_mathjax(): 
    425     print("=== Preprocess HTML, converting latex to html ===") 
    426     subprocess.call(["node", "convertMathJax.js", SASVIEW_DOCS]) 
    427  
    428 def fetch_mathjax(): 
    429     subprocess.call(["npm", "install", "mathjax-node-page"]) 
    430     # TODO: copy fonts from node_modules/mathjax/fonts/HTML-CSS/Tex into static 
    431  
    432377def rebuild(): 
    433378    clean() 
     
    435380    retrieve_user_docs() 
    436381    retrieve_bumps_docs() 
    437     #fetch_katex(version=KATEX_VERSION, destination=KATEX_PARENT) 
    438     #fetch_mathjax() 
    439382    apidoc() 
    440383    build() 
    441     if find_executable('latex'): 
    442         build_pdf() 
    443     #convert_katex() 
    444     #convert_mathjax() 
    445384 
    446385    print("=== Done ===") 
Note: See TracChangeset for help on using the changeset viewer.