mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Test the viewcode extension; decode the source files before highlighting them.
This commit is contained in:
parent
8d1235d7ad
commit
d3d93a54f0
@ -31,7 +31,7 @@ def doctree_read(app, doctree):
|
||||
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
|
||||
@ -41,7 +41,7 @@ def doctree_read(app, doctree):
|
||||
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:
|
||||
@ -87,7 +87,10 @@ def collect_pages(app):
|
||||
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
|
||||
|
@ -7,7 +7,7 @@ sys.path.append(os.path.abspath('.'))
|
||||
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'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user