Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19051a9

Browse files
committed
removes sphinx xfileref_role deprecation warning
1 parent 6b11910 commit 19051a9

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

doc/sphinxext/inheritance_diagram.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class E(B): pass
4040

4141
from docutils.nodes import Body, Element
4242
from docutils.parsers.rst import directives
43-
from sphinx.roles import xfileref_role
43+
import sphinx.roles
4444

4545
def my_import(name):
4646
"""Module importer - taken from the python documentation.
@@ -308,8 +308,13 @@ def inheritance_diagram_directive(name, arguments, options, content, lineno,
308308
# references to real URLs later. These nodes will eventually be
309309
# removed from the doctree after we're done with them.
310310
for name in graph.get_all_class_names():
311-
refnodes, x = xfileref_role(
312-
'class', ':class:`%s`' % name, name, 0, state)
311+
try: # Sphinx >= 1.0
312+
refnodes, x = sphinx.roles.XRefRole()(
313+
'class', ':class:`%s`' % name, name, 0, state)
314+
except AttributeError: # Sphinx < 1.0
315+
refnodes, x = sphinx.roles.xfileref_role(
316+
'class', ':class:`%s`' % name, name, 0, state)
317+
313318
node.extend(refnodes)
314319
# Store the graph object so we can use it to generate the
315320
# dot file later

0 commit comments

Comments
 (0)