Changeset 6592f56 in sasmodels
- Timestamp:
- Sep 12, 2016 1:37:18 AM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- b217c71
- Parents:
- 7b68dc5
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
r52ec91e r6592f56 706 706 Iq_units = "The returned value is scaled to units of |cm^-1| |sr^-1|, absolute scale." 707 707 Sq_units = "The returned value is a dimensionless structure factor, $S(q)$." 708 docs = convert_section_titles_to_boldface(model_info.docs) 708 docs = model_info.docs if model_info.docs is not None else "" 709 docs = convert_section_titles_to_boldface(docs) 709 710 pars = make_partable(model_info.parameters.COMMON 710 711 + model_info.parameters.kernel_parameters) … … 718 719 719 720 721 # TODO: need a single source for rst_prolog; it is also in doc/rst_prolog 722 RST_PROLOG = """\ 723 .. |Ang| unicode:: U+212B 724 .. |Ang^-1| replace:: |Ang|\ :sup:`-1` 725 .. |Ang^2| replace:: |Ang|\ :sup:`2` 726 .. |Ang^-2| replace:: |Ang|\ :sup:`-2` 727 .. |1e-6Ang^-2| replace:: 10\ :sup:`-6`\ |Ang|\ :sup:`-2` 728 .. |Ang^3| replace:: |Ang|\ :sup:`3` 729 .. |Ang^-3| replace:: |Ang|\ :sup:`-3` 730 .. |Ang^-4| replace:: |Ang|\ :sup:`-4` 731 .. |cm^-1| replace:: cm\ :sup:`-1` 732 .. |cm^2| replace:: cm\ :sup:`2` 733 .. |cm^-2| replace:: cm\ :sup:`-2` 734 .. |cm^3| replace:: cm\ :sup:`3` 735 .. |1e15cm^3| replace:: 10\ :sup:`15`\ cm\ :sup:`3` 736 .. |cm^-3| replace:: cm\ :sup:`-3` 737 .. |sr^-1| replace:: sr\ :sup:`-1` 738 .. |P0| replace:: P\ :sub:`0`\ 739 740 .. |equiv| unicode:: U+2261 741 .. |noteql| unicode:: U+2260 742 .. |TM| unicode:: U+2122 743 744 .. |cdot| unicode:: U+00B7 745 .. |deg| unicode:: U+00B0 746 .. |g/cm^3| replace:: g\ |cdot|\ cm\ :sup:`-3` 747 .. |mg/m^2| replace:: mg\ |cdot|\ m\ :sup:`-2` 748 .. |fm^2| replace:: fm\ :sup:`2` 749 .. |Ang*cm^-1| replace:: |Ang|\ |cdot|\ cm\ :sup:`-1` 750 """ 751 752 # TODO: make a better fake reference role 753 RST_ROLES = """\ 754 .. role:: ref 755 756 .. role:: numref 757 758 """ 759 720 760 def make_html(model_info): 721 761 """ … … 723 763 """ 724 764 from . import rst2html 725 return rst2html.convert(make_doc(model_info)) 765 766 rst = make_doc(model_info) 767 return rst2html.rst2html("".join((RST_ROLES, RST_PROLOG, rst))) 768 769 def view_html(model_name): 770 from . import rst2html 771 from . import modelinfo 772 kernel_module = load_kernel_module(model_name) 773 info = modelinfo.make_model_info(kernel_module) 774 url = "file://"+dirname(info.filename)+"/" 775 rst2html.wxview(make_html(info), url=url) 726 776 727 777 def demo_time(): -
sasmodels/rst2html.py
r40a87fa r6592f56 10 10 from contextlib import contextmanager 11 11 12 # CRUFT: locale.getlocale() fails on some versions of OS X 13 # See https://bugs.python.org/issue18378 14 import locale 15 if hasattr(locale, '_parse_localename'): 16 try: 17 locale._parse_localename('UTF-8') 18 except ValueError: 19 _old_parse_localename = locale._parse_localename 20 def _parse_localename(localename): 21 code = locale.normalize(localename) 22 if code == 'UTF-8': 23 return None, code 24 else: 25 return _old_parse_localename(localename) 26 locale._parse_localename = _parse_localename 27 12 28 from docutils.core import publish_parts 13 29 from docutils.writers.html4css1 import HTMLTranslator 14 30 from docutils.nodes import SkipNode 15 31 32 def wxview(html, url="", size=(850, 540)): 33 import wx 34 from wx.html2 import WebView 35 frame = wx.Frame(None, -1, size=size) 36 view = WebView.New(frame) 37 view.SetPage(html, url) 38 frame.Show() 39 return frame 16 40 17 def rst2html(rst, part="whole", math_output="html"): 41 def view_rst(filename): 42 from os.path import expanduser 43 with open(expanduser(filename)) as fid: 44 rst = fid.read() 45 html = rst2html(rst) 46 wxview(html) 47 48 def rst2html(rst, part="whole", math_output="mathjax"): 18 49 r""" 19 50 Convert restructured text into simple html. … … 44 75 else: 45 76 settings = {"math-output": math_output} 77 78 # TODO: support stylesheets 79 #html_root = "/full/path/to/_static/" 80 #sheets = [html_root+s for s in ["basic.css","classic.css"]] 81 #settings["embed_styesheet"] = True 82 #settings["stylesheet_path"] = sheets 46 83 47 84 # math2html and mathml do not support \frac12
Note: See TracChangeset
for help on using the changeset viewer.