Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx handling sphinx and python versions #1826

Merged
merged 5 commits into from
Oct 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions doc/ksdomain.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-

import sys
import re

from docutils import nodes
from docutils.parsers.rst import directives

from sphinx import addnodes
from sphinx import addnodes, version_info
from sphinx.roles import XRefRole
from sphinx.locale import l_, _
from sphinx.domains import Domain, ObjType, Index
Expand Down Expand Up @@ -55,8 +56,13 @@ def add_target_and_index(self, name, sig, signode):
objects[key] = self.env.docname
indextext = self.get_index_text(self.objtype, name)
if indextext:
self.indexnode['entries'].append(('single', indextext,
targetname, ''))
# sphinx 1.4.0+ requires 5 elements
if version_info > (1, 4, 0, '', 0):
self.indexnode['entries'].append(('single', indextext,
targetname, '', None))
else:
self.indexnode['entries'].append(('single', indextext,
targetname, ''))

class KOSGlobal(KOSObject):
doc_field_types = [
Expand Down Expand Up @@ -260,8 +266,13 @@ def resolve_xref(self, env, fromdocname, builder, typ, target, node,
contnode, target + ' ' + objtype)

def get_objects(self):
for (typ, name), docname in self.data['objects'].iteritems():
yield name, name, typ, docname, name, 1
# iteritems() was renamed to items() in python 3
if sys.version_info[0] < 3:
for (typ, name), docname in self.data['objects'].iteritems():
yield name, name, typ, docname, name, 1
else:
for (typ, name), docname in self.data['objects'].items():
yield name, name, typ, docname, name, 1

def setup(app):
app.add_domain(KOSDomain)