summaryrefslogtreecommitdiff
path: root/sphinx/ext/viewcode.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/ext/viewcode.py')
-rw-r--r--sphinx/ext/viewcode.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py
index e6af4f550..89e7a9965 100644
--- a/sphinx/ext/viewcode.py
+++ b/sphinx/ext/viewcode.py
@@ -5,7 +5,7 @@
Add links to module code in Python object descriptions.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -139,7 +139,11 @@ def collect_pages(app):
# construct a page name for the highlighted source
pagename = '_modules/' + modname.replace('.', '/')
# highlight the source using the builder's highlighter
- highlighted = highlighter.highlight_block(code, 'python', linenos=False)
+ if env.config.highlight_language == 'python3':
+ lexer = 'python3'
+ else:
+ lexer = 'python'
+ highlighted = highlighter.highlight_block(code, lexer, linenos=False)
# split the code into lines
lines = highlighted.splitlines()
# split off wrap markup from the first line of the actual code