Changeset f8b59e3 in sasview


Ignore:
Timestamp:
Aug 16, 2017 8:55:45 AM (7 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:
78d0a9b
Parents:
35ddae5 (diff), 940d034 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ticket-510' into ticket-639-katex

Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/media/residuals_help.rst

    rdf1a6ed r940d034  
    3434.. math:: 
    3535 
    36   \chi^2/N_{pts} =  \sum[(Y_i - Y_{theory}_i)^2 / (Y_error_i)^2] / N_{pts} 
     36  \chi^2/N_{pts} =  \sum[(Y_i - \mathrm{theory}_i)^2 / \mathrm{error}_i^2] / N_{pts} 
    3737 
    3838This differs slightly from what is sometimes called the 'reduced $\chi^2$' 
  • .gitignore

    recdd132 re9df8a5  
    4949/docs/sphinx-docs/source/user/perspectives 
    5050/docs/sphinx-docs/source/user/sasgui 
     51/docs/sphinx-docs/katex*.zip 
    5152 
    5253 
  • docs/sphinx-docs/Makefile

    r1d5f5c2 r3194371  
    1616PAPEROPT_a4     = -D latex_paper_size=a4 
    1717PAPEROPT_letter = -D latex_paper_size=letter 
    18 ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 
     18ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source-temp 
    1919# the i18n builder cannot share the environment and doctrees with the others 
    2020I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 
     
    5353        rm -rf source/dev/api 
    5454        sphinx-apidoc -o source/dev/api -d 8 ../../src 
    55          
     55 
    5656html: stubs 
    5757        $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 
  • docs/sphinx-docs/build_sphinx.py

    rf2ea95a rf4771596  
    324324        print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 
    325325 
    326  
    327326def retrieve_bumps_docs(): 
    328327    """ 
     
    360359                     SASVIEW_BUILD]) 
    361360 
     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 
    362387def build(): 
    363388    """ 
    364389    Runs sphinx-build.  Reads in all .rst files and spits out the final html. 
    365390    """ 
    366     print("=== Build HTML Docs from Rest Files ===") 
     391    print("=== Build HTML Docs from ReST Files ===") 
    367392    subprocess.call(["sphinx-build", 
    368393                     "-b", "html", # Builder name. TODO: accept as arg to setup.py. 
     
    375400    copy_tree(html, SASVIEW_DOCS) 
    376401 
    377     #We are building latex doc on linux only 
    378     if "linux" in platform: 
    379         print "=== Build Latex Docs from Rest Files ===" 
    380         subprocess.call(["sphinx-build", 
    381                      "-b", "latex", # Builder name. TODO: accept as arg to setup.py. 
    382                      "-d", os.path.join(SPHINX_BUILD, "doctrees"), 
    383                      SPHINX_SOURCE, 
    384                      os.path.join(SPHINX_BUILD, "latex")]) 
    385  
    386         print "=== Copy Latex Docs to Build Directory ===" 
    387         latex = os.path.join(SPHINX_BUILD, "latex") 
    388         copy_tree(latex, SASVIEW_DOCS) 
     402def fetch_katex(version, destination="_static"): 
     403    from zipfile import ZipFile 
     404    import urllib2 
     405    url = "https://github.com/Khan/KaTeX/releases/download/%s/katex.zip" % version 
     406    cache_path = "katex_%s.zip" % version 
     407    if not os.path.exists(cache_path): 
     408        try: 
     409            fd_in = urllib2.urlopen(url) 
     410            with open(cache_path, "wb") as fd_out: 
     411                fd_out.write(fd_in.read()) 
     412        finally: 
     413            fd_in.close() 
     414    with ZipFile(cache_path) as zip: 
     415        zip.extractall(destination) 
     416 
     417def convert_katex(): 
     418    print("=== Preprocess HTML, converting latex to html ===") 
     419    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 
    389428 
    390429def rebuild(): 
     
    393432    retrieve_user_docs() 
    394433    retrieve_bumps_docs() 
     434    #fetch_katex(version=KATEX_VERSION, destination=KATEX_PARENT) 
     435    #fetch_mathjax() 
    395436    apidoc() 
    396437    build() 
     438    #build_pdf() 
     439    #convert_katex() 
     440    #convert_mathjax() 
    397441 
    398442    print("=== Done ===") 
  • docs/sphinx-docs/source/conf.py

    rf2ea95a rf4771596  
    3636              'sphinx.ext.coverage', 
    3737              'sphinx.ext.mathjax', 
     38              #'mathjax',  # replacement mathjax that allows a list of paths 
    3839              'dollarmath', 
    3940              'sphinx.ext.viewcode'] 
     41 
     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""" 
     48#STATIC_PATH = '../../_static/' 
     49STATIC_PATH = '' 
     50mathjax_path = [ 
     51    STATIC_PATH + 'katex/katex.min.js', 
     52    STATIC_PATH + 'katex/contrib/auto-render.min.js', 
     53    STATIC_PATH + 'rendermath.js' 
     54] 
     55mathjax_css = STATIC_PATH + 'katex/katex.min.css' 
     56""" 
     57 
    4058 
    4159# Add any paths that contain templates here, relative to this directory. 
     
    201219# -- Options for LaTeX output -------------------------------------------------- 
    202220 
     221# TODO: seems like angstroms is defined twice. 
    203222LATEX_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 > 
    204228\renewcommand{\AA}{\text{\r{A}}} % Allow \AA in math mode 
    205 \usepackage[utf8]{inputenc}      % Allow unicode symbols in text 
    206 \usepackage[T1]{fontenc}      % Taking care of underscores 
    207 \catcode`\_=12                % Moving underscore to category 12 
    208 \newcommand{\lt}{<}           %lower than symbol handling 
    209 \newcommand{\gt}{>}           %greater than symbol handling 
     229\DeclareUnicodeCharacter {212B} {\AA}                  % Angstrom 
    210230\DeclareUnicodeCharacter {00B7} {\ensuremath{\cdot}}   % cdot 
    211231\DeclareUnicodeCharacter {00B0} {\ensuremath{^\circ}}  % degrees 
    212 \DeclareUnicodeCharacter {212B} {\AA}                  % Angstrom 
    213232""" 
    214233latex_elements = { 
  • src/sas/sasgui/guiframe/documentation_window.py

    r959eb01 r35ddae5  
    1616import os 
    1717import logging 
    18 import wx 
    1918import webbrowser 
    2019import urllib 
    2120import sys 
    2221 
     22import wx 
     23try: 
     24    import wx.html2 as html 
     25    WX_SUPPORTS_HTML2 = True 
     26except ImportError: 
     27    WX_SUPPORTS_HTML2 = False 
     28 
     29from .gui_manager import get_app_dir 
     30 
    2331logger = logging.getLogger(__name__) 
    2432 
    2533SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" 
    26 WX_SUPPORTS_HTML2 = True 
    27 try: 
    28     import wx.html2 as html 
    29 except: 
    30     WX_SUPPORTS_HTML2 = False 
    3134 
     35THREAD_STARTED = False 
     36def start_documentation_server(doc_root, port): 
     37    import thread 
     38    global THREAD_STARTED 
     39    if not THREAD_STARTED: 
     40        thread.start_new_thread(_documentation_server, (doc_root, port)) 
     41        THREAD_STARTED = True 
    3242 
    33 from gui_manager import get_app_dir 
     43def _documentation_server(doc_root, port): 
     44    from SimpleHTTPServer import SimpleHTTPRequestHandler 
     45    from SocketServer import TCPServer 
    3446 
     47    os.chdir(doc_root) 
     48    httpd = TCPServer(("127.0.0.1", port), SimpleHTTPRequestHandler, bind_and_activate=False) 
     49    httpd.allow_reuse_address = True 
     50    try: 
     51        httpd.server_bind() 
     52        httpd.server_activate() 
     53        httpd.serve_forever() 
     54    finally: 
     55        httpd.server_close() 
    3556 
    3657class DocumentationWindow(wx.Frame): 
     
    7091        #Note added June 21, 2015     PDB 
    7192        file_path = os.path.join(docs_path, path) 
    72         url = "file:///" + urllib.quote(file_path, r'/\:')+ url_instruction 
    73  
    74         if not os.path.exists(file_path): 
     93        if path.startswith('http'): 
     94            url = path 
     95        elif not os.path.exists(file_path): 
     96            url = "index.html" 
    7597            logger.error("Could not find Sphinx documentation at %s \ 
    7698            -- has it been built?", file_path) 
    77         elif WX_SUPPORTS_HTML2: 
     99        elif False: 
     100            start_documentation_server(docs_path, port=7999) 
     101            url = "http://127.0.0.1:7999/" + path.replace('\\', '/') + url_instruction 
     102        else: 
     103            url = "file:///" + urllib.quote(file_path, r'/\:')+ url_instruction 
     104 
     105        logger.info("showing url " + url) 
     106        if WX_SUPPORTS_HTML2: 
    78107            # Complete HTML/CSS support! 
    79108            self.view = html.WebView.New(self) 
    80109            self.view.LoadURL(url) 
     110            self.Bind(html.EVT_WEBVIEW_ERROR, self.OnError, self.view) 
    81111            self.Show() 
    82112        else: 
     
    88118            webbrowser.open_new_tab(url) 
    89119 
     120    def OnError(self, evt): 
     121        logger.error("%d: %s", evt.GetInt(), evt.GetString()) 
     122 
    90123def main(): 
    91124    """ 
    92125    main loop function if running alone for testing. 
    93126    """ 
     127    url = "index.html" if len(sys.argv) <= 1 else sys.argv[1] 
    94128    app = wx.App() 
    95     DocumentationWindow(None, -1, "index.html", "", "Documentation",) 
     129    DocumentationWindow(None, -1, url, "", "Documentation",) 
    96130    app.MainLoop() 
    97131 
Note: See TracChangeset for help on using the changeset viewer.