[Python-checkins] r62562 - in doctools/trunk: CHANGES sphinx/highlighting.py

armin.ronacher python-checkins at python.org
Mon Apr 28 15:22:15 CEST 2008


Author: armin.ronacher
Date: Mon Apr 28 15:22:14 2008
New Revision: 62562

Log:
pygments_style can be an import path now



Modified:
   doctools/trunk/CHANGES
   doctools/trunk/sphinx/highlighting.py

Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Mon Apr 28 15:22:14 2008
@@ -1,3 +1,13 @@
+Release 0.3 (TBA)
+=================
+
+New features added
+------------------
+
+* If the `pygments_style` contains a dot it's treated as import path and
+  used as style class.
+
+
 Release 0.2 (Apr 27, 2008)
 ==========================
 

Modified: doctools/trunk/sphinx/highlighting.py
==============================================================================
--- doctools/trunk/sphinx/highlighting.py	(original)
+++ doctools/trunk/sphinx/highlighting.py	Mon Apr 28 15:22:14 2008
@@ -87,10 +87,11 @@
             return
         if stylename == 'sphinx':
             style = SphinxStyle
-        elif isinstance(stylename, basestring):
-            style = get_style_by_name(stylename)
+        elif '.' in stylename:
+            module, stylename = stylename.rsplit('.', 1)
+            style = getattr(__import__(module, None, None, ['']), stylename)
         else:
-            style = stylename
+            style = get_style_by_name(stylename)
         self.hfmter = {False: HtmlFormatter(style=style),
                        True: HtmlFormatter(style=style, linenos=True)}
         self.lfmter = {False: LatexFormatter(style=style),


More information about the Python-checkins mailing list