Commits

Georg Brandl committed 2adfdbd

Test the viewcode extension; decode the source files before highlighting them.

  • Participants
  • Parent commits 99196ac

Comments (0)

Files changed (2)

File sphinx/ext/viewcode.py

                 env._viewcode_modules[modname] = False
                 return
             analyzer.find_tags()
-            entry = analyzer.code, analyzer.tags, {}
+            entry = analyzer.code.decode(analyzer.encoding), analyzer.tags, {}
             env._viewcode_modules[modname] = entry
         elif entry is False:
             return
             return True
 
     for objnode in doctree.traverse(addnodes.desc):
-        if objnode['domain'] != 'py':
+        if objnode.get('domain') != 'py':
             continue
         names = set()
         for signode in objnode:
     app.builder.info(' (%d module code pages)' %
                      len(env._viewcode_modules), nonl=1)
 
-    for modname, (code, tags, used) in env._viewcode_modules.iteritems():
+    for modname, entry in env._viewcode_modules.iteritems():
+        if not entry:
+            continue
+        code, tags, used = entry
         # construct a page name for the highlighted source
         pagename = '_modules/' + modname.replace('.', '/')
         # highlight the source using the builder's highlighter

File tests/root/conf.py

 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.jsmath', 'sphinx.ext.todo',
               'sphinx.ext.coverage', 'sphinx.ext.autosummary',
               'sphinx.ext.doctest', 'sphinx.ext.extlinks',
-              'sphinx.ext.oldcmarkup', 'ext']
+              'sphinx.ext.viewcode', 'sphinx.ext.oldcmarkup', 'ext']
 
 jsmath_path = 'dummy.js'