Changeset 9d566b2 in sasview
- Timestamp:
- Jun 13, 2017 12:29:35 PM (8 years ago)
- 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:
- afca488
- Parents:
- 0e2d287
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/sphinx-docs/build_sphinx.py
r0e2d287 r9d566b2 66 66 SPHINX_SOURCE_TEST = os.path.join(SPHINX_SOURCE, "test") 67 67 SPHINX_SOURCE_USER = os.path.join(SPHINX_SOURCE, "user") 68 KATEX_PARENT = os.path.join(SPHINX_SOURCE, "_static") 69 KATEX_PATH = os.path.join(KATEX_PARENT, "katex") 70 KATEX_VERSION = "v0.7.1" # https://github.com/khan/katex/releases 68 71 69 72 BUMPS_DOCS = os.path.join(CURRENT_SCRIPT_DIR, "..", "..", "..", … … 98 101 _remove_dir(SPHINX_BUILD) 99 102 _remove_dir(SPHINX_SOURCE) 103 _remove_dir(KATEX_PATH) 100 104 #_remove_dir(SPHINX_SOURCE_GUIFRAME) 101 105 #_remove_dir(SPHINX_SOURCE_MODELS) … … 326 330 327 331 332 def fetch_katex(version, destination="_static"): 333 from zipfile import ZipFile 334 import urllib2 335 url = "https://github.com/Khan/KaTeX/releases/download/%s/katex.zip" % version 336 cache_path = "katex_%s.zip" % version 337 if not os.path.exists(cache_path): 338 try: 339 fd_in = urllib2.urlopen(url) 340 with open(cache_path, "wb") as fd_out: 341 fd_out.write(fd_in.read()) 342 finally: 343 fd_in.close() 344 with ZipFile(cache_path) as zip: 345 zip.extractall(destination) 346 347 328 348 def retrieve_bumps_docs(): 329 349 """ … … 381 401 retrieve_user_docs() 382 402 retrieve_bumps_docs() 403 fetch_katex(version=KATEX_VERSION, destination=KATEX_PARENT) 383 404 apidoc() 384 405 build() -
docs/sphinx-docs/source/conf.py
r959eb01 r9d566b2 35 35 'sphinx.ext.todo', 36 36 'sphinx.ext.coverage', 37 ' sphinx.ext.mathjax',37 'mathjax', 38 38 'dollarmath', 39 39 'sphinx.ext.viewcode'] 40 41 STATIC_PATH = '../../_static/' 42 mathjax_path = [ 43 STATIC_PATH + 'katex/katex.min.js', 44 STATIC_PATH + 'katex/contrib/auto-render.min.js', 45 STATIC_PATH + 'rendermath.js' 46 ] 47 mathjax_css = STATIC_PATH + 'katex/katex.min.css' 48 40 49 41 50 # Add any paths that contain templates here, relative to this directory. -
src/sas/sasgui/guiframe/documentation_window.py
r959eb01 r9d566b2 16 16 import os 17 17 import logging 18 import wx19 18 import webbrowser 20 19 import urllib 21 20 import sys 22 21 22 import wx 23 try: 24 import wx.html2 as html 25 WX_SUPPORTS_HTML2 = True 26 except ImportError: 27 WX_SUPPORTS_HTML2 = False 28 29 from .gui_manager import get_app_dir 30 23 31 logger = logging.getLogger(__name__) 24 32 25 33 SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" 26 WX_SUPPORTS_HTML2 = True27 try:28 import wx.html2 as html29 except:30 WX_SUPPORTS_HTML2 = False31 34 35 THREAD_STARTED = False 36 def 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 32 42 33 from gui_manager import get_app_dir 43 def _documentation_server(doc_root, port): 44 from SimpleHTTPServer import SimpleHTTPRequestHandler 45 from SocketServer import TCPServer 34 46 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() 35 56 36 57 class DocumentationWindow(wx.Frame): … … 70 91 #Note added June 21, 2015 PDB 71 92 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" 75 97 logger.error("Could not find Sphinx documentation at %s \ 76 98 -- has it been built?", file_path) 77 elif WX_SUPPORTS_HTML2: 99 elif True: 100 start_documentation_server(docs_path, port=7999) 101 url = "http://localhost: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: 78 107 # Complete HTML/CSS support! 79 108 self.view = html.WebView.New(self) 80 109 self.view.LoadURL(url) 110 self.Bind(html.EVT_WEBVIEW_ERROR, self.OnError, self.view) 81 111 self.Show() 82 112 else: … … 88 118 webbrowser.open_new_tab(url) 89 119 120 def OnError(self, evt): 121 logger.error("%d: %s", evt.GetInt(), evt.GetString()) 122 90 123 def main(): 91 124 """ 92 125 main loop function if running alone for testing. 93 126 """ 127 url = "index.html" if len(sys.argv) <= 1 else sys.argv[1] 94 128 app = wx.App() 95 DocumentationWindow(None, -1, "index.html", "", "Documentation",)129 DocumentationWindow(None, -1, url, "", "Documentation",) 96 130 app.MainLoop() 97 131
Note: See TracChangeset
for help on using the changeset viewer.