##// END OF EJS Templates
Added test for the pretty.py extension and fixed sphinx docs....
Brian Granger -
Show More
@@ -0,0 +1,56 b''
1 #!/usr/bin/env python
2 # encoding: utf-8
3 """
4 Simple tests for :mod:`IPython.extensions.pretty`.
5 """
6
7 #-----------------------------------------------------------------------------
8 # Copyright (C) 2008-2009 The IPython Development Team
9 #
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
12 #-----------------------------------------------------------------------------
13
14 #-----------------------------------------------------------------------------
15 # Imports
16 #-----------------------------------------------------------------------------
17
18 import sys
19 from unittest import TestCase
20
21 from IPython.core.component import Component, masquerade_as
22 from IPython.core.iplib import InteractiveShell
23 from IPython.extensions import pretty as pretty_ext
24 from IPython.external import pretty
25
26 from IPython.utils.traitlets import Bool
27
28 #-----------------------------------------------------------------------------
29 # Tests
30 #-----------------------------------------------------------------------------
31
32
33 class InteractiveShellStub(Component):
34 pprint = Bool(True)
35
36 class A(object):
37 pass
38
39 def a_pprinter(o, p, c):
40 return p.text("<A>")
41
42 class TestPrettyResultDisplay(TestCase):
43
44 def setUp(self):
45 self.ip = InteractiveShellStub(None)
46 # This allows our stub to be retrieved instead of the real InteractiveShell
47 masquerade_as(self.ip, InteractiveShell)
48 self.prd = pretty_ext.PrettyResultDisplay(self.ip, name='pretty_result_display')
49
50 def test_for_type(self):
51 self.prd.for_type(A, a_pprinter)
52 a = A()
53 result = pretty.pretty(a)
54 self.assertEquals(result, "<A>")
55
56
@@ -1,192 +1,192 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #
2 #
3 # IPython documentation build configuration file.
3 # IPython documentation build configuration file.
4
4
5 # NOTE: This file has been edited manually from the auto-generated one from
5 # NOTE: This file has been edited manually from the auto-generated one from
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
7 # needed, generate a scratch one and merge by hand any new fields needed.
7 # needed, generate a scratch one and merge by hand any new fields needed.
8
8
9 #
9 #
10 # This file is execfile()d with the current directory set to its containing dir.
10 # This file is execfile()d with the current directory set to its containing dir.
11 #
11 #
12 # The contents of this file are pickled, so don't put values in the namespace
12 # The contents of this file are pickled, so don't put values in the namespace
13 # that aren't pickleable (module imports are okay, they're removed automatically).
13 # that aren't pickleable (module imports are okay, they're removed automatically).
14 #
14 #
15 # All configuration values have a default value; values that are commented out
15 # All configuration values have a default value; values that are commented out
16 # serve to show the default value.
16 # serve to show the default value.
17
17
18 import sys, os
18 import sys, os
19
19
20 # If your extensions are in another directory, add it here. If the directory
20 # If your extensions are in another directory, add it here. If the directory
21 # is relative to the documentation root, use os.path.abspath to make it
21 # is relative to the documentation root, use os.path.abspath to make it
22 # absolute, like shown here.
22 # absolute, like shown here.
23 sys.path.append(os.path.abspath('../sphinxext'))
23 sys.path.append(os.path.abspath('../sphinxext'))
24
24
25 # Import support for ipython console session syntax highlighting (lives
25 # Import support for ipython console session syntax highlighting (lives
26 # in the sphinxext directory defined above)
26 # in the sphinxext directory defined above)
27 import ipython_console_highlighting
27 import ipython_console_highlighting
28
28
29 # We load the ipython release info into a dict by explicit execution
29 # We load the ipython release info into a dict by explicit execution
30 iprelease = {}
30 iprelease = {}
31 execfile('../../IPython/core/release.py',iprelease)
31 execfile('../../IPython/core/release.py',iprelease)
32
32
33 # General configuration
33 # General configuration
34 # ---------------------
34 # ---------------------
35
35
36 # Add any Sphinx extension module names here, as strings. They can be extensions
36 # Add any Sphinx extension module names here, as strings. They can be extensions
37 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
37 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
38 extensions = [
38 extensions = [
39 # 'matplotlib.sphinxext.mathmpl',
39 # 'matplotlib.sphinxext.mathmpl',
40 'matplotlib.sphinxext.only_directives',
40 'matplotlib.sphinxext.only_directives',
41 # 'matplotlib.sphinxext.plot_directive',
41 # 'matplotlib.sphinxext.plot_directive',
42 'sphinx.ext.autodoc',
42 'sphinx.ext.autodoc',
43 'sphinx.ext.doctest',
43 'sphinx.ext.doctest',
44 'inheritance_diagram',
44 'inheritance_diagram',
45 'ipython_console_highlighting',
45 'ipython_console_highlighting',
46 'numpydoc', # to preprocess docstrings
46 'numpydoc', # to preprocess docstrings
47 ]
47 ]
48
48
49 # Add any paths that contain templates here, relative to this directory.
49 # Add any paths that contain templates here, relative to this directory.
50 templates_path = ['_templates']
50 templates_path = ['_templates']
51
51
52 # The suffix of source filenames.
52 # The suffix of source filenames.
53 source_suffix = '.txt'
53 source_suffix = '.txt'
54
54
55 # The master toctree document.
55 # The master toctree document.
56 master_doc = 'index'
56 master_doc = 'index'
57
57
58 # General substitutions.
58 # General substitutions.
59 project = 'IPython'
59 project = 'IPython'
60 copyright = '2008, The IPython Development Team'
60 copyright = '2008, The IPython Development Team'
61
61
62 # The default replacements for |version| and |release|, also used in various
62 # The default replacements for |version| and |release|, also used in various
63 # other places throughout the built documents.
63 # other places throughout the built documents.
64 #
64 #
65 # The full version, including alpha/beta/rc tags.
65 # The full version, including alpha/beta/rc tags.
66 release = iprelease['version']
66 release = iprelease['version']
67 # The short X.Y version.
67 # The short X.Y version.
68 version = '.'.join(release.split('.',2)[:2])
68 version = '.'.join(release.split('.',2)[:2])
69
69
70
70
71 # There are two options for replacing |today|: either, you set today to some
71 # There are two options for replacing |today|: either, you set today to some
72 # non-false value, then it is used:
72 # non-false value, then it is used:
73 #today = ''
73 #today = ''
74 # Else, today_fmt is used as the format for a strftime call.
74 # Else, today_fmt is used as the format for a strftime call.
75 today_fmt = '%B %d, %Y'
75 today_fmt = '%B %d, %Y'
76
76
77 # List of documents that shouldn't be included in the build.
77 # List of documents that shouldn't be included in the build.
78 #unused_docs = []
78 #unused_docs = []
79
79
80 # List of directories, relative to source directories, that shouldn't be searched
80 # List of directories, relative to source directories, that shouldn't be searched
81 # for source files.
81 # for source files.
82 exclude_dirs = ['attic']
82 exclude_dirs = ['attic']
83
83
84 # If true, '()' will be appended to :func: etc. cross-reference text.
84 # If true, '()' will be appended to :func: etc. cross-reference text.
85 #add_function_parentheses = True
85 #add_function_parentheses = True
86
86
87 # If true, the current module name will be prepended to all description
87 # If true, the current module name will be prepended to all description
88 # unit titles (such as .. function::).
88 # unit titles (such as .. function::).
89 #add_module_names = True
89 #add_module_names = True
90
90
91 # If true, sectionauthor and moduleauthor directives will be shown in the
91 # If true, sectionauthor and moduleauthor directives will be shown in the
92 # output. They are ignored by default.
92 # output. They are ignored by default.
93 #show_authors = False
93 #show_authors = False
94
94
95 # The name of the Pygments (syntax highlighting) style to use.
95 # The name of the Pygments (syntax highlighting) style to use.
96 pygments_style = 'sphinx'
96 pygments_style = 'sphinx'
97
97
98
98
99 # Options for HTML output
99 # Options for HTML output
100 # -----------------------
100 # -----------------------
101
101
102 # The style sheet to use for HTML and HTML Help pages. A file of that name
102 # The style sheet to use for HTML and HTML Help pages. A file of that name
103 # must exist either in Sphinx' static/ path, or in one of the custom paths
103 # must exist either in Sphinx' static/ path, or in one of the custom paths
104 # given in html_static_path.
104 # given in html_static_path.
105 html_style = 'default.css'
105 html_style = 'default.css'
106
106
107 # The name for this set of Sphinx documents. If None, it defaults to
107 # The name for this set of Sphinx documents. If None, it defaults to
108 # "<project> v<release> documentation".
108 # "<project> v<release> documentation".
109 #html_title = None
109 #html_title = None
110
110
111 # The name of an image file (within the static path) to place at the top of
111 # The name of an image file (within the static path) to place at the top of
112 # the sidebar.
112 # the sidebar.
113 #html_logo = None
113 #html_logo = None
114
114
115 # Add any paths that contain custom static files (such as style sheets) here,
115 # Add any paths that contain custom static files (such as style sheets) here,
116 # relative to this directory. They are copied after the builtin static files,
116 # relative to this directory. They are copied after the builtin static files,
117 # so a file named "default.css" will overwrite the builtin "default.css".
117 # so a file named "default.css" will overwrite the builtin "default.css".
118 html_static_path = ['_static']
118 html_static_path = ['_static']
119
119
120 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
120 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
121 # using the given strftime format.
121 # using the given strftime format.
122 html_last_updated_fmt = '%b %d, %Y'
122 html_last_updated_fmt = '%b %d, %Y'
123
123
124 # If true, SmartyPants will be used to convert quotes and dashes to
124 # If true, SmartyPants will be used to convert quotes and dashes to
125 # typographically correct entities.
125 # typographically correct entities.
126 #html_use_smartypants = True
126 #html_use_smartypants = True
127
127
128 # Custom sidebar templates, maps document names to template names.
128 # Custom sidebar templates, maps document names to template names.
129 #html_sidebars = {}
129 #html_sidebars = {}
130
130
131 # Additional templates that should be rendered to pages, maps page names to
131 # Additional templates that should be rendered to pages, maps page names to
132 # template names.
132 # template names.
133 #html_additional_pages = {}
133 #html_additional_pages = {}
134
134
135 # If false, no module index is generated.
135 # If false, no module index is generated.
136 #html_use_modindex = True
136 #html_use_modindex = True
137
137
138 # If true, the reST sources are included in the HTML build as _sources/<name>.
138 # If true, the reST sources are included in the HTML build as _sources/<name>.
139 #html_copy_source = True
139 #html_copy_source = True
140
140
141 # If true, an OpenSearch description file will be output, and all pages will
141 # If true, an OpenSearch description file will be output, and all pages will
142 # contain a <link> tag referring to it. The value of this option must be the
142 # contain a <link> tag referring to it. The value of this option must be the
143 # base URL from which the finished HTML is served.
143 # base URL from which the finished HTML is served.
144 #html_use_opensearch = ''
144 #html_use_opensearch = ''
145
145
146 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
146 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
147 #html_file_suffix = ''
147 #html_file_suffix = ''
148
148
149 # Output file base name for HTML help builder.
149 # Output file base name for HTML help builder.
150 htmlhelp_basename = 'ipythondoc'
150 htmlhelp_basename = 'ipythondoc'
151
151
152
152
153 # Options for LaTeX output
153 # Options for LaTeX output
154 # ------------------------
154 # ------------------------
155
155
156 # The paper size ('letter' or 'a4').
156 # The paper size ('letter' or 'a4').
157 latex_paper_size = 'letter'
157 latex_paper_size = 'letter'
158
158
159 # The font size ('10pt', '11pt' or '12pt').
159 # The font size ('10pt', '11pt' or '12pt').
160 latex_font_size = '11pt'
160 latex_font_size = '11pt'
161
161
162 # Grouping the document tree into LaTeX files. List of tuples
162 # Grouping the document tree into LaTeX files. List of tuples
163 # (source start file, target name, title, author, document class [howto/manual]).
163 # (source start file, target name, title, author, document class [howto/manual]).
164
164
165 latex_documents = [ ('index', 'ipython.tex', 'IPython Documentation',
165 latex_documents = [ ('index', 'ipython.tex', 'IPython Documentation',
166 ur"""The IPython Development Team""",
166 ur"""The IPython Development Team""",
167 'manual'),
167 'manual', True),
168 ]
168 ]
169
169
170 # The name of an image file (relative to this directory) to place at the top of
170 # The name of an image file (relative to this directory) to place at the top of
171 # the title page.
171 # the title page.
172 #latex_logo = None
172 #latex_logo = None
173
173
174 # For "manual" documents, if this is true, then toplevel headings are parts,
174 # For "manual" documents, if this is true, then toplevel headings are parts,
175 # not chapters.
175 # not chapters.
176 #latex_use_parts = False
176 #latex_use_parts = False
177
177
178 # Additional stuff for the LaTeX preamble.
178 # Additional stuff for the LaTeX preamble.
179 #latex_preamble = ''
179 #latex_preamble = ''
180
180
181 # Documents to append as an appendix to all manuals.
181 # Documents to append as an appendix to all manuals.
182 #latex_appendices = []
182 #latex_appendices = []
183
183
184 # If false, no module index is generated.
184 # If false, no module index is generated.
185 #latex_use_modindex = True
185 #latex_use_modindex = True
186
186
187
187
188 # Cleanup
188 # Cleanup
189 # -------
189 # -------
190 # delete release info to avoid pickling errors from sphinx
190 # delete release info to avoid pickling errors from sphinx
191
191
192 del iprelease
192 del iprelease
General Comments 0
You need to be logged in to leave comments. Login now