Fix warning with Sphinx 1.4

This commit is contained in:
Tatsuhiro Tsujikawa 2016-07-16 19:34:39 +09:00
parent cbd72da9a1
commit f857b63986
1 changed files with 13 additions and 4 deletions

View File

@ -15,6 +15,7 @@ from docutils import nodes
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
from sphinx import addnodes from sphinx import addnodes
from sphinx import version_info
from sphinx.roles import XRefRole from sphinx.roles import XRefRole
from sphinx.locale import l_, _ from sphinx.locale import l_, _
from sphinx.domains import Domain, ObjType, Index from sphinx.domains import Domain, ObjType, Index
@ -231,8 +232,8 @@ class RubyObject(ObjectDescription):
indextext = self.get_index_text(modname, name_cls) indextext = self.get_index_text(modname, name_cls)
if indextext: if indextext:
self.indexnode['entries'].append(('single', indextext, self.indexnode['entries'].append(
fullname, fullname)) _make_index('single', indextext, fullname, fullname))
def before_content(self): def before_content(self):
# needed for automatic qualification of members (reset in subclasses) # needed for automatic qualification of members (reset in subclasses)
@ -415,11 +416,19 @@ class RubyModule(Directive):
# modindex currently # modindex currently
if not noindex: if not noindex:
indextext = _('%s (module)') % modname indextext = _('%s (module)') % modname
inode = addnodes.index(entries=[('single', indextext, inode = addnodes.index(entries=[_make_index(
'module-' + modname, modname)]) 'single', indextext, 'module-' + modname, modname)])
ret.append(inode) ret.append(inode)
return ret return ret
def _make_index(entrytype, entryname, target, ignored, key=None):
# Sphinx 1.4 introduced backward incompatible changes, it now
# requires 5 tuples. Last one is categorization key. See
# http://www.sphinx-doc.org/en/stable/extdev/nodes.html#sphinx.addnodes.index
if version_info >= (1, 4, 0, '', 0):
return (entrytype, entryname, target, ignored, key)
else:
return (entrytype, entryname, target, ignored)
class RubyCurrentModule(Directive): class RubyCurrentModule(Directive):
""" """