Revision: 6863
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6863&view=rev
Author: jdh2358
Date: 2009-02-02 12:42:08 +0000 (Mon, 02 Feb 2009)
Log Message:
-----------
addplied Fernando's sphinxext patch
Modified Paths:
--------------
trunk/matplotlib/doc/sphinxext/inheritance_diagram.py
trunk/matplotlib/doc/sphinxext/ipython_console_highlighting.py
trunk/matplotlib/doc/sphinxext/mathmpl.py
trunk/matplotlib/doc/sphinxext/only_directives.py
Modified: trunk/matplotlib/doc/sphinxext/inheritance_diagram.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/inheritance_diagram.py 2009-02-02
08:29:18 UTC (rev 6862)
+++ trunk/matplotlib/doc/sphinxext/inheritance_diagram.py 2009-02-02
12:42:08 UTC (rev 6863)
@@ -42,6 +42,17 @@
from docutils.parsers.rst import directives
from sphinx.roles import xfileref_role
+def my_import(name):
+ """Module importer - taken from the python documentation.
+
+ This function allows importing names with dots in them."""
+
+ mod = __import__(name)
+ components = name.split('.')
+ for comp in components[1:]:
+ mod = getattr(mod, comp)
+ return mod
+
class DotException(Exception):
pass
@@ -84,6 +95,13 @@
path = base
try:
module = __import__(path, None, None, [])
+ # We must do an import of the fully qualified name. Otherwise if a
+ # subpackage 'a.b' is requested where 'import a' does NOT provide
+ # 'a.b' automatically, then 'a.b' will not be found below. This
+ # second call will force the equivalent of 'import a.b' to happen
+ # after the top-level import above.
+ my_import(fullname)
+
except ImportError:
raise ValueError(
"Could not import class or module '%s' specified for
inheritance diagram" % name)
Modified: trunk/matplotlib/doc/sphinxext/ipython_console_highlighting.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/ipython_console_highlighting.py
2009-02-02 08:29:18 UTC (rev 6862)
+++ trunk/matplotlib/doc/sphinxext/ipython_console_highlighting.py
2009-02-02 12:42:08 UTC (rev 6863)
@@ -1,18 +1,32 @@
+"""reST directive for syntax-highlighting ipython interactive sessions.
+"""
+
+#-----------------------------------------------------------------------------
+# Needed modules
+
+# Standard library
+import re
+
+# Third party
from pygments.lexer import Lexer, do_insertions
-from pygments.lexers.agile import PythonConsoleLexer, PythonLexer, \
- PythonTracebackLexer
+from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer,
+ PythonTracebackLexer)
from pygments.token import Comment, Generic
+
from sphinx import highlighting
-import re
+
+#-----------------------------------------------------------------------------
+# Global constants
line_re = re.compile('.*?\n')
+#-----------------------------------------------------------------------------
+# Code begins - classes and functions
+
class IPythonConsoleLexer(Lexer):
"""
For IPython console output or doctests, such as:
- Tracebacks are not currently supported.
-
.. sourcecode:: ipython
In [1]: a = 'foo'
@@ -24,7 +38,14 @@
foo
In [4]: 1 / 0
+
+ Notes:
+
+ - Tracebacks are not currently supported.
+
+ - It assumes the default IPython prompts, not customized ones.
"""
+
name = 'IPython console session'
aliases = ['ipython']
mimetypes = ['text/x-ipython-console']
@@ -72,4 +93,6 @@
pylexer.get_tokens_unprocessed(curcode)):
yield item
+#-----------------------------------------------------------------------------
+# Register the extension as a valid pygments lexer
highlighting.lexers['ipython'] = IPythonConsoleLexer()
Modified: trunk/matplotlib/doc/sphinxext/mathmpl.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/mathmpl.py 2009-02-02 08:29:18 UTC (rev
6862)
+++ trunk/matplotlib/doc/sphinxext/mathmpl.py 2009-02-02 12:42:08 UTC (rev
6863)
@@ -1,3 +1,25 @@
+"""matplotlib-based directive for math rendering in reST using sphinx.
+
+To use this extension, add ``mathmpl`` to the list of extensions in
+:file:`conf.py`.
+
+Note:
+
+Current SVN versions of Sphinx now include built-in support for math.
+There are two flavors:
+
+ - pngmath: uses dvipng to render the equation
+
+ - jsmath: renders the math in the browser using Javascript
+
+To use these extensions instead of the code in this module, add
+``sphinx.ext.pngmath`` or ``sphinx.ext.jsmath`` to the list of extensions in
+:file:`conf.py` instead of ``mathmpl``.
+
+All three of these options for math are designed to behave in the same
+way.
+"""
+
import os
import sys
try:
Modified: trunk/matplotlib/doc/sphinxext/only_directives.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/only_directives.py 2009-02-02 08:29:18 UTC
(rev 6862)
+++ trunk/matplotlib/doc/sphinxext/only_directives.py 2009-02-02 12:42:08 UTC
(rev 6863)
@@ -1,11 +1,15 @@
-#
-# A pair of directives for inserting content that will only appear in
-# either html or latex.
-#
+"""Sphinx directives for selective inclusion of contents.
+A pair of directives for inserting content that will only appear in
+either html or latex.
+"""
+
+# Required modules
from docutils.nodes import Body, Element
from docutils.parsers.rst import directives
+
+# Code begins
class only_base(Body, Element):
def dont_traverse(self, *args, **kwargs):
return []
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins