Changeset f4771596 in sasview


Ignore:
Timestamp:
Jun 19, 2017 12:34:42 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
35ddae5
Parents:
8f1bb6f
Message:

prerender mathjax for comparison

Location:
docs/sphinx-docs
Files:
3 edited

Legend:

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

    r3194371 rf4771596  
    324324        print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 
    325325 
     326def retrieve_bumps_docs(): 
     327    """ 
     328    Copies select files from the bumps documentation into fitting perspective 
     329    """ 
     330    if os.path.exists(BUMPS_DOCS): 
     331        print("=== Retrieve BUMPS Docs ===") 
     332        filenames = [os.path.join(BUMPS_DOCS, "optimizer.rst")] 
     333        filenames += glob(os.path.join(BUMPS_DOCS, "dream-*.png")) 
     334        filenames += glob(os.path.join(BUMPS_DOCS, "fit-*.png")) 
     335        for f in filenames: 
     336            print("Copying file", f) 
     337            shutil.copy(f, BUMPS_TARGET) 
     338    else: 
     339        print(""" 
     340======= Error ======= 
     341missing directory %s 
     342The documentation will not include the optimizer selection section. 
     343Checkout the bumps source tree and rebuild the docs. 
     344""" % BUMPS_DOCS) 
     345 
     346def apidoc(): 
     347    """ 
     348    Runs sphinx-apidoc to generate .rst files from the docstrings in .py files 
     349    in the SasView build directory. 
     350    """ 
     351    print("=== Generate API Rest Files ===") 
     352 
     353    # Clean directory before generating a new version. 
     354    _remove_dir(SPHINX_SOURCE_API) 
     355 
     356    subprocess.call(["sphinx-apidoc", 
     357                     "-o", SPHINX_SOURCE_API, # Output dir. 
     358                     "-d", "8", # Max depth of TOC. 
     359                     SASVIEW_BUILD]) 
     360 
     361def build_pdf(): 
     362    """ 
     363    Runs sphinx-build for pdf.  Reads in all .rst files and spits out the final html. 
     364    """ 
     365    print("=== Build PDF Docs from ReST Files ===") 
     366    subprocess.call(["sphinx-build", 
     367                     "-b", "latex", # Builder name. TODO: accept as arg to setup.py. 
     368                     "-d", os.path.join(SPHINX_BUILD, "doctrees"), 
     369                     SPHINX_SOURCE, 
     370                     os.path.join(SPHINX_BUILD, "latex")]) 
     371 
     372    LATEXDIR = os.path.join(SPHINX_BUILD, "latex") 
     373    def pdflatex(): 
     374        subprocess.call(["pdflatex", "Sasview.tex"], cwd=LATEXDIR) 
     375    pdflatex() 
     376    pdflatex() 
     377    pdflatex() 
     378    subprocess.call(["makeindex", "-s", "python.ist", "Sasview.idx"], cwd=LATEXDIR) 
     379    pdflatex() 
     380    pdflatex() 
     381 
     382    print("=== Copy PDF to HTML Directory ===") 
     383    source = os.path.join(LATEXDIR, "Sasview.pdf") 
     384    target = os.path.join(SASVIEW_DOCS, "Sasview.pdf") 
     385    shutil.copyfile(source, target) 
     386 
     387def build(): 
     388    """ 
     389    Runs sphinx-build.  Reads in all .rst files and spits out the final html. 
     390    """ 
     391    print("=== Build HTML Docs from ReST Files ===") 
     392    subprocess.call(["sphinx-build", 
     393                     "-b", "html", # Builder name. TODO: accept as arg to setup.py. 
     394                     "-d", os.path.join(SPHINX_BUILD, "doctrees"), 
     395                     SPHINX_SOURCE, 
     396                     os.path.join(SPHINX_BUILD, "html")]) 
     397 
     398    print("=== Copy HTML Docs to Build Directory ===") 
     399    html = os.path.join(SPHINX_BUILD, "html") 
     400    copy_tree(html, SASVIEW_DOCS) 
     401 
    326402def fetch_katex(version, destination="_static"): 
    327403    from zipfile import ZipFile 
     
    339415        zip.extractall(destination) 
    340416 
    341 def retrieve_bumps_docs(): 
    342     """ 
    343     Copies select files from the bumps documentation into fitting perspective 
    344     """ 
    345     if os.path.exists(BUMPS_DOCS): 
    346         print("=== Retrieve BUMPS Docs ===") 
    347         filenames = [os.path.join(BUMPS_DOCS, "optimizer.rst")] 
    348         filenames += glob(os.path.join(BUMPS_DOCS, "dream-*.png")) 
    349         filenames += glob(os.path.join(BUMPS_DOCS, "fit-*.png")) 
    350         for f in filenames: 
    351             print("Copying file", f) 
    352             shutil.copy(f, BUMPS_TARGET) 
    353     else: 
    354         print(""" 
    355 ======= Error ======= 
    356 missing directory %s 
    357 The documentation will not include the optimizer selection section. 
    358 Checkout the bumps source tree and rebuild the docs. 
    359 """ % BUMPS_DOCS) 
    360  
    361 def apidoc(): 
    362     """ 
    363     Runs sphinx-apidoc to generate .rst files from the docstrings in .py files 
    364     in the SasView build directory. 
    365     """ 
    366     print("=== Generate API Rest Files ===") 
    367  
    368     # Clean directory before generating a new version. 
    369     _remove_dir(SPHINX_SOURCE_API) 
    370  
    371     subprocess.call(["sphinx-apidoc", 
    372                      "-o", SPHINX_SOURCE_API, # Output dir. 
    373                      "-d", "8", # Max depth of TOC. 
    374                      SASVIEW_BUILD]) 
    375  
    376 def build_pdf(): 
    377     """ 
    378     Runs sphinx-build for pdf.  Reads in all .rst files and spits out the final html. 
    379     """ 
    380     print("=== Build PDF Docs from ReST Files ===") 
    381     subprocess.call(["sphinx-build", 
    382                      "-b", "latex", # Builder name. TODO: accept as arg to setup.py. 
    383                      "-d", os.path.join(SPHINX_BUILD, "doctrees"), 
    384                      SPHINX_SOURCE, 
    385                      os.path.join(SPHINX_BUILD, "latex")]) 
    386  
    387     LATEXDIR = os.path.join(SPHINX_BUILD, "latex") 
    388     def pdflatex(): 
    389         subprocess.call(["pdflatex", "Sasview.tex"], cwd=LATEXDIR) 
    390     pdflatex() 
    391     pdflatex() 
    392     pdflatex() 
    393     subprocess.call(["makeindex", "-s", "python.ist", "Sasview.idx"], cwd=LATEXDIR) 
    394     pdflatex() 
    395     pdflatex() 
    396  
    397     print("=== Copy PDF to HTML Directory ===") 
    398     source = os.path.join(LATEXDIR, "Sasview.pdf") 
    399     target = os.path.join(SASVIEW_DOCS, "Sasview.pdf") 
    400     shutil.copyfile(source, target) 
    401  
    402 def build(): 
    403     """ 
    404     Runs sphinx-build.  Reads in all .rst files and spits out the final html. 
    405     """ 
    406     print("=== Build HTML Docs from ReST Files ===") 
    407     subprocess.call(["sphinx-build", 
    408                      "-b", "html", # Builder name. TODO: accept as arg to setup.py. 
    409                      "-d", os.path.join(SPHINX_BUILD, "doctrees"), 
    410                      SPHINX_SOURCE, 
    411                      os.path.join(SPHINX_BUILD, "html")]) 
    412  
    413     print("=== Copy HTML Docs to Build Directory ===") 
    414     html = os.path.join(SPHINX_BUILD, "html") 
    415     copy_tree(html, SASVIEW_DOCS) 
    416  
    417417def convert_katex(): 
    418418    print("=== Preprocess HTML, converting latex to html ===") 
    419419    subprocess.call(["node", "convertKaTex.js", SASVIEW_DOCS]) 
     420 
     421def convert_mathjax(): 
     422    print("=== Preprocess HTML, converting latex to html ===") 
     423    subprocess.call(["node", "convertMathJax.js", SASVIEW_DOCS]) 
     424 
     425def fetch_mathjax(): 
     426    subprocess.call(["npm", "install", "mathjax-node-page"]) 
     427    # TODO: copy fonts from node_modules/mathjax/fonts/HTML-CSS/Tex into static 
    420428 
    421429def rebuild(): 
     
    424432    retrieve_user_docs() 
    425433    retrieve_bumps_docs() 
    426     fetch_katex(version=KATEX_VERSION, destination=KATEX_PARENT) 
     434    #fetch_katex(version=KATEX_VERSION, destination=KATEX_PARENT) 
     435    #fetch_mathjax() 
    427436    apidoc() 
    428437    build() 
    429438    #build_pdf() 
    430439    #convert_katex() 
     440    #convert_mathjax() 
    431441 
    432442    print("=== Done ===") 
  • docs/sphinx-docs/source/_extensions/mathjax.py

    rafca488 rf4771596  
    105105    # http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn 
    106106    app.add_config_value('mathjax_path', 
    107                          'https://cdn.mathjax.org/mathjax/latest/MathJax.js?' 
    108                          'config=TeX-AMS-MML_HTMLorMML', False) 
     107                         'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?' 
     108                         'config=TeX-MML-AM_CHTML', 
     109                         #'config=TeX-AMS-MML_HTMLorMML', 
     110                         False) 
    109111    app.add_config_value('mathjax_css', None, 'html') 
    110112    app.add_config_value('mathjax_use_katex', False, 'html') 
  • docs/sphinx-docs/source/conf.py

    rdce368f rf4771596  
    3535              'sphinx.ext.todo', 
    3636              'sphinx.ext.coverage', 
    37               'mathjax', 
     37              'sphinx.ext.mathjax', 
     38              #'mathjax',  # replacement mathjax that allows a list of paths 
    3839              'dollarmath', 
    3940              'sphinx.ext.viewcode'] 
    4041 
     42mathjax_path = ( 
     43    'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?' 
     44    'config=TeX-MML-AM_CHTML') 
     45 
     46# For katex uncomment the following 
     47""" 
    4148#STATIC_PATH = '../../_static/' 
    4249STATIC_PATH = '' 
     
    4754] 
    4855mathjax_css = STATIC_PATH + 'katex/katex.min.css' 
     56""" 
    4957 
    5058 
     
    211219# -- Options for LaTeX output -------------------------------------------------- 
    212220 
     221# TODO: seems like angstroms is defined twice. 
    213222LATEX_PREAMBLE=r""" 
     223\usepackage[utf8]{inputenc}      % Allow unicode symbols in text 
     224\usepackage{underscore}          % Allow underscore outside math mode 
     225\usepackage[T1]{fontenc}         % Use underscore character from font 
     226\newcommand{\lt}{<}              % HTML needs \lt rather than < 
     227\newcommand{\gt}{>}              % HTML needs \gt rather than > 
    214228\renewcommand{\AA}{\text{\r{A}}} % Allow \AA in math mode 
    215 \usepackage[utf8]{inputenc}      % Allow unicode symbols in text 
    216 \usepackage[T1]{fontenc}      % Taking care of underscores 
    217 \catcode`\_=12                % Moving underscore to category 12 
    218 \newcommand{\lt}{<}           %lower than symbol handling 
    219 \newcommand{\gt}{>}           %greater than symbol handling 
     229\DeclareUnicodeCharacter {212B} {\AA}                  % Angstrom 
    220230\DeclareUnicodeCharacter {00B7} {\ensuremath{\cdot}}   % cdot 
    221231\DeclareUnicodeCharacter {00B0} {\ensuremath{^\circ}}  % degrees 
    222 \DeclareUnicodeCharacter {212B} {\AA}                  % Angstrom 
    223232""" 
    224233latex_elements = { 
Note: See TracChangeset for help on using the changeset viewer.