Revision: 7799
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7799&view=rev
Author:   fer_perez
Date:     2009-09-20 17:05:15 +0000 (Sun, 20 Sep 2009)

Log Message:
-----------
Add output prompt support.  Note: this is now in matplotlib trunk!

It's probably OK to keep it here for a while longer so sampledoc readers get
a functional, self-contained tool.  But eventually we should stop shipping
it here, once mpl has a release with this.

Modified Paths:
--------------
    trunk/sampledoc_tut/sphinxext/ipython_console_highlighting.py

Modified: trunk/sampledoc_tut/sphinxext/ipython_console_highlighting.py
===================================================================
--- trunk/sampledoc_tut/sphinxext/ipython_console_highlighting.py       
2009-09-20 17:03:40 UTC (rev 7798)
+++ trunk/sampledoc_tut/sphinxext/ipython_console_highlighting.py       
2009-09-20 17:05:15 UTC (rev 7799)
@@ -1,4 +1,8 @@
 """reST directive for syntax-highlighting ipython interactive sessions.
+
+XXX - See what improvements can be made based on the new (as of Sept 2009)
+'pycon' lexer for the python console.  At the very least it will give better
+highlighted tracebacks.
 """
 
 #-----------------------------------------------------------------------------
@@ -15,7 +19,6 @@
 
 from sphinx import highlighting
 
-
 #-----------------------------------------------------------------------------
 # Global constants
 line_re = re.compile('.*?\n')
@@ -77,8 +80,11 @@
                                    [(0, Generic.Prompt, 
continue_prompt.group())]))
                 curcode += line[continue_prompt.end():]
             elif output_prompt is not None:
+                # Use the 'error' token for output.  We should probably make
+                # our own token, but error is typicaly in a bright color like
+                # red, so it works fine for our output prompts.
                 insertions.append((len(curcode),
-                                   [(0, Generic.Output, 
output_prompt.group())]))
+                                   [(0, Generic.Error, 
output_prompt.group())]))
                 curcode += line[output_prompt.end():]
             else:
                 if curcode:
@@ -93,6 +99,16 @@
                                       pylexer.get_tokens_unprocessed(curcode)):
                 yield item
 
+
+def setup(app):
+    """Setup as a sphinx extension."""
+
+    # This is only a lexer, so adding it below to pygments appears sufficient.
+    # But if somebody knows that the right API usage should be to do that via
+    # sphinx, by all means fix it here.  At least having this setup.py
+    # suppresses the sphinx warning we'd get without it.
+    pass
+
 #-----------------------------------------------------------------------------
 # Register the extension as a valid pygments lexer
 highlighting.lexers['ipython'] = IPythonConsoleLexer()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to