~ubuntu-branches/debian/experimental/spyder/experimental

« back to all changes in this revision

Viewing changes to spyderlib/utils/inspector/sphinxify.py

  • Committer: Package Import Robot
  • Author(s): Picca Frédéric-Emmanuel
  • Date: 2013-03-13 22:11:13 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20130313221113-4xqcg0ugwmdy6gvc
Tags: 2.2.0~beta4+dfsg-1
* Imported Upstream version 2.2.0~beta4+dfsg
* remove the new added jquery.js library
* debian/patches
  - 0001-fix-documentation-installation.patch (refreshed)
    configure spyder to use jquery from the system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
AUTHORS:
7
7
- Tim Joseph Dumol (2009-09-29): initial version
8
 
- The Spyder Team: Several changes to make it work with Spyder
 
8
- The Spyder Development Team: Several changes to make it work with Spyder
9
9
 
10
10
Copyright (C) 2009 Tim Dumol <tim@timdumol.com>
11
 
Copyright (C) 2012 The Spyder Development Team
 
11
Copyright (C) 2013 The Spyder Development Team
12
12
Distributed under the terms of the BSD License
13
13
 
14
14
Taken from the Sage project (www.sagemath.org).
35
35
                                  get_module_source_path)
36
36
from spyderlib.utils import encoding
37
37
 
 
38
 
 
39
#-----------------------------------------------------------------------------
 
40
# Globals and constants
 
41
#-----------------------------------------------------------------------------
 
42
 
38
43
# Note: we do not use __file__ because it won't be working in the stand-alone
39
44
# version of Spyder (i.e. the py2exe or cx_Freeze build)
40
45
CONFDIR_PATH = get_module_source_path('spyderlib.utils.inspector')
41
46
CSS_PATH = osp.join(CONFDIR_PATH, 'static', 'css')
42
 
 
 
47
JS_PATH = osp.join(CONFDIR_PATH, 'js')
 
48
 
 
49
# To let Debian packagers redefine the MathJax and JQuery locations so they can
 
50
# use their own packages for them. See Issue 1230, comment #7.
 
51
MATHJAX_PATH = get_module_data_path('spyderlib',
 
52
                                    relpath=osp.join('utils', 'inspector',
 
53
                                                     JS_PATH, 'mathjax'),
 
54
                                    attr_name='MATHJAXPATH')
 
55
 
 
56
JQUERY_PATH = get_module_data_path('spyderlib',
 
57
                                   relpath=osp.join('utils', 'inspector',
 
58
                                                    JS_PATH),
 
59
                                   attr_name='JQUERYPATH')
 
60
 
 
61
#-----------------------------------------------------------------------------
 
62
# Utility functions
 
63
#-----------------------------------------------------------------------------
43
64
 
44
65
def is_sphinx_markup(docstring):
45
66
    """Returns whether a string contains Sphinx-style ReST markup."""
47
68
    # this could be made much more clever
48
69
    return ("`" in docstring or "::" in docstring)
49
70
 
 
71
 
50
72
def warning(message):
51
73
    """Print a warning message on the rich text view"""
52
74
    
55
77
    warning = env.get_template("warning.html")
56
78
    return warning.render(css_path=CSS_PATH, text=message)
57
79
 
 
80
 
58
81
def generate_context(name, argspec, note, math):
59
82
    """
60
83
    Generate the html_context dictionary for our Sphinx conf file.
80
103
    -------
81
104
    A dict of strings to be used by Jinja to generate the webpage
82
105
    """
83
 
 
84
 
    # To let Debian packagers redefine the MathJax location so they can use
85
 
    # their own package for it. See Issue 1230, comment #7.
86
 
    js_path = osp.join(CONFDIR_PATH, 'js')
87
 
    mathjax_path = get_module_data_path('spyderlib',
88
 
                                        relpath=osp.join('utils', 'inspector',
89
 
                                                         js_path, 'mathjax'),
90
 
                                        attr_name='MATHJAXPATH')
91
106
    
92
107
    context = \
93
108
    {
99
114
      
100
115
      # Static variables
101
116
      'css_path': CSS_PATH,
102
 
      'js_path': js_path,
103
 
      'jquery_path': osp.join(sphinx.package_dir, 'themes', 'basic', 'static'),
104
 
      'mathjax_path': mathjax_path,
 
117
      'js_path': JS_PATH,
 
118
      'jquery_path': JQUERY_PATH,
 
119
      'mathjax_path': MATHJAX_PATH,
105
120
      'right_sphinx_version': '' if sphinx.__version__ < "1.1" else 'true',
106
121
      'platform': sys.platform
107
122
    }
108
123
    
109
124
    return context
110
125
 
 
126
 
111
127
def sphinxify(docstring, context, buildername='html'):
112
128
    """
113
129
    Runs Sphinx on a docstring and outputs the processed documentation.