From 2e96cea026f805dfee9a98e7cbaac8ec0993a51d Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 28 Apr 2008 13:22:14 +0000 Subject: [PATCH] pygments_style can be an import path now --- CHANGES | 10 ++++++++++ sphinx/highlighting.py | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 831b8a132..ab286cde8 100644 --- a/CHANGES +++ b/CHANGES @@ -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) ========================== diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index ba5091735..a70d8e1e0 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -87,10 +87,11 @@ class PygmentsBridge(object): 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),